如何在地质层覆盖后盖上纵横比?
我正在尝试将一些城市覆盖在地图之上。
import pandas as pd
import geopandas as gdp
import matplotlib.pyplot as plt
from shapely.geometry import box
destinations = ["Oslo", "Bergen", "Trondheim", "Tromsø", "Nordkapp", "Bodø", "Lofoten"]
world = gdp.read_file(gdp.datasets.get_path('naturalearth_lowres'))
norway = world[world.name=="Norway"]
norway =gdp.clip(norway, box(0, 0, 60,75)) # removing Svalbard
cities = world = gdp.read_file(gdp.datasets.get_path('naturalearth_cities'))
df = pd.read_csv("norway_cities.csv", sep=";")
norway_cities = gdp.GeoDataFrame(df, geometry=gdp.points_from_xy(df.lng, df.lat))
ax = norway.plot(color='white', edgecolor='black')
ax = cities[cities.name=="Stockholm"].plot(ax=ax, color='red')
ax = norway_cities[norway_cities.city.isin(destinations)].plot(ax=ax, color='blue')
plt.show()
当我绘制斯德哥尔摩坐标时,比例会受益:
当我绘制其余内容时,事情会扭曲:
来自不同的来源
数据 =“ https://i.sstatic.net/7ea4i.png” rel =“ nofollow noreferrer”>
更改图的大小不会影响结果,我如何保持第一张图片的相同纵横比?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
构建
norway_cities
时,您尚未定义CRS。完整代码
When constructing
norway_cities
you have not defined the CRS.full code