地板拼字投影显示错误

发布于 2025-01-21 04:43:33 字数 2127 浏览 0 评论 0原文

后续问题至我以前的问题我可以包括输出的图像。

这是我运行以下代码时的输出,仅包含重要部分:

“

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:

This

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文