Created
April 12, 2018 18:09
-
-
Save psd/9397d72db9cf0035d06b5fcb214d81b0 to your computer and use it in GitHub Desktop.
Get Land Registry Inspire polygons as an image from their WMS service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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