[Geojson] coordinate order

Norman Vine nhv at cape.com
Mon Mar 10 12:55:58 PDT 2008


Tim Schaub writes:
> Sean Gillies wrote:
> > Tim Schaub wrote:
> >>
> >>
> >> Regarding the order of elements in the coordinates array for GeoJSON 
> >> geometries, we say that the first two elements are in x, y order (lon, 
> >> lat for dd).  This is what we have said from the start.
> >>
> >> The change to the spec is to accommodate CRS that define a different 
> >> coordinate order.  Instead of requiring all clients to know about all 
> >> CRS coordinate order conventions, we require that GeoJSON geometries 
> >> referencing a CRS that defines non-xy coordinate order include a 
> >> "coordinate_order" member in the CRS object.
> >>
> >> This means a point geometry that references EPSG:4326 
> would look like this:
> >>
> >> {
> >>     "type": "Point",
> >>     "coordinates": [-180.0, 90.0],
> >>     "crs": {
> >>         "type": "EPSG",
> >>         "properties": {"code": 4326},
> >>         "coordinate_order": [1, 0]
> >>     }
> >> }
> >>
> > 

I thought we meant that if the coordinate order was different then X,Y 
then even if crs was present that one must supply "coordinate_order"

So proper access to the coordinate array coords[] for 'simple clients' 
could still be done eg.

for point in coords:
  x = point[coordinate_order[1]]
  y = point[coordinate_order[0]]


Note that for clients that know the CRS this might simplify to

for point in coords:
  lat = point[0]
  lon = point[1]

As this is implied by the CRS

Cheers

Norman




More information about the GeoJSON mailing list