C#中使用GEO坐标绘制地图

发布于 2024-10-04 03:12:09 字数 625 浏览 0 评论 0原文

他,

我想用 C# 绘制一个带有 LAT/LNG 坐标的国家地图。我必须将纬度/经度转换为像素,最好的方法是什么?我可以绘制“地图”,但它非常小,而且不在窗口的中心。

有人可以帮忙吗?我有这个代码:

    void draw(Graphics g, PointF[] points, Pen p)
    {            
        Graphics gfx = g;
        gfx.PageUnit = GraphicsUnit.Point;

        GraphicsPath gpath = new GraphicsPath();
        gpath.StartFigure();
        gpath.AddLines(points);
        gpath.CloseFigure();

        Matrix m = new Matrix();
        m.Scale(5, 5);

        gfx.Transform = m;
        gfx.DrawPath(p, gpath);            
        gfx.Dispose();
        gpath.Dispose();

        return;
    }

He,

I want to draw a Countrymap in C# with LAT/LNG coordinates. I have to translate the lat/lng to pixels, what would be the best way? I can draw the 'Map' but it's very small and it's not in the center of the window.

Can someone help? I have this code:

    void draw(Graphics g, PointF[] points, Pen p)
    {            
        Graphics gfx = g;
        gfx.PageUnit = GraphicsUnit.Point;

        GraphicsPath gpath = new GraphicsPath();
        gpath.StartFigure();
        gpath.AddLines(points);
        gpath.CloseFigure();

        Matrix m = new Matrix();
        m.Scale(5, 5);

        gfx.Transform = m;
        gfx.DrawPath(p, gpath);            
        gfx.Dispose();
        gpath.Dispose();

        return;
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请止步禁区 2024-10-11 03:12:09

您需要选择地图投影(例如墨卡托投影、柱面等积投影或 Mollweide 投影),然后将坐标从地理 lat、LNG 转换为使用此投影。

其标准开源库是 proj.4。我知道周围有 C# 包装器,但我个人已经将 OGR 与 ogrsharp 包装器一起使用。 OGR 在内部使用 proj.4,但当您想要使用特定坐标系(例如在 prj 文件中定义)时,还添加了许多常用函数。

You will need to choose a map projection (eg. Mercator, Cylindrical Equal Area, or Mollweide) and then transform the coordinates from geographic lat,LNG to use this projection.

The standard open source library for this is proj.4. I understand there are C# wrappers around, ut personally I've used OGR with the ogrsharp wrappers. OGR uses proj.4 internally but also adds a lot of used functions when you want to work with specific coordinate systems (eg defined in a prj file).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文