I'm working with R. And to have a Rasterfile and a Shapefile. Now I want to fit their CRS/ EPSG so I can plot them together. Several approaches I've tried won't work.
Someone may help?
THE CRS/EPSG:
st_crs(Shape)
CRS: Shapefile crs(Shape)
oordinate Reference System:
Deprecated Proj.4 representation: +proj=longlat +datum=WGS84 +no_defs
WKT2 2019 representation:
GEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["latitude",north,
ORDER1,
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["longitude",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4326]]
crs(Raster)
Coordinate Reference System:
Deprecated Proj.4 representation: +proj=longlat +datum=WGS84 +no_defs
WKT2 2019 representation:
GEOGCRS["WGS 84 (with axis order normalized for visualization)",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["geodetic longitude (Lon)",east,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433,
ID["EPSG",9122]]],
AXIS["geodetic latitude (Lat)",north,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433,
ID["EPSG",9122]]]]
I read the the both files by:
Raster <- raster("CMR10adjv4.tif")
Shape <- st_read("CMR_adm3.shp")
Different approaches to change the EPSG didn't work (see the following error messages):
shp <- spTransform(Shape, crs(Raster))
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘spTransform’ for signature ‘"sf", "CRS"’
st_crs(Shape) <- st_transform(Shape, crs = '+init=EPSG:9122')
Error in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
crs not found: is it missing?
In addition: Warning message:
In CPL_crs_from_input(x) : GDAL Error 1: PROJ: proj_create: crs not found
> pr1 <- projectRaster(Raster, crs= '+init=EPSG:9122')
Error in sp::CRS(...) : NA
st_crs(Shape) <- st_transform(Shape, crs = '+init=EPSG:9122')
Error in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy, :
crs not found: is it missing?
In addition: Warning message:
In CPL_crs_from_input(x) : GDAL Error 1: PROJ: proj_create: crs not found
Additional information to my Files are:
> Raster
class : RasterLayer
dimensions : 13713, 9238, 126680694 (nrow, ncol, ncell)
resolution : 0.0008333, 0.0008333 (x, y)
extent : 8.494606, 16.19263, 1.652261, 13.0793 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +no_defs
source : CMR10adjv4.tif
names : CMR10adjv4
values : 0, 1344.71 (min, max)
S
hape
Simple feature collection with 360 features and 15 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 8.499454 ymin: 1.652267 xmax: 16.19105 ymax: 13.07739
Geodetic CRS: WGS 84
First 10 features:
Using: Shape <- st_transform(Shape, crs(Raster))
giving me a wrong picture like: