0

Take the following example from their home page:

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [125.6, 10.1]
  },
  "properties": {
    "name": "Dinagat Islands"
  }
}

The coordinates field expects longitude and latitude in the first and second indexes respectively of this array. This is confusing to me for the following reasons:

  • Longitude and latitude are not the same thing. Representing them in the same list seems illogical from a purely programming perspective however I understand that a list looks like traditional coordinates.
  • Human error is more likely with index-based variables in a list rather than accessing them through clearly labelled keys in an object. In fact, after briefly helping someone who is working with Leaflet, ArcGIS and GeoJSON, this exact thing happened. He accidentally swapped round the indexes for accessing longitude and latitude. Furthermore, one of the libraries expected the longitude and latitude to be the opposite way round, leading to further confusion. Even if the keys were differently arranged in an object, this same issue would not occur (unless you accessed the keys via indexes which is possible in some languages I suppose; but this is a bad practice that is generally avoided).
  • Regarding performance, in most contexts I expect GeoJSON to be processed in JavaScript via mapping libraries and the likes. Quickly looking at JavaScript arrays and objects, I can find both people claiming it is faster and slower, but either way, the performance difference seems to be not great enough to justify sacrificing semantics.

Is there any reason why this decision was made? What is the advantage of storing them in a list?

Specifications can be found here: https://datatracker.ietf.org/doc/html/rfc7946

11
  • 1
    @mplungjan I considered also the 'shorter' argument, but this only amounts to making the file size smaller. If this really was a goal, then simply store the data in csv and forget about a whole convention with long key names (see properties for example). The performance is questionable. Some benchmarks even claim it to be the other way round so this is also not a reason. Commented Nov 28, 2024 at 8:50
  • 1
    datatracker.ietf.org/doc/html/rfc7946#section-3.1.1 Commented Nov 28, 2024 at 9:00
  • 1
    I've used geo libraries that use object notation using property names longitude/latitude, and Longitude/Latitude, and long/lat, and lon/lat, and x/y etc Commented Nov 28, 2024 at 9:25
  • 1
    Actually I tried to find an actual documented reason and could not find it in the documentation or elsewhere other than "because that is what we use", hence it would become an opinion. Commented Nov 28, 2024 at 9:50
  • 1
    No problem, there are two votes to reopen, so let's see Commented Nov 28, 2024 at 10:36

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.