Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can st_write warn when writing non-EPSG:4326 GeoJSON files? #344

Closed
atheriel opened this issue May 16, 2017 · 5 comments
Closed

Can st_write warn when writing non-EPSG:4326 GeoJSON files? #344

atheriel opened this issue May 16, 2017 · 5 comments

Comments

@atheriel
Copy link

Although GeoJSON does support a crs field, it is not widely supported by client libraries. Popular Javascript visualization libraries (including Leaflet and D3) expect all GeoJSON files to be EPSG:4326, and will break in mysterious ways if this is not the case. The draft GeoJSON standard recommends against it, too.

At the moment sf will happily let you export non-EPSG:4326 GeoJSON files. Obviously this may be desirable in some cases, but I suspect that many users would do so unintentionally.

Is it possible or desirable to have st_write issue a warning when writing non-standard GeoJSON files? I would be happy to write a patch if so.

@edzer
Copy link
Member

edzer commented May 17, 2017

I am inclined to leave such decisions up to GDAL - as you say, the issue with draft standards is that they are not yet "the" standard, we have to live with that now, and understand the consequences.

@edzer edzer added the question label May 17, 2017
@atheriel
Copy link
Author

This makes sense to me. Presumably GDAL warnings could be propagated up through sf, and the project shouldn't stray too far from the spec. But from my browsing of the GDAL bug tracker it does not look like they will consider this a bug, either.

Still, I suspect that casual consumers of sf (like me) will not "understand the consequences" of the current GeoJSON standard (and its shortcomings), and are very likely to be surprised by this behaviour. That is why I think it might belong at the R level, and not in GDAL.

@edzer
Copy link
Member

edzer commented May 17, 2017

I'd be happy to go there when the GeoJSON standard is no longer a draft, and prescribes 4326.

@yeelauren
Copy link

When using st_write(data, '.out/data.geojson', driver = 'geojson') the geojson contains a CRS.
This goes against the geojson spec, is there a way to use st_write while not including the CRS in the geojson?

This is causing issues for map tiles.

@edzer
Copy link
Member

edzer commented Sep 11, 2021

sf is not going to interfere with the GDAL GeoJSON driver by itself, but reading that, you might want to add the argument layer_options = "RFC7946=YES" to follow the RFC spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants