[R-sig-Geo] WriteOGR to GeoJSON loses CRS
Roger Bivand
Roger.Bivand at nhh.no
Tue Aug 12 09:33:58 CEST 2014
On Tue, 12 Aug 2014, Philip Greenwood wrote:
> Thanks very much for you help. My writeOGR belongs to rgdal version 0.8-5.
Which is from February 2013, current is 0.8-16. More importantly, we don't
know which version of GDAL is loaded when rgdal loads - messages are
printed on-screen to tell you - nor do we know how you installed rgdal.
With GDAL 1.11.0, released 2014/04/16, I see:
dsn <- system.file("vectors", package = "rgdal")[1]
cities <- readOGR(dsn=dsn, layer="cities")
summary(cities)
#...
#[+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0]
#...
td <- tempdir()
writeOGR(cities, paste(td, ".geojson", sep=.Platform$file.sep),
"OGRGeoJSON", driver="GeoJSON")
summary(readOGR(paste(td, ".geojson", sep=.Platform$file.sep),
"OGRGeoJSON"))
#...
#[+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs]
#...
with the head of:
file.show(paste(td, ".geojson", sep=.Platform$file.sep))
"crs": { "type": "name", "properties": { "name":
"urn:ogc:def:crs:OGC:1.3:CRS84" } },
where urn:ogc:def:crs:OGC:1.3:CRS84 is WGS 84 longitude-latitude on p. 18
of https://portal.opengeospatial.org/files/?artifact_id=24045.
Not quite the same CRS, but a CRS is recorded. I think that your problem
is related to the version of GDAL loaded into rgdal. The driver page on
www.gdal.org relates to the current release and may include information
for the development version. Your version seems to be old.
>
> gdalinfo --formats returns:
ogrinfo --formats, or equivalently ogrDrivers() in R with rgdal loaded.
Hope this clarifies,
Roger
>
> Supported Formats:
> VRT (rw+v): Virtual Raster
> GTiff (rw+v): GeoTIFF
> NITF (rw+v): National Imagery Transmission Format
> RPFTOC (ro): Raster Product Format TOC format
> HFA (rw+v): Erdas Imagine Images (.img)
> SAR_CEOS (ro): CEOS SAR Image
> CEOS (ro): CEOS Image
> JAXAPALSAR (ro): JAXA PALSAR Product Reader (Level 1.1/1.5)
> GFF (rov): Ground-based SAR Applications Testbed File Format (.gff)
> ELAS (rw+): ELAS
> AIG (ro): Arc/Info Binary Grid
> AAIGrid (rwv): Arc/Info ASCII Grid
> SDTS (ro): SDTS Raster
> OGDI (ro): OGDI Bridge
> DTED (rwv): DTED Elevation Raster
> PNG (rwv): Portable Network Graphics
> JPEG (rwv): JPEG JFIF
> MEM (rw+): In Memory Raster
> JDEM (ro): Japanese DEM (.mem)
> GIF (rwv): Graphics Interchange Format (.gif)
> BIGGIF (rov): Graphics Interchange Format (.gif)
> ESAT (ro): Envisat Image Format
> BSB (ro): Maptech BSB Nautical Charts
> XPM (rw): X11 PixMap Format
> BMP (rw+v): MS Windows Device Independent Bitmap
> DIMAP (ro): SPOT DIMAP
> AirSAR (ro): AirSAR Polarimetric Image
> RS2 (ro): RadarSat 2 XML Product
> PCIDSK (rw+v): PCIDSK Database File
> PCRaster (rw): PCRaster Raster File
> ILWIS (rw+v): ILWIS Raster Map
> SGI (rw+): SGI Image File Format 1.0
> SRTMHGT (rwv): SRTMHGT File Format
> Leveller (rw+): Leveller heightfield
> Terragen (rw+): Terragen heightfield
> GMT (rw): GMT NetCDF Grid Format
> netCDF (rw): Network Common Data Format
> HDF4 (ro): Hierarchical Data Format Release 4
> HDF4Image (rw+): HDF4 Dataset
> ISIS3 (ro): USGS Astrogeology ISIS cube (Version 3)
> ISIS2 (ro): USGS Astrogeology ISIS cube (Version 2)
> PDS (ro): NASA Planetary Data System
> TIL (ro): EarthWatch .TIL
> ERS (rw+): ERMapper .ers Labelled
> JPEG2000 (rwv): JPEG-2000 part 1 (ISO/IEC 15444-1)
> L1B (ro): NOAA Polar Orbiter Level 1b Data Set
> FIT (rw): FIT Image
> GRIB (ro): GRIdded Binary (.grb)
> RMF (rw+): Raster Matrix Format
> WCS (ro): OGC Web Coverage Service
> WMS (ro): OGC Web Map Service
> MSGN (ro): EUMETSAT Archive native (.nat)
> RST (rw+): Idrisi Raster A.1
> INGR (rw+): Intergraph Raster
> GSAG (rw): Golden Software ASCII Grid (.grd)
> GSBG (rw+): Golden Software Binary Grid (.grd)
> GS7BG (ro): Golden Software 7 Binary Grid (.grd)
> COSAR (ro): COSAR Annotated Binary Matrix (TerraSAR-X)
> TSX (ro): TerraSAR-X Product
> COASP (ro): DRDC COASP SAR Processor Raster
> R (rwv): R Object Data Store
> PNM (rw+): Portable Pixmap Format (netpbm)
> DOQ1 (ro): USGS DOQ (Old Style)
> DOQ2 (ro): USGS DOQ (New Style)
> ENVI (rw+v): ENVI .hdr Labelled
> EHdr (rw+v): ESRI .hdr Labelled
> GenBin (ro): Generic Binary (.hdr Labelled)
> PAux (rw+): PCI .aux Labelled
> MFF (rw+): Vexcel MFF Raster
> MFF2 (rw+): Vexcel MFF2 (HKV) Raster
> FujiBAS (ro): Fuji BAS Scanner Image
> GSC (ro): GSC Geogrid
> FAST (ro): EOSAT FAST Format
> BT (rw+): VTP .bt (Binary Terrain) 1.3 Format
> LAN (ro): Erdas .LAN/.GIS
> CPG (ro): Convair PolGASP
> IDA (rw+): Image Data and Analysis
> NDF (ro): NLAPS Data Format
> EIR (ro): Erdas Imagine Raw
> DIPEx (ro): DIPEx
> LCP (rov): FARSITE v.4 Landscape File (.lcp)
> RIK (ro): Swedish Grid RIK (.rik)
> USGSDEM (rw): USGS Optional ASCII DEM (and CDED)
> GXF (ro): GeoSoft Grid Exchange Format
> DODS (ro): DAP 3.x servers
> HTTP (ro): HTTP Fetching Wrapper
> BAG (ro): Bathymetry Attributed Grid
> HDF5 (ro): Hierarchical Data Format Release 5
> HDF5Image (ro): HDF5 Dataset
> NWT_GRD (ro): Northwood Numeric Grid Format .grd/.tab
> NWT_GRC (ro): Northwood Classified Grid Format .grc/.tab
> ADRG (rw+v): ARC Digitized Raster Graphics
> SRP (rov): Standard Raster Product (ASRP/USRP)
> BLX (rw): Magellan topo (.blx)
> Rasterlite (rw): Rasterlite
> EPSILON (rwv): Epsilon wavelets
> WKTRaster (ro): PostGIS WKT Raster driver
> SAGA (rw+v): SAGA GIS Binary Grid (.sdat)
>
>
>
> On 12/08/2014, at 4:32 PM, Frede Aakmann T?gersen <frtog at vestas.com<mailto:frtog at vestas.com>>
> wrote:
>
> Sorry. I was too hasty. I suppose that your problem is with the GDAL drivers. I see that http://www.gdal.org/drv_geojson.html points to http://www.gdal.org/drv_geojson.html.
>
> Which package belong writeOGR to. What is the version of the package? What is the version of your GDAL installation. What does e.g. 'gdalinfo --formats' show?
>
> Yours sincerely / Med venlig hilsen
>
>
> Frede Aakmann T?gersen
> Specialist, M.Sc., Ph.D.
> Plant Performance & Modeling
>
> Technology & Service Solutions
> T +45 9730 5135
> M +45 2547 6050
> frtog at vestas.com<mailto:frtog at vestas.com>
> http://www.vestas.com
>
> Company reg. name: Vestas Wind Systems A/S
> This e-mail is subject to our e-mail disclaimer statement.
> Please refer to www.vestas.com/legal/notice
> If you have received this e-mail in error please contact the sender.
>
>
> -----Original Message-----
> From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-
> project.org] On Behalf Of Frede Aakmann T?gersen
> Sent: 12. august 2014 08:19
> To: Philip Greenwood; r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] WriteOGR to GeoJSON loses CRS
>
> Hi
>
> Google points me to http://geojson.org/geojson-spec.html. See Section 3
> about CRSs.
>
> Yours sincerely / Med venlig hilsen
>
>
> Frede Aakmann T?gersen
> Specialist, M.Sc., Ph.D.
> Plant Performance & Modeling
>
> Technology & Service Solutions
> T +45 9730 5135
> M +45 2547 6050
> frtog at vestas.com
> http://www.vestas.com
>
> Company reg. name: Vestas Wind Systems A/S
> This e-mail is subject to our e-mail disclaimer statement.
> Please refer to www.vestas.com/legal/notice
> If you have received this e-mail in error please contact the sender.
>
>
> -----Original Message-----
> From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-
> project.org] On Behalf Of Philip Greenwood
> Sent: 12. august 2014 08:13
> To: r-sig-geo at r-project.org
> Subject: [R-sig-Geo] WriteOGR to GeoJSON loses CRS
>
> Hi I am using WriteOGR to write a SpatialPolygonsDataFrame to a
> temporary
> GeoJSON file. However the CRS seems to be lost in the resulting file.
> Does the GeoJSON driver support CRSs?
>
> Thanks
> Phil
>
> ---
> Philip Greenwood
> Product Manager
> Australian Urban Research Infrastructure Network (AURIN)
> Level 2 West, Alice Hoy Building, University of Melbourne
> T: +61-(0)3-9035-8549
> E:
>
> philip.greenwood at unimelb.edu.au<mailto:philip.greenwood at unimelb.edu
> .au>
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> ---
> Philip Greenwood
> Product Manager
> Australian Urban Research Infrastructure Network (AURIN)
> Level 2 West, Alice Hoy Building, University of Melbourne
> T: +61-(0)3-9035-8549
> E: philip.greenwood at unimelb.edu.au<mailto:philip.greenwood at unimelb.edu.au>
>
>
>
> [[alternative HTML version deleted]]
>
>
--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list