7

I'm modelling a bus route as a series of waypoints. Most of these waypoints have just a latitude and a longitude and represent points along a road. However, when the bus gets to a bus stop, the waypoint has an arrival and departure time associated with it. This information could potentially be relevant to plotting this route, for example, if I was to animate the progress of the bus.

Since I am going to be exposing these models through an API, I want to keep to standards by using the GeoJSON format. This will be my first time using GeoJSON. I know that the first three coordinates of a GeoJSON point are [longitude, latitude, elevation]. According to Tom Macwright, GeoJSON supports multi-dimensional coordinates. However, I couldn't find any information on any standards beyond those three.

I plan to represent the times in ticks (JavaScript ticks, i.e. number of milliseconds since midnight of January 1, 1970). I would like to use the following standard:

{ 
    "type": "Point", 
    "coordinates":  [longitude, latitude, null, arrivalTime, departureTime] 
}
  • Will this format collide with any GeoJSON standard?
  • Elevation data is meaningless to me. Do I need the "null" in order to conform to GeoJSON?
2
  • 1
    Have you read the standard geojson.org/geojson-spec.html? A position is represented by an array of numbers. There must be at least two elements, and may be more. The order of elements must follow x, y, z order (easting, northing, altitude for coordinates in a projected coordinate reference system, or longitude, latitude, altitude for coordinates in a geographic coordinate reference system). Any number of additional elements are allowed -- interpretation and meaning of additional elements is beyond the scope of this specification. Use null, extra elements should be after x, y, and ele.
    – user30184
    Sep 7, 2015 at 14:17
  • 1
    Thanks, this should be an answer! I'm not sure what is meant by "beyond the scope of this specification" - does it mean free for all or does it mean there are potentially extensions to the spec that I should consider?
    – 08Dc91wk
    Sep 7, 2015 at 14:23

4 Answers 4

8

The current GeoJSON specification is geojson.org/geojson-spec.html and it defines "positions" as

A position is represented by an array of numbers. There must be at least two elements, and may be more. The order of elements must follow x, y, z order (easting, northing, altitude for coordinates in a projected coordinate reference system, or longitude, latitude, altitude for coordinates in a geographic coordinate reference system). Any number of additional elements are allowed -- interpretation and meaning of additional elements is beyond the scope of this specification.

The new draft version https://datatracker.ietf.org/doc/html/draft-butler-geojson-06 is a bit more explicit:

A position is represented by an array of numbers. There MUST be two or more elements. The first two elements will be longitude and latitude, or easting and northing, precisely in that order and using decimal numbers. Altitude or elevation MAY be included as an optional third element.

Additional position elements MAY be included but MUST follow the three specified above and MAY be ignored by software. Interpretation and meaning of additional elements is beyond the scope of this specification.

It means that GeoJSON defines only that two first elements of position are X and Y and if there is a third element it must mean elevation. There may be further elements which can mean whatever. It is up to you to define what they mean and how they should be handled. A basic GeoJSON reader that does not know what to do with extra elements should just skip them without throwing an error.

However, if your data are points I think you could as well write the times as normal attributes like in this example https://github.com/kgeographer/catalhoyuk/blob/master/geotemporal_fig.json?short_path=b3b33df. Multidimensional coordinates will suit better if you plan to present you bus lines as linestrings because then one bus route would be only one geometric feature which can have just one arrival and departure time.

1
  • 2
    Old post, I know, but GeoJSON now only supports lon/latl/ele, and forbids any other fields. (tools.ietf.org/html/rfc7946#section-3.1.1, Also see section 7 if you think the language isn't strong enough).
    – Martin
    Feb 13, 2019 at 23:41
4

In my opinion the "right" way would be using properties unless you consider your timestamps to be coordinates in time-space.

That means that instead of raw geometries, you would use features, actual proper objects that have geometries and optional attribute (the properties).

Stuffing attributes into the coordinates array just invites problems with all software involved. If you use the properties, all software should correctly interpret them as such. QGIS for example will show them in the attribute table.

See http://geojson.org/geojson-spec.html#feature-objects

For example something like this (no guarantee for correct syntax):

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [123456, 234567]
  },
  "properties": {
    "arrivalTime": 12345678,
    "departureTime": 23456789
  }
}
1
  • This is the competing proposal. I also see it as possibly more "correct", so i may just use this. The reason I'd rather stuff the times into the coordinates is because I may use these "waypoints" as I'm calling them in a LineString, for example, and this would really cut my response models down in size. The timestamps kind of ARE coordinates in time-space. Those times are meaningless without their associated spatial coordinates, and vice versa.
    – 08Dc91wk
    Sep 7, 2015 at 15:04
1

Looking around I have also found GeoJSON-events, draft under-construction at MapBox. It looked to me the most appropriate because it applies the general concept of "event" (that is cool in terms of possibility to apply to different subjects that need a space-time representation). The implementation is pretty straightforward. There are two basic types for timing: interval and instant. As stated in the documentation, syntax for instant:

{
  "geometry": {
    "coordinates": [
      0.0,
      0.0
    ],
    "type": "Point"
  },
  "id": "1",
  "properties": {"foo": "bar"},
  "type": "Feature",
  "when": {
    "start": "2014-04-24",
    "type": "Instant"
  }
}

Syntax for interval:

{
  "geometry": {
    "coordinates": [
      0.0,
      0.0
    ],
    "type": "Point"
  },
  "id": "1",
  "properties": {"foo": "bar"},
  "type": "Feature",
  "when": {
    "start": "2014-04-24",
    "end": "2014-04-26",
    "type": "Interval"
  }
}
1

When the GeoJSON Events effort stalled, I began work on GeoJSON-T (https://github.com/kgeographer/geojson-t). Put it "through its paces" with a Linked Traces pilot app. (http://linkedtraces.org). In that, a "when" element can live not only at the feature level, but for each geometry in a GeometryCollection. Among other things, this allows for representing journeys, changing shapes over time.

GeoJSON-T development suspended, but has evolved into the Linked Places format for linking gazetteers (https://github.com/LinkedPasts/linked-places). So for example,

"features": [
    { "@id": "http://mygaz.org/places/p_12345",
      "type": "Feature",
      "properties":{
        "title": "Abingdon (UK)",
        "ccode": "GB"
      },
      "geometry": {
        "type": "GeometryCollection",
        "geometries": [
            { "type": "Point",
              "coordinates": [-1.2879,51.6708],
              "geo_wkt": "POINT(-1.2879 51.6708)",
              "when": {"timespans":[
                {"start":{"in":"1600"},"end":{"in":"1699"}}]},
              "src": "tgn:7011944"
            },
            { "type": "Point",
              "coordinates": [-1.31,51.64],
              "geo_wkt": "POLYGON ((-1.3077 51.6542, -1.2555 51.6542, -1.2555 51.6908, -1.3077 51.6908, -1.3077 51.6542))",
              "when": {"timespans":[{"start":{"in":"1700"}}]}
            }
        ]
      },
      "when": {
        "timespans": [
          {
            "start": {"in":"0676"},"end": {"in":"1066"}
          }
        ],
        "periods": [
          {
            "name": "Anglo-Saxon Period, 449-1066",
            "@id": "periodo:p06c6g3whtg"
          },
          {
            "name": "Anglo-Saxon (culture or style)",
            "@id": "http://chronontology.dainst.org/period/O5r960WKERYr"
          }
        ],
        "label": "dummy 'when' object illustrating named period, duration, and sequence",
        "duration": "P100Y"
      },

Your Answer

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

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