I've got my data_map for the actual geom_point plot, which looks similar to this:
| x | y | Cat | E | N | Category | var |
|---|---|---|---|---|---|---|
| 2804705 | 1162511 | A | 2804704 | 1162510 | A | 1 |
| 2814805 | 1162611 | B | 2814805 | 1162611 | A | 2 |
| 2803905 | 1163011 | A | 2803906 | 1163012 | B | 3 |
| 2814905 | 1162711 | B | 2814903 | 1162712 | B | A |
as long as I only create a scatterplot, this works fine:
ggplot(data = data_map) +
geom_point(aes(x = x, y = y, fill = Cat))+
geom_point(aes(color = Category, x = E, y = N))+
facet_wrap(~var, ncol = 2) +
coord_fixed(ratio = 1)
after this only a few cosmetic adaptions happen. so far it works.
However, now I need to add an aspect raster file (.tif) as background map. I derived the aspect raster using the aspect function in ArcGIS Pro from these DEM raster data: https://www.swisstopo.admin.ch/en/geodata/height/alti3d.html.
I already tried everything I know (various versions of geom_raster and geom_spatraster) and searched several hours online and asked AI. I just cant get the raster as a background map. could anyone tell me how I have to add the tif raster as a background map? it shouldn't change the plot per se, I just need to add the background map and the legend (and of course some custom colors). thank you!