General documentation / cheat sheets for various languages and services

Standards (GeoJSON vs Google, Twitter, etc.)

Coordinates (aka., points, aka., positions) in the GeoJSON spec take the following order:

terminology 0, 1, 2
cartesian x y z
projected easting northing altitude
geographic longitude latitude altitude
spherical range (-180,180) (-90,90) (?,∞)

The z/altitude measure is often omitted, in which case the positions are 2-tuples.

GeoJSON features can have bbox fields, which are always 2N-long, where N = the number of dimensions. For most geolocation, N = 2, so this field is 4-long. The order is:

  0, 1, 2, 3  
[ southwest longitude southwest latitude northeast longitude northeast latitude ]
[ minimum longitude minimum latitude maximum longitude maximum latitude ]

Southwest is the minimum (for both latitudes and longitudes), northeast is maximum.

For example, here’s a simple little snippet of GeoJSON for the whole earth:

{
  "type": "Feature",
  "bbox": [-180.0, -90.0, 180.0, 90.0],
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
        [-180.0, -90.0, 180.0, 90.0]
    ]]
  },
  "properties": {
    "name": "The whole world"
  }
}

Twitter

Twitter has two formal geolocation attributes:

geo and coordinates might both be null, or other types of geometries, but those parts of a tweet might look like this:

{
  "geo": {
    "type": "Point",
    "coordinates": [
      <latitude>,
      <longitude>
    ]
  },
  "coordinates": {
    "type": "Point",
    "coordinates": [
      <longitude>,
      <latitude>
    ]
  }
}

Luckily, Twitter got the order right in the streaming API locations query. We can query from the whole globe with the following URL:

https://stream.twitter.com/1.1/statuses/filter.json?locations=-180,-90,180,90

Twitter sometimes only returns “place” attributes. This is kind of like a GeoJSON feature, but has a predictable set of values:

{
  "place": {
    "id": "1d9a5370a355ab0c",
    "url": "https://api.twitter.com/1.1/geo/id/1d9a5370a355ab0c.json",
    "place_type": "city",
    "name": "Chicago",
    "full_name": "Chicago, IL",
    "country_code": "US",
    "country": "United States",
    "attributes": {},
    "bounding_box": {
      "type": "Polygon",
      "coordinates": [[
        [-88.097, 37.771],
        [-88.097, 41.761],
        [-84.784, 41.761],
        [-84.784, 37.771]
      ]]
    }
  },
  ...
}

The bounding_box sub-object above is a true GeoJSON geometry, with [long, lat] pairs. You can tell pretty quickly with this one because, if a place had latitudes around -84 or -88, it’d be in the Antarctic. Not impossible, but unlikely. Of course, no latitudes are greater than 90 or less than -90, and most tweets come from somewhere between the Arctic (+66 latitude) and Antarctic (-66 latitude) circles.

Google

When you search for a coordinate pair, Google expects latitude, longitude pairs. This support page lists the following working formats: