luni, 25 august 2014

How to reproject spatial data using free libraries?

You can try the DotSpatial.Projections library.
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.");
    }
  }
}


Another alternative is http://projnet.codeplex.com/

Niciun comentariu:

Trimiteți un comentariu