如何从使用OWSLib提取的WMS图像中获取适当的GetMap尺寸

huangapple go评论73阅读模式
英文:

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

问题

所以我正在尝试使用OWSLib提取外部WMS的png图像,但我不确定size=['Width', 'Height']应该是多少。我从哪里获取这些数据/如何计算它?

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

我不确定如何进行此操作,我对使用OWSLib和Python还很陌生。

<details>
<summary>英文:</summary>

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


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

I&#39;m not sure how to go about this, I&#39;m quite new to using OWSLib and python

</details>


# 答案1
**得分**: 1

你可以决定要多大的图像,唯一的约束是它的宽高比应与边界框相匹配,否则你的地图将被拉伸。因此,通常的做法是固定一个维度,然后乘以边界框的宽高比来获得另一个维度。

<details>
<summary>英文:</summary>

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.

</details>



huangapple
  • 本文由 发表于 2023年6月26日 03:30:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76552108.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定