[Geojson] Valid values for numbers in points etc?

Michael Geary mg at mg.to
Thu Mar 7 12:59:41 PST 2013

> On Wed, Mar 6, 2013 at 6:03 PM, Michael Geary <mg at mg.to> wrote:
> > The meaning of the coordinate values depends on the coordinate reference
> > system (CRS) the GeoJSON file uses.
> >
> > The default CRS is WGS84 (EPSG:4326), where the values do represent
> > longitude, latitude, and optional altitude.
> >
> > If you specify a different CRS in the GeoJSON file, then the coordinate
> > values are easting, northing, and again optional altitude. The meaning of
> > the easting and northing depends on the CRS. I believe altitude is in
> meters
> > in all cases; someone correct me if I'm wrong.
> >
> > As an example, my PolyGonzo library accepts GeoJSON in either the default
> > WGS84, or alternatively in Spherical Mercator (EPSG:3857) coordinates,
> also
> > known as Google Mercator. These are coordinates in "meters" on the
> projected
> > Spherical Mercator plane. If you use this in the GeoJSON, it allows
> slightly
> > faster display of the polygons because it only takes a single
> multiplication
> > to convert each coordinate to a pixel location instead of a sequence of
> > trigonometric operations.
> >
> On Thu, Mar 7, 2013 at 12:14 PM, Francis Galiegue <fgaliegue at gmail.com>
>  wrote:
>>  Hmm, so the schemas I have written should be really split in two. I
> guess there is no defined way to tell from the get go if one GeoJSON
> representation is written using one coordinate reference system or
> another? How do APIs know whether one or the other coordinate system
> is used?

Actually I described it poorly. A position is always an array of numbers in
[ x, y, z ] order, where x and y are required, z is optional, and there may
be additional optional numeric elements after that. Put more simply, it's
an array of numbers with a minimum of two elements. Similarly, a bbox is an
array of four or more numbers.

What those numbers *represent* depends on the coordinate reference system.
In WGS84, x and y are longitude and latitude. In Spherical Mercator, they
are meters on the projected plane. In other CRSes they will mean other
things. But the *format* of the numbers doesn't change; numbers are numbers.

I'm looking at your schema definition for a position:

        "position": {
            "description": "A single position",
            "type": "array",
            "minItems": 2,
            "items": [ { "type": "number" }, { "type": "number" } ],
            "additionalItems": false

It looks like you need to change the additionalItems to allow for the
optional numeric elements. Other than that, this should be fine regardless
of the CRS, because the position array elements are numbers in all cases.

Looking at bbox:


    "$schema": "http://json-schema.org/draft-04/schema#",
    "id": "http://json-schema.org/geojson/bbox.json#",
    "description": "A bounding box as defined by GeoJSON",
    "FIXME": "unenforceable constraint: even number of elements in array",
    "type": "array",
    "items": { "type": "number" }

Maybe add a minItems: 4 here?

Regarding how applications and APIs know which CRS is used in a GeoJSON
file, they get it from the crs property in the file and assume WGS84 if
it's not specified. But as long as you just describe positions and bboxes
as arrays of numbers, the CRS won't affect you.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geojson.org/pipermail/geojson-geojson.org/attachments/20130307/c07fe67c/attachment.htm>

More information about the GeoJSON mailing list