Skip to content
Prev 17696 / 29559 Next

writeOGR(GeoJSON) to string instead of file

On Wed, 6 Mar 2013, Philip Greenwood wrote:

            
See:

http://www.gdal.org/ogr/drv_geojson.html

which implies no. The write driver writes to a file as far as I can see, 
unless you try the VSI route, dsn="/vsistdout/", but that output goes 
straight to the console, not through R. If you can find a way to access 
this output stream, you may be lucky.

Roger

library(rgdal)
cities <- readOGR(system.file("vectors", package = "rgdal")[1], "cities")
writeOGR(cities[1:10,], "/vsistdout/", "cities", driver="GeoJSON")