[GIS] Representing Time in GeoJSON

apicoordinatesgeojsonpointtime

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?

Best Answer

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.