I would like to create a buffer around the shape-shape file with the wgs84 coordinates.
I prepared a shapefile with one line segment and Datum: D_WGS_1984. After that I loaded .shp into R using the "readOGR" command.
After that, I tried the gBuffer method from the rgeos package to calculate the buffer:
gBuffer(l2, width=1.0, quadsegs=5, capStyle="ROUND", joinStyle="ROUND", mitreLimit=0.01)) Warning: In gBuffer(l2, width = 1, quadsegs = 5, capStyle = "ROUND", joinStyle = "ROUND", : Spatial object is not projected; GEOS expects planar coordinates
Obviously, the team has a problem with the coordinates. I tried some approaches but could not find a solution.
Another example I found for a buffer around dots was the following, but I'm not sure how to use it in my case: http://r-sig-geo.2731867.n2.nabble.com/compute-buffer-from- point-shapefile-to-have-shapefile-td4574666.html
Any ideas?
Regards, Stefan
// update:
Reduced to the corresponding part, here is the code:
require("rgeos") require("rgdal") l2=readOGR(dsn="C:/Maps", layer="osm_ms") proj4string(l2) <- CRS("+proj=longlat") l2.trans <- spTransform(l2, CRS("+proj=longlat")) summary(l2.trans) > Object of class SpatialLinesDataFrame > Coordinates: > min max > x 7.478942 7.772171 > y 51.840318 52.058856 > Is projected: FALSE > proj4string : [+proj=longlat +ellps=WGS84] > Data attributes: plot(l2.trans) plot(gBuffer(l2.trans, width=1.0, quadsegs=5, capStyle="ROUND", joinStyle="ROUND", mitreLimit=0.01))
Probably the line:
Projected: FALSE is causing the problem, but I'm not sure how to use spTranform and how to find the correct projection.