如何使用免费库重新投影空间数据?


13

如何使用免费库转换空间数据?

例如,我想在C#Web应用程序的代码中更改Shapefile的投影。我怎么做?


转换为CW,因为这实际上是一个“ X列表”问题。
whuber

2
现在已经有点晚了,因为CW马已经出局了,但是如果回答者更加关注“我该怎么办?” Q的一部分,它不仅是“ X列表”。
马特·威尔基2011年

让我们尝试通过一个很好的答案使这成为一个很好的问题。
昏暗

Answers:


10

您可以尝试使用DotSpatial.Projections库。

该网站列出了一个示例“从地理坐标系转换为投影坐标系”

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DotSpatial.Projections;

namespace WindowsFormsApplication1
{
  public partial class Form1 : Form
  {
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        //Sets up a array to contain the x and y coordinates
        double[] xy = new double[2];
        xy[0] = 0;
        xy[1] = 0;
        //An array for the z coordinate
        double[] z = new double[1];
        z[0] = 1;
        //Defines the starting coordiante system
        ProjectionInfo pStart = KnownCoordinateSystems.Geographic.World.WGS1984;
        //Defines the ending coordiante system
        ProjectionInfo pEnd = KnownCoordinateSystems.Projected.NorthAmerica.USAContiguousLambertConformalConic;
        //Calls the reproject function that will transform the input location to the output locaiton
        Reproject.ReprojectPoints(xy, z, pStart, pEnd, 0, 1);
        Interaction.MsgBox("The points have been reporjected.");
    }
  }
}



2

我有点惊讶,没有人提到proj.4和shapelib。尽管两者都是C项目,但是已经进行了C#绑定(或者您可以p /调用它们)。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.