Created
August 2, 2017 22:20
-
-
Save valentinitnelav/bdea511468eed337440ab2f2bc12c000 to your computer and use it in GitHub Desktop.
Revisions
-
valentinitnelav created this gist
Aug 2, 2017 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ require(rgeos) require(sp) require(plotKML) # Generate a random grid-points for a (almost) global bounding box b.box <- as(raster::extent(120, -120, -60, 60), "SpatialPolygons") proj4string(b.box) <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" set.seed(2017) pts <- sp::spsample(b.box, n=100, type="regular") plot(pts@coords) # Project to Mollweide projection to be able to apply buffer with `gBuffer` # (one could use other projection) pts.moll <- sp::spTransform(pts, CRSobj = "+proj=moll") # create 1000 km buffers around the points buf1000km.moll <- rgeos::gBuffer(spgeom = pts.moll, byid = TRUE, width = 10^6) plot(buf1000km.moll) # convert back to WGS84 unprojected buf1000km.WGS84 <- sp::spTransform(buf1000km.moll, CRSobj = proj4string(pts)) plot(buf1000km.WGS84) # distorsions are present # save as KML to visualize distorted Euclidian buffers on Google Earth plotKML::kml(buf1000km.WGS84, file.name = "buf1000km.WGS84.kml")