Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created August 20, 2012 20:53
Show Gist options
  • Save tmcw/3407807 to your computer and use it in GitHub Desktop.
Save tmcw/3407807 to your computer and use it in GitHub Desktop.
Turn your Foursquare Data Archive into a GeoJSON file
import glob, json
# this script loves this script
# https://gist.github.com/3350235
points = []
vids = set()
places = glob.glob("checkins/*.json")
for p in places:
pj = json.load(open(p))
try:
if pj['venue']['id'] not in vids:
vids.add(pj['venue']['id'])
coords = [
pj['venue']['location']['lng'],
pj['venue']['location']['lat']]
points.append({
'geometry': {
'type': 'Point',
'coordinates': coords
},
'properties': {
'name': pj['venue']['name'],
'id': pj['venue']['id']
}
})
except Exception, e:
pass
json.dump({ 'type': 'FeatureCollection', 'features': points }, open('checkins.geojson', 'w'))
@shashashasha
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment