Search code examples
pythongisgeospatialgeopandaswms

How do I get the proper GetMap size of an image extracted from WMS using OWSLib


So I'm trying to extract a png of an external WMS using OWSLib but I'm not sure what the size=['Width', 'Height'] should be. Where do I get that data/How do I calculate it?

    layers=['geomorphology:MH_GM50K_0506'],
    srs='EPSG:4326',
    bbox=(72.653, 15.607, 80.9, 22.029),
    format='image/png',
    size=[Width, Height],
    transparent=True
)
out = open('geomorph_MH.png', 'wb')
out.write(image.read())
out.close````

I'm not sure how to go about this, I'm quite new to using OWSLib and python

Solution

  • You get to decide how big an image you want, the only constraint is that the aspect ratio should match the bounding box otherwise your map will be stretched. So, the usual practice is to fix one of the dimensions and then multiply by the aspect ratio of the bounding box to get the other.