地板拼字投影显示错误
后续问题至我以前的问题我可以包括输出的图像。
这是我运行以下代码时的输出,仅包含重要部分:
import pyproj
import geopandas as gpd
import matplotlib.pyplot as plt
currentProjection = "Orthographic"
nel_path = gpd.datasets.get_path("naturalearth_lowres")
g_path = "myDirectory/ne_110m_graticules_10/ne_110m_graticules_10.shp"
class Projections:
class Mercator:
world = gpd.read_file(nel_path)
cities = gpd.read_file(gpd.datasets.get_path("naturalearth_cities"))
graticules = gpd.read_file(g_path)
graticules = graticules.set_crs("EPSG:4326")
def createprojection(crs, name):
class Thing:
world = Projections.Mercator.world.to_crs(crs)
cities = Projections.Mercator.cities.to_crs(crs)
graticules = Projections.Mercator.graticules.to_crs(crs)
setattr(Projections, name, Thing)
createprojection("EPSG: 9840", "Orthographic")
def plot_map(gdf1, gdf2, gdf3, name, unit):
fig, ax = plt.subplots(figsize=(12, 10))
gdf1.plot(ax=ax, color="lightgray")
gdf2.plot(ax=ax, color="black", markersize=10, marker="o")
gdf3.plot(ax=ax, color="darkgray", linewidth=0.5)
ax.set(xlabel="X Coordinate -" + unit, ylabel="Y Coordinate -" + unit, title=name)
plt.show()
if __name__ == '__main__':
projection = getattr(Projections, currentProjection)
plot_map(projection.world, projection.cities, projection.graticules, currentProjection, "Metres")
我确实修改了事物一定程度,使得在预测之间更容易切换,这是我最终目标的一部分,但是它的工作方式与教程
添加了教程的任何一部分教程,并且添加了任何一部分,并且如果您切换Current purrent-prodoction
顶部到“ Mercator”的变量仍然可以很好地工作。
这些是我拥有的库的版本:
python:3.10,pyproj:3.3.0,geopandas:0.10.2,matplotlib:3.5.1
Follow-up question to my previous question so that I can include an image of what the output is.
This is the output when I run the following code, cleaned up to only include important parts:
import pyproj
import geopandas as gpd
import matplotlib.pyplot as plt
currentProjection = "Orthographic"
nel_path = gpd.datasets.get_path("naturalearth_lowres")
g_path = "myDirectory/ne_110m_graticules_10/ne_110m_graticules_10.shp"
class Projections:
class Mercator:
world = gpd.read_file(nel_path)
cities = gpd.read_file(gpd.datasets.get_path("naturalearth_cities"))
graticules = gpd.read_file(g_path)
graticules = graticules.set_crs("EPSG:4326")
def createprojection(crs, name):
class Thing:
world = Projections.Mercator.world.to_crs(crs)
cities = Projections.Mercator.cities.to_crs(crs)
graticules = Projections.Mercator.graticules.to_crs(crs)
setattr(Projections, name, Thing)
createprojection("EPSG: 9840", "Orthographic")
def plot_map(gdf1, gdf2, gdf3, name, unit):
fig, ax = plt.subplots(figsize=(12, 10))
gdf1.plot(ax=ax, color="lightgray")
gdf2.plot(ax=ax, color="black", markersize=10, marker="o")
gdf3.plot(ax=ax, color="darkgray", linewidth=0.5)
ax.set(xlabel="X Coordinate -" + unit, ylabel="Y Coordinate -" + unit, title=name)
plt.show()
if __name__ == '__main__':
projection = getattr(Projections, currentProjection)
plot_map(projection.world, projection.cities, projection.graticules, currentProjection, "Metres")
I did modify things up to an extent so that it would be easier to switch between projections, which is part of my end goal, but it still works exactly the same way as in the tutorial
anything not part of the tutorial was added for ease of use, and if you switch the currentProjection
variable at the top to "Mercator" it still works perfectly fine.
These are the versions of libraries I have:
Python:3.10, Pyproj:3.3.0, Geopandas:0.10.2, matplotlib:3.5.1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论