Skip to content

Instantly share code, notes, and snippets.

@nv1t
Created September 15, 2014 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nv1t/54d6eb6cfe827277b2b9 to your computer and use it in GitHub Desktop.
Save nv1t/54d6eb6cfe827277b2b9 to your computer and use it in GitHub Desktop.
plot gps coords on german map
import sys
import cartopy.crs as ccrs
import cartopy.io.shapereader as shpreader
import matplotlib.pyplot as plt
import json
# Downloaded from http://biogeo.ucdavis.edu/data/gadm2/shp/DEU_adm.zip
fname = 'DEU_adm1.shp'
adm1_shapes = list(shpreader.Reader(fname).geometries())
ax = plt.axes(projection=ccrs.PlateCarree())
plt.title(sys.argv[1].split('/')[-1])
ax.coastlines(resolution='10m')
ax.add_geometries(adm1_shapes, ccrs.PlateCarree(),
edgecolor='black', facecolor='gray', alpha=0.5)
ax.set_extent([4, 16, 47, 56], ccrs.PlateCarree())
x = []
y = []
print 'Loading File...',sys.argv[1]
with open(sys.argv[1]) as f:
for i in f:
temp = json.loads(i)
x.append(float(temp['x'])/10**6)
y.append(float(temp['y'])/10**6)
plt.plot(x, y,
color='blue', linewidth=0, marker='.',
transform=ccrs.Geodetic(),
)
plt.savefig(sys.argv[2],dpi=300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment