Commit 9933468b authored by Jon Pye's avatar Jon Pye
Browse files

Removed hanging OpenStreetMap references and used coastlines() with max resolution

parent 6c2f6c1e
......@@ -8,7 +8,7 @@ import numpy as np
import cartopy.crs as ccrs
from cartopy.io.img_tiles import MapQuestOpenAerial, MapQuestOSM, OSM
import matplotlib.pyplot as plt
from shapely.geometry import Polygon, mapping, asShape, shape, asPoint, point
from shapely.geometry import Point
def flip_geojson_coordinates(geo):
......@@ -28,10 +28,10 @@ def flip_geojson_coordinates(geo):
wfs = WebFeatureService('http://global.devl.oceantrack.org:8080/geoserver/wfs?', version="2.0.0")
print list(wfs.contents)
a = wfs.contents['otn:animals']
a = wfs.contents['otn:stations']
b = a.boundingBoxWGS84
json_response = wfs.getfeature(typename=['otn:animals'], propertyname=None, outputFormat='application/json').read()
json_response = wfs.getfeature(typename=['otn:stations'], propertyname=None, outputFormat='application/json').read()
geom = geojson.loads(json_response)
flip_geojson_coordinates(geom)
......@@ -43,28 +43,25 @@ geodetic = ccrs.Geodetic(globe=ccrs.Globe(datum='WGS84'))
# Open Source Imagery from MapQuest (max zoom = 16?)
tiler = MapQuestOpenAerial()
# Open Street Map (max zoom = 18?)
tiler = OSM()
ax = plt.axes(projection=tiler.crs)
ax = plt.axes(projection=ccrs.PlateCarree())
dx=b[2]-b[0]
dy=b[3]-b[1]
extent = (b[0]-0.1*dx,b[2]+0.1*dx,b[1]-0.1*dy,b[3]+0.1*dy)
ax.set_extent(extent, geodetic)
ax.add_image(tiler, 7)
#ax.add_geometries([polygon],ccrs.PlateCarree(),
# facecolor=BLUE, edgecolor=GRAY,alpha=0.5)
for p in geom.get("features", []):
# How to feed this to the ax.?
#multi_poly = asShape(p.get("geometry"))
thePoint = asPoint(p.get("geometry"))
ax.add_geometries(p.get("geometry"),ccrs.PlateCarree(),
edgecolor='black',facecolor='none', color='black')
# Get a list of all features.
locs = geom.get("features", [])
lons, lats = zip(*[(x["geometry"]["coordinates"][0], x["geometry"]["coordinates"][1]) for x in locs])
# Can get other data here, too.
ax.scatter(lons, lats, transform=ccrs.PlateCarree())
#title(name)
print 'done with geometry'
gl=ax.gridlines(draw_labels=True)
gl.xlabels_top = False
gl.ylabels_right = False
#ax.add_feature(coast_10m,edgecolor='black')
#ax.coastlines()
ax.coastlines(resolution="10m")
plt.show()
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