Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a shapefile with a Google Mercator projection (900913) that I need converted to GeoJSON. I need to do this on a regular basis amongst other things so I wrote a shell script to do it using ogr2ogr. I am also converting this to a 4326 projection so the coordinates are more usable.

This is how I am using ogr2ogr to do that: ogr2ogr -f "GeoJSON" -s_srs EPSG:900913 -t_srs EPSG:4326 output.geojson my-shapefile.shp -lco WRITE_BBOX=YES -lco COORDINATE_PRECISION=6 --debug on

For some reason all of my coordinate arrays have 3 values, the last one always being 0.0. Like so: [ -122.633291, 48.628477, 0.0 ]

Where is the extra 0.0 coming from?? However, if I export from qgis the coordinates come out as expected.. [ -122.633291, 48.819157 ]

I also notice that the longitude is slightly different between the two. Any ideas on how I could improve my ogr2ogr command? Or perhaps this is a bug?


Here are some more details about the shapefile being converted.

Storage type of this layer:ESRI Shapefile
Geometry type of the features in this layer: Polygon
The number of features in this layer: 431
Editing capabilities of this layer: Add Features, Delete Features, Change Attribute Values, Add Attributes, Create Spatial Index, Fast Access to Features at ID, Change Geometries

In layer spatial reference system units : xMin,yMin -19951913.23,2139102.40 : xMax,yMax 20021888.10,11554793.57

+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs

share|improve this question
Okay, so I have figured out the problem. Just incase anyone else if having a similar issue, it was that the shapefile was created as a "3D Polygon". I fixed that by explicitly specifing that it should be 2D durning the creation process of the shapefile like so: -nlt POLYGON –  Pete May 18 '12 at 17:23
It would be helpful if you took your comment and added as an answer. Then you can accept it. This will make it easier for other people with the same question to search for yours and see a specific answer instead of having to search through comments for it. –  Get Spatial May 19 '12 at 6:29

1 Answer 1

This is possible explanation for the differences you're finding. In my version of QGIS the parameter string for EPSG:900913 is:

+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +over +no_defs

which looks about right to me (after all, it is Google Spherical Mercator). This is different from the string that ogr2ogr appears to be using. Nick.

share|improve this answer
This (the +nadgrids=@null, +a/+b=6378137) version is the correct PROJ.4 string for Google Mercator. Note that any reasonably modern version of ogr2ogr will use this for EPSG:900913. The more appropriate (real) EPSG code to use for Google Mercator is EPSG:3857. –  Frank Warmerdam May 19 '12 at 21:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.