在Geopandas打印时管理预测

问题描述 投票:1回答:1

我使用geopandas绘制地图意大利。

import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize = (20,30))

region_map.plot(ax=ax, color='white', edgecolor='black')
plt.xlim([6,19])
plt.ylim([36,47.7])
plt.tight_layout()
plt.show()

这是的结果,之后适当地限定region_map作为一条“几何” GeoSeries的。

map of italy

但是,我无法修改人物的纵横比,即使在figsize不同plt.subplots。我失去了一些小事,或者是它可能是一个geopandas问题?

谢谢

python pandas figure geopandas map-projections
1个回答
2
投票

源的数据集(region_map)是在地理坐标系统显然是“编码”(单位:拉特和LONS)。它是安全的,你的情况来承担,这是WGS84(EPSG:4326)。如果你希望你的情节看起来更像它在e.g谷歌地图,你将有它的坐标重新投影到许多的一个投影坐标系统(单位:米)。您可以使用全球通用WEB墨卡托投影(EPSG:3857)。

Geopandas使这个尽可能容易。你只需要知道我们如何处理与协调计算机科学预测,并通过他们的EPSG码学习最流行的CRSes的基础知识。

import matplotlib.pyplot as plt

#If your source does not have a crs assigned to it, do it like this:
region_map.crs = {"init": "epsg:4326"}

#Now that Geopandas what is the "encoding" of your coordinates, you can perform any coordinate reprojection
region_map = region_map.to_crs(epsg=3857)

fig, ax = plt.subplots(figsize = (20,30))
region_map.plot(ax=ax, color='white', edgecolor='black')

#Keep in mind that these limits are not longer referring to the source data!
# plt.xlim([6,19])
# plt.ylim([36,47.7])
plt.tight_layout()
plt.show()

我强烈建议有关管理预测阅读official GeoPandas docs

© www.soinside.com 2019 - 2024. All rights reserved.