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?
Pete
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