Skip to content

Instantly share code, notes, and snippets.

Last active December 30, 2015 07:39
Show Gist options
  • Save sgillies/7797688 to your computer and use it in GitHub Desktop.
Save sgillies/7797688 to your computer and use it in GitHub Desktop.
Example of RFC 6902 GeoJSON diff
Display the source blob
Display the rendered blob
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"Name":"Albina Press","Address":"4637 N Albina Ave Portland, OR 97217","Notes":"usually busy, outlets on side wall only"},"geometry":{"type":"Point","coordinates":[-122.67516911029816,45.55673233031101]}},{"type":"Feature","properties":{"Name":"Arbor Lodge","Address":"1507 N Rosa Parks Way Portland, OR 97217","Notes":""},"geometry":{"type":"Point","coordinates":[-122.68242716789246,45.56997505986905]}},{"type":"Feature","properties":{"Name":"Three Friends Coffeehouse","Address":"201 SE 12th Ave, Portland, OR 97214"},"geometry":{"type":"Point","coordinates":[-122.655,45.522]}}]}
import json
import jsonpatch
import os.path
import requests
import subprocess
# original
if not os.path.exists('hackspots-44de76ef53.json'):
r = requests.get('')
data = r.content
with open('hackspots-44de76ef53.json', 'wb') as f:
# next commit
if not os.path.exists('hackspots-e9514f5c31.json'):
r = requests.get('')
data = r.content
with open('hackspots-e9514f5c31.json', 'wb') as f:
diff_text = subprocess.check_output([
diff = json.loads(diff_text)
print(json.dumps(diff, indent=2))
# Moving coordinates of hackspots-e9514f5c31
diff = '[{"path": "/features/2/geometry/coordinates/0", "value": -122.655, "op": "replace"}, {"path": "/features/2/geometry/coordinates/1", "value": 45.522, "op": "replace"}]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment