3

My idea is before upload a GeoJSON file, check if geometries are in EPSG:4326.

I've tried using PostGIS with Find_SRID but return 0 because when I insert geometry I don't know which SRID has the geometry.

So I have thought to use proj4js, but How can I know if coordinates are in 4326??

For example this feature:

{ "type": "Feature", 
"properties": { "ELEMENTO": null }, 
"geometry": { "type": "MultiPolygon", 
"coordinates": [ [ [ [ -414236.540692540816963, 4926522.465698616579175 ], [ -414236.373088985448703, 4926517.988521464169025 ], [ -414232.96294131380273, 4926518.148180302232504 ], [ -414232.470842457551043, 4926506.033791448920965 ], [ -414235.880985956988297, 4926505.874133027158678 ], [ -414235.845654207805637, 4926501.527601527050138 ], [ -414241.617404744320083, 4926501.348593777045608 ], [ -414241.584211973997299, 4926497.265490275807679 ], [ -414254.178381783829536, 4926497.030577188357711 ], [ -414254.210508854594082, 4926500.981967449188232 ], [ -414254.735310742806178, 4926500.97766708675772 ], [ -414255.524655419110786, 4926501.234642565250397 ], [ -414256.183870582142845, 4926501.624406144022942 ], [ -414256.712956251634751, 4926502.146957862190902 ], [ -414257.373242470435798, 4926502.668434447608888 ], [ -414257.772198708786163, 4926503.323774351738393 ], [ -414258.171154998184647, 4926503.979114288464189 ], [ -414258.439981782750692, 4926504.767242475412786 ], [ -414264.081604171195067, 4926504.721009643748403 ], [ -414264.4500383278355, 4926517.758462836034596 ], [ -414258.67827876994852, 4926517.937484437599778 ], [ -414258.552432899130508, 4926518.597125899977982 ], [ -414258.295386300596874, 4926519.257842551916838 ], [ -414258.038339668069966, 4926519.918559241108596 ], [ -414257.649021311604884, 4926520.44863781798631 ], [ -414257.128502179228235, 4926520.979791535995901 ], [ -414256.606912050629035, 4926521.379231951199472 ], [ -414255.953050200769212, 4926521.648034159094095 ], [ -414255.29918831132818, 4926521.916836336255074 ], [ -414255.036786810611375, 4926521.918986548669636 ], [ -414255.067843496857677, 4926525.738673321902752 ], [ -414242.084317687083967, 4926526.503666937351227 ], [ -414242.051124523044564, 4926522.420553126372397 ], [ -414236.540692540816963, 4926522.465698616579175 ] ], [ [ -414248.861272739071865, 4926504.714010251685977 ], [ -414244.532726213394199, 4926504.881197917275131 ], [ -414243.881006645096932, 4926505.41342505812645 ], [ -414240.756820489361417, 4926508.468625050038099 ], [ -414241.075970351346768, 4926515.447273960337043 ], [ -414244.647299421543721, 4926518.974508428014815 ], [ -414251.732137904153205, 4926518.916457841172814 ], [ -414252.251586343278177, 4926518.253591251559556 ], [ -414254.983240895846393, 4926515.333323136903346 ], [ -414255.057682926650159, 4926508.351449576206505 ], [ -414251.221811289375182, 4926504.562946592457592 ], [ -414248.861272739071865, 4926504.714010251685977 ] ] ] ] } }

So, in each file that I try to upload I would like to know if is in EPSG:4326 or not.

9
  • You can't. In your example, the coordinates clearly aren't in any geographic reference (LonLat), but in a projected CRS. But that's all that can be said, really.
    – geozelot
    Commented Jan 9, 2020 at 13:21
  • If there are more than 3 digits before the comma, it's not 4326. That should be easy to check for. If you want to check, which CRS it actually is... no chance.
    – Erik
    Commented Jan 9, 2020 at 13:22
  • but if I'm using 3857 on Null Island you can't tell what it is
    – Ian Turton
    Commented Jan 9, 2020 at 13:24
  • I think in that... if there are more than 3 digits is not 4326 but is not exactly perfect, because maybe could be a projection with 3 digst that are in different projection as 4326
    – Javier
    Commented Jan 9, 2020 at 13:26
  • 1
    Please do not places answers inside questions -- It messes up the Question/Answer model of StackExchange.
    – Vince
    Commented Jan 9, 2020 at 13:42

2 Answers 2

7

Sadly, most GeoJSON files conform to the specification and do not specify their projection, but fail to conform to the specification that they are stored in WGS84 long/lat.

There is no general way to tell what projection such a file is in - go back to the supplier and ask them to fix their output.

2
  • You surely already know, but this is pertinent for everyone. Incorrect GeoJSON output isn't necessarily user error as, for example, both QGIS and ArcGIS conform to the 2008 spec when exporting data.
    – Gabriel
    Commented Jan 9, 2020 at 13:40
  • As does GeoServer but they should include the CRS if they do that
    – Ian Turton
    Commented Jan 9, 2020 at 14:02
1

You can use the tool at https://app.dogeo.fr/Projection/#/coords-to-points to identify a CRS, which sadly is in french.

Input your point X and Y on the right hand pane, deselect "filter by BBOX" and you get the point in many different systems, all plot on OpenStreetMap background.

The first vertex of your feature when interpreted as Web Mercator (EPSG:3857) lies in the city of Madrid, Spain.

So if you have any idea of the spatial extent your data will have you could interpret them as 3857, project them to 4326 and check if they fall within your defined area. If yes they probably were in 3857.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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