Skip to content

Instantly share code, notes, and snippets.

@psd
Created April 12, 2018 18:09
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 psd/9397d72db9cf0035d06b5fcb214d81b0 to your computer and use it in GitHub Desktop.
Save psd/9397d72db9cf0035d06b5fcb214d81b0 to your computer and use it in GitHub Desktop.
Get Land Registry Inspire polygons as an image from their WMS service
#!/usr/bin/env python3
from owslib.wms import WebMapService
wms = WebMapService('http://inspire.landregistry.gov.uk/inspire/ows?Service=WMS&Request=Getcapabilities', version='1.1.1')
print(wms.identification.type)
layers = list(wms.contents)
layer=layers[0]
styles = wms[layer].styles
print('styles', styles)
style = list(styles.keys())[0]
print('layers', layers)
print('style', style)
bbox=wms[layer].boundingBoxWGS84
bbox=(-0.525670,51.742390,-0.506916,51.750388)
print('bbox', bbox)
img = wms.getmap(
layers=[layer],
styles=[style],
srs='EPSG:4326',
bbox=bbox,
size=(1024, 1024),
format='image/jpeg',
transparent=True
)
out = open('image.jpg', 'wb')
out.write(img.read())
out.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment