简体   繁体   English

Geopandas 图被拉伸

[英]Geopandas plot is streched

I'm trying to plot a state of Germany with geopandas.我正在尝试用 geopandas 绘制德国的状态。 Unfortunately the plot is a bit streched.可惜剧情有点牵强。

import matplotlib.pyplot as plt
import geopandas as gpd

shapes = gpd.read_file('shapes.shp')
shapes.plot(figsize=(20,20), color='white', edgecolor='black')

If I execute the code above, I'll receive the following plot.如果我执行上面的代码,我将收到以下图。 在此处输入图片说明 But if you compare the shape of the plot to the real shape of the state as displayed below, then this plot is a bit streched.但是,如果您将图的形状与如下所示的状态的真实形状进行比较,则该图有点拉伸。 在此处输入图片说明

I tried to adjust the axes and the figsize, but I didn't work.我试图调整轴和 figsize,但我没有工作。

Thanks for your help谢谢你的帮助

As gboffi mentioned the projection is not right.正如 gboffi 提到的,投影是不正确的。 So i changed it to EPSG:3857.所以我把它改成了 EPSG:3857。

import matplotlib.pyplot as plt
import geopandas as gpd

shapes = gpd.read_file('shapes.shp').to_crs(epsg=3857)
fig, axs = plt.subplots(1, 1, figsize=(15,15))
shapes.plot(ax=axs, color='white', edgecolor='black')

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM