Search code examples
python-2.7twittergeojsontwitter-streaming-api

Coordinates in tweets have inconsistent longitude latitude


I've noticed in the live twitter stream that the longitude, latitude pairs for the object are inconsistent. Although the docs say the co-ordinates are displayed in the form [longitude, latitude] they appear in different orders. Is this a bug? If is "coordinates" guaranteed to be the correct representation? (Assumed this the place attribute" co-ordinates" for the area bounding box match those )

Tweet 1:

"geo":{"type":"Point","coordinates":[1.38229787,103.89847755]},
"coordinates":{"type":"Point","coordinates":[103.89847755,1.38229787]},

Tweet 2:

"geo":{"type":"Point","coordinates":[53.34789491,-6.25940967]},
"coordinates":{"type":"Point","coordinates":[-6.25940967,53.34789491]}

Solution

  • The correct attribute to look at here is coordinates since geo has been deprecated.

    If you properly rely on coordinates, then locations will indeed be always represented as a collection of [longitude, latitude] arrays as specified by GeoJSON.

    Read more about these fields on the Tweet Objects Documentation.