I have a .shp file and I want to change its crs
, I have tried to use spTransform
but it does not work in my case. The .shp file can be found at https://www.dropbox.com/s/8wfgf8207dbh79r/gpr_000b11a_e.zip?dl=0.
library(rgdal)
shpfile <- readOGR(dsn="D:/Map",layer = "gpr_000b11a_e")
crs(shpfile)
CRS arguments:
+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0
spTransform(shpfile, CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
crs(shpfile)
CRS arguments:
+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0
The problem is: after spTransform
, the crs for the shapefile does not change. Thanks for any help.
The problem is that you didn't attribute the transformed shape to an object. Try this:
shpfile <- spTransform(shpfile,
CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"))
I recommend you the package sf
, for reading and handling .shp
files, its easy to use and efficient.
Hope it helps.