Skip to content
Prev 21490 / 29559 Next

WriteOGR to GeoJSON loses CRS

Hi

I can get your example (SpatialPointsDataFrame) to work. On my windows box I have:
Loading required package: sp
rgdal: version: 0.8-16, (SVN revision 498)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.11.0, released 2014/04/16
Path to GDAL shared files: c:/Programmer/R/R-3.1.0/library/rgdal/gdal
GDAL does not use iconv for recoding strings.
Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
Path to PROJ.4 shared files: c:/Programmer/R/R-3.1.0/library/rgdal/proj

However I cannot get this (using SpatialPolygonsDataFrame) to work:
Checking rgeos availability: TRUE
IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
Object of class SpatialPolygonsDataFrame
Coordinates:
        min       max
x -84.32385 -75.45698
y  33.88199  36.58965
Is projected: FALSE 
proj4string : [+proj=longlat +ellps=clrk66]
Data attributes:
      AREA          PERIMETER         CNTY_         CNTY_ID            NAME   
 Min.   :0.0420   Min.   :0.999   Min.   :1825   Min.   :1825   Alamance : 1
No crs information at top of file.

Tried this giving no crs information in xx.geojson:

ogr2ogr -f GeoJSON c:\Users\frtog\xx.geojson c:\\Programmer\\R\\R-3.1.0\\library\\maptools\\shapes\\sids.shp

But this gave crs information:

ogr2ogr -f GeoJSON  -s_srs EPSG:4008 -t_srs EPSG:4008 c:\Users\frtog\xx.geojson c:\\Programmer\\R\\R-3.1.0\\library\\maptools\\shapes\\sids.shp

Had to include both -s_srs and -t_srs to get it to work. EPSG:4008 specifies "+proj=longlat +ellps=clrk66" as the shape file was read with. 

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.