Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

How can I use free libraries to transform spatial data?

For example, I want to change the projection of a Shapefile within the code of my C# web application. How do I do that?

share|improve this question
    
Converted to CW because this is really a "list of X" question. –  whuber Aug 11 '11 at 14:56
1  
at bit late now as the CW horse is out the gate already, but if answerers paid more attention to the "how do I do that?" part of the Q it wouldn't be just a "list of X". –  matt wilkie Aug 30 '11 at 22:02
    
Let's try to make this a great question with great answers. –  underdark Aug 30 '11 at 22:18
add comment

4 Answers

up vote 7 down vote accepted

You can try the DotSpatial.Projections library.

The website lists an example "Converting from a Geographic Coordinate System to a Projected Coordinate System":

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.");
    }
  }
}
share|improve this answer
add comment

There is also GDAL/OGR: http://trac.osgeo.org/gdal/wiki/GdalOgrInCsharp The page looks quite old, I'm not sure if the bindings are up to date.

share|improve this answer
add comment

I was a bit surprised nobody mentioned proj.4 and shapelib. Although both are C projects, C# bindings have been made (or you could just p/invoke them).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.