I am trying to change or assign the projection of a Germany-Shapefile from NA
to +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
, but somehow it doesn't work well.
Reproducible Example: Shapefile and other files can be downloaded here:
What I tried is the following:
library(maptools)
library(sp)
library(rgeos)
library(rgdal)
projection.x <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0")
mapG <- readShapePoly("vg2500_lan.shp", verbose=TRUE, proj4string=projection.x)
summary(mapG)
mapG <- spTransform(mapG, CRS("+proj=longlat +ellps=WGS84 +datum=WGS84"))
So, the problem is I cannot plot my observations on the map. See below
The ponits were detected using geocode
function from ggmap
package.
Any idea how to change the projection of the shapefile or the projection of the google coordinates would be highly appreciated!
I found my mistake. The solution would be:
mapG <- readOGR("vg2500_lan.shp", layer="vg2500_lan")
summary(mapG)
germG <- spTransform(mapG, CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"))
plot(germG, axes=T)
And the desired output:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With