I am trying to get an altitude raster to coincide with a working spatial polygon dataframe that shapes the region with data from an .nc file. The .nc file, and thus the derived spatial polygon dataframe, came with no crs. Instead, I gave it one that coincides with location data I will later use.
My problem is that I do not get to correctly overlap the altitude raster and the polygon, despite following what seems to be the required approach.
Here is the data: alt=https:https://www.dropbox.com/t/DmdmofDGvPPsP3uF r=https://www.dropbox.com/sh/uen3y3vig9jh1ij/AACqvB9bNC7VLcEHmjoKOcPga?dl=0
alt=raster("/Users/agus/Dropbox/geo resources/rasters/alt.grd")
polys <- as(r, "SpatialPolygonsDataFrame")
r1=rasterize(polys,pCTMAXe)
alt=crop(alt,r1)
altr=projectRaster(from=alt,to=r1,res=res(r1))
plot(r1)
plot(altr,add=T)
The objects have similar extent, resolution and projection, but plots do not overlap,why?!
I have tried options in: How to rasterize an object of class SpatialPolygonsDataframe in R https://www.rdocumentation.org/packages/raster/versions/2.5-8/topics/projectRaster Handling raster data in a "rotated pole projection" with R? Plotting spatial data when two spatial objects have different CRS using R
raster
package? Check the content with e.g. Notepad++, just 1 KB in size.