Commit b1fd7d73 authored by Jon Pye's avatar Jon Pye
Browse files

Simplified the cartopy example.

parent a28f142a
......@@ -40,10 +40,6 @@ wfs = WebFeatureService('http://global.devl.oceantrack.org:8080/geoserver/wfs?',
# Print the name of every layer available on this Geoserver
print list(wfs.contents)
# Define the bounding box for the map using the stations.
a = wfs.contents['otn:stations']
b = a.boundingBoxWGS84
# Get a list of all stations. There is a lot of metadata associated with this JSON data.
# But mostly we're interested in the coordinates.
json_response = wfs.getfeature(typename=['otn:stations'], propertyname=None, outputFormat='application/json').read()
......@@ -55,7 +51,6 @@ print geom['type'], geom['crs'] # check our coordinate reference system
ax = plt.axes(projection=ccrs.PlateCarree())
# Get a list of all features.
locs = geom.get("features", [])
......@@ -66,12 +61,14 @@ print locs[0]['properties'].values()
# But we also have the coordinates, which is what gets us onto the map.
#lons, lats = zip(*[(x["geometry"]["coordinates"][0], x["geometry"]["coordinates"][1]) for x in locs])
# You could also subselect if that fits your project.
lons, lats = zip(*[(x["geometry"]["coordinates"][0], x["geometry"]["coordinates"][1]) for x in locs if x['properties']['collectioncode']=="CBS"])
lons, lats = zip(*[(x["geometry"]["coordinates"][0], x["geometry"]["coordinates"][1]) for x in locs if x['properties']['collectioncode']=="Howslib_example_output.png"])
# Do some simple buffering of the map edges based on your returned data.
plt.axis([min(lons)-1, max(lons)+1, min(lats)-1, max(lats)+1])
# Plot the lons and lats, transforming them to the axis projection
# We get around a lot of projection-related unpleasantness by dealing exclusively in point data here.
ax.scatter(lons, lats, transform=ccrs.PlateCarree())
ax.scatter(lons, lats, transform=ccrs.PlateCarree(), edgecolors="k", marker='.')
ax.stock_img() # fairly nice looking bathymetry provided by Cartopy
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment