Skip to content

Instantly share code, notes, and snippets.

@dbuscombe-usgs
Created October 13, 2013 06:29
Show Gist options
  • Save dbuscombe-usgs/6958792 to your computer and use it in GitHub Desktop.
Save dbuscombe-usgs/6958792 to your computer and use it in GitHub Desktop.
little python function to write a .geojson file to display a list of coordinates, x and y
f = open('points.geojson', 'w')
f.write('\n')
f.write('{\n')
f.write(' "type": "FeatureCollection",\n')
f.write(' "features": [\n')
for k in range(len(x)):
f.write('\n')
f.write(' {\n')
f.write(' "type": "Feature",\n')
f.write(' "geometry": {\n')
f.write(' "type": "Point",\n')
f.write(' "coordinates": ['+str(y[k])+', '+str(x[k])+']\n')
f.write(' },\n')
f.write(' "properties": {\n')
f.write(' "'+str(k)+'": "description here"\n')
f.write(' }\n')
if k==len(x)-1:
f.write(' }\n')
else:
f.write(' },\n')
f.write('\n')
f.write('\n')
f.write(' ]\n')
f.write('}\n')
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment