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

Add crs to GeoJSON when not CRS84 #58173

Closed
jkr-wrk opened this issue Jul 18, 2024 · 12 comments
Closed

Add crs to GeoJSON when not CRS84 #58173

jkr-wrk opened this issue Jul 18, 2024 · 12 comments
Labels
Feature Request Feedback Waiting on the submitter for answers stale Uh oh! Seems this work is abandoned, and the PR is about to close.

Comments

@jkr-wrk
Copy link

jkr-wrk commented Jul 18, 2024

Feature description

Wouldn't it be good practice to add the crs attribute to a GeoJSON when it is not the default crs?

For example:

{
"type": "FeatureCollection",
"name": "myname",
"crs" : {
"type" : "name",
"properties" : {
"name" : "EPSG:28992"
}
},
"xy_coordinate_resolution": 1e-10,
"features": []
}

Additional context

This is how other software implements using custom CRS with GeoJson.

@troopa81
Copy link
Contributor

It has been done on WMS GetFeatureInfo and WFS #56600 and is already available in QGIS 3.38

Do you confirm that it fulfill your needs?

@troopa81 troopa81 added the Feedback Waiting on the submitter for answers label Jul 18, 2024
@jkr-wrk
Copy link
Author

jkr-wrk commented Jul 19, 2024

Using 3.38.0

Export with settings:
GeoJSON
CRS EPSG:28992

Coordinate Precision:10
RFC7946:NO
Write_BBOX: NO

Gives this:
{
"type": "FeatureCollection",
"name": "test_json_RFC7946_NO10_qgis3",
"xy_coordinate_resolution": 1e-10,
"features": [
{ "type": "Feature", "properties": { "fid": 8, "statcode": "PV27", "statnaam": "Noord-Holland", "jrstatcode": "2022PV27", "rubriek": "provincie" }, "geometry": { "type": "MultiPolygon", "coordinates": [] } }
]
}

There is no CRS attribute or something similar.

@rouault
Copy link
Contributor

rouault commented Jul 20, 2024

@jkr-wrk I do not replicate that when exporting a layer already in EPSG:28992 (or overriding its CRS in the dialog) as GeoJSON using the Export / Save Features As dialog box. The generated GeoJSON contains "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::28992" } }
Can you possibly share a project + layer ?

@jkr-wrk
Copy link
Author

jkr-wrk commented Jul 22, 2024

test_json_RFC7946_NO.json

This is the file I opened and saved as GeoJSON again.

I also tried with this service (using 3.39.0 just now):
https://service.pdok.nl/kadaster/bestuurlijkegebieden/wfs/v1_0?request=GetCapabilities&service=WFS

And coordinates are in 28992 but no crs attribute is available.

@rouault
Copy link
Contributor

rouault commented Jul 22, 2024

I somehow reproduce the issue, but in a different way. The CRS does get exported, but the geometry not.
I see an error "Warning 1: Infinite or NaN coordinate encountered"

{
"type": "FeatureCollection",
"name": "foo",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::28992" } },
"features": [
{ "type": "Feature", "properties": { "fid": 8, "statcode": "PV27", "statnaam": "Noord-Holland", "jrstatcode": "2022PV27", "rubriek": "provincie" }, "geometry": null }
]
}

@jkr-wrk
Copy link
Author

jkr-wrk commented Jul 22, 2024

Strange, I can't reproduce that using 3.39.0.

Would like to test 3.34.9 or 3.38.1 but OSGeo4W fails to install these versions. Looks like Windows Defender is preventing today.
Had success installing versions on friday, but not today.

Copy link

github-actions bot commented Aug 6, 2024

The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale".
If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue.
In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue.
If there is no further activity on this issue, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Aug 6, 2024
@troopa81 troopa81 removed Feedback Waiting on the submitter for answers stale Uh oh! Seems this work is abandoned, and the PR is about to close. labels Aug 13, 2024
@jkr-wrk
Copy link
Author

jkr-wrk commented Sep 4, 2024

Tried again today using 3.38.2:

{
"type": "FeatureCollection",
"name": "Test Export rfcno",
"features": [{
"type": "Feature",
"properties": {
"identificatie": "PV21",
"naam": "Fryslân",
"code": "21",
"ligtInLandCode": "6030",
"ligtInLandNaam": "Nederland",
"fuuid": "provinciegebied.d0a8a913-5680-4bb5-b28a-e56bab2f651d"
},
"geometry": {
"type": "MultiPolygon",
"coordinates": [[[[189491.268000000010943, 535832.616999999969266], [189494.21, 535842.547000000020489] , etc. etc. ]]]
}
}
]
}

Steps to reproduce...

Instal PDOK Services Plugin
Add Provincies WFS from the PDOK plugin
Select Fryslân
Dissolve Selected feature
Export feature with right click on the Dissove layer
Export as GeoJSON with RFCxxxx set to No

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Sep 5, 2024

@jkr-wrk, using QGIS 3.38.2 (OSGeo4W) with GDAL/OGR 3.9.2 on Windows 10

  • I've created a new project having CRS EPSG:4326
  • I've created a point layer having CRS EPSG:4326 and added a point randomly placed in the Netherlands
  • I've exported such layer (via right click -> Export -> Save Features As... -> Save Vector Layer as...) changing the CRS parameter to ESPG:28992 and setting COORDINATE_PRECISION = 10, RFC7946=NO, WRITE_BBOX=NO:
{
"type": "FeatureCollection",
"name": "4326-28992",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::28992" } },
"xy_coordinate_resolution": 1e-10,
"features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 167453.3256934369, 497815.226271763 ] } }
]
}
  • I've reprojected such layer to the CRS EPSG:28992 and exported the reprojected layer following the same procedure and using the same parameters (this time leaving the CRS set to EPSG:28992):
{
"type": "FeatureCollection",
"name": "28992",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::28992" } },
"xy_coordinate_resolution": 1e-10,
"features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 167453.3256934369, 497815.226271763 ] } }
]
}

So, it seems to me the crs attribute is correctly present in the exported GeoJSON layers.

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Sep 5, 2024

@jkr-wrk , afterwards I've imported the provided test_json_RFC7946_NO.json, assigned EPSG:28992 as the layer's CRS, and exported such layer following the same procedure and using the same parameters (leaving the CRS set to EPSG:28992):

{
"type": "FeatureCollection",
"name": "test_json_RFC7946_NO_28992",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::28992" } },
"xy_coordinate_resolution": 1e-10,
"features": [
{ "type": "Feature", "properties": { "fid": 8, "statcode": "PV27", "statnaam": "Noord-Holland", "jrstatcode": "2022PV27", "rubriek": "provincie" }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 150817.7896144802, 477979.2072202922 ], [ 150870.1662389686, 477927.4095703705 ], [ 150089.3342324059, 478192.6626739331 ], [ 150077.1968909417, 478439.1956211975 ], [ 150672.9224872852, 478433.978409293 ], [ 150977.1665158421, 478163.0254149203 ], [ 150817.7896144802, 477979.2072202922 ] ] ], [ [ [ 131307.2914809157, 482947.1495827798 ], [ 131146.2443887191, 482908.4246546297 ], [ 131104.3021696125, 483250.8019863805 ], [ 131247.3499429776, 483245.0803827818 ], [ 131429.9798880598, 483096.9133843749 ], [ 131307.2914809157, 482947.1495827798 ] ] ], [ [ [ 134232.8620112413, 484164.4973444095 ] ...

Even this time it seems to me the crs attribute is correctly present in the exported GeoJSON layer.

@agiudiceandrea agiudiceandrea added the Feedback Waiting on the submitter for answers label Sep 5, 2024
Copy link

The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale".
If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue.
In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue.
If there is no further activity on this issue, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Sep 20, 2024
Copy link

While we hate to see this happen, this issue has been automatically closed because it has not had any activity in the last 42 days despite being marked as feedback. If this issue should be reconsidered, please follow the guidelines in the previous comment and reopen this issue.
Or, if you have any further questions, there are also further support channels that can help you.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Feedback Waiting on the submitter for answers stale Uh oh! Seems this work is abandoned, and the PR is about to close.
Projects
None yet
Development

No branches or pull requests

4 participants