Geopandas: to_json should either include CRS to convert to wgs84

Created on 4 Mar 2017  路  5Comments  路  Source: geopandas/geopandas

Geopandas dataframes can be in any CRS, but when exported to geojson the CRS is not exported. So we should either export the CRS or convert to the default (wgs84 according the geojson spec).

What do you think?

Most helpful comment

@jorisvandenbossche I'd like to remind you that https://tools.ietf.org/html/rfc7946 is the official GeoJSON spec.

@wassname when WGS84 is no longer the world standard used by most commercial GPS devices, RFC 7946 will be obsoleted and a new RFC will be published.

All 5 comments

That sounds like a good idea. Specification is here: http://geojson.org/geojson-spec.html#coordinate-reference-system-objects. The main question will be how to convert the crs in an appropriate object/string to put in the json.

Do you know if this is supported for reading geojson?

I agree it's hard to convert from a pyproj projections to either a link or named CRS like in the geojson spec. The other approach is easy and standards complaint.

That was the 2008 spec, but If you look at the 2016 geojson spec

Specification of coordinate reference systems has been removed,
i.e., the "crs" member of [GJ2008] is no longer used.

They recommend not using a CRS (doesn't seem very future proof when we upgrade from wgs84 as the world standard), which is easy for us to implement. If there is a CRS defined we use to_crs(epsg=4326) when exporting. And when importing from geojson we use epsg=4326 as the default. I can make a PR for this if you like?

@jorisvandenbossche I'd like to remind you that https://tools.ietf.org/html/rfc7946 is the official GeoJSON spec.

@wassname when WGS84 is no longer the world standard used by most commercial GPS devices, RFC 7946 will be obsoleted and a new RFC will be published.

Hi All, i would recommend to stick with the official geoJSON spec. This improves integration with other packages such as Mapbox / Earth Engine. Raise a warning when epsq != 4326 https://macwright.org/2015/03/23/geojson-second-bite#projections

Yes, I don't think there is disagreement on sticking to the official GeoJSON spec (my comment above was based on looking at the old spec ..).
So PRs are welcome!

(note that in the end, it is of course still the final responsibility of the user, because if there is no CRS defined for the data, geopandas can also not convert it to WGS84 and you can still write 'invalid' geojson)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fmaussion picture fmaussion  路  6Comments

dzanaga picture dzanaga  路  3Comments

jorisvandenbossche picture jorisvandenbossche  路  3Comments

raiphilibert picture raiphilibert  路  6Comments

kuanb picture kuanb  路  4Comments