Estou atualizando o código rgdal
para usar o sf
pacote.
Tenho um SpatialPolygonsDataFrame que preciso projetar. Em rgdal
eu usei proj4string()
. Com sf
, tentei usar st_crs()
:
library(sf)
ext <- extent(c(0, 20, 0, 20))
r <- raster(ext, res=1)
r[] = 1:ncell(r)
# convert the raster to polygon:
Output_Shapefile <- rasterToPolygons(r)
prj <- "+proj=eqdc +lat_0=17.8333333333333 +lon_0=-66.4333333333333 +lat_1=18.4333333333333 +lat_2=18.0333333333333 +x_0=200000 +y_0=200000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
#project:
# proj4string(Output_Shapefile) <- prj
st_crs(Output_Shapefile) <- prj
Aqui está o erro que estou recebendo:
Error in UseMethod("st_crs<-") :
no applicable method for 'st_crs<-' applied to an object of class "c('SpatialPolygonsDataFrame', 'SpatialPolygons', 'Spatial', 'SpatialVector')"