Projecting to USA Contiguous Lambert Conformal Conic - sindizzy/DSW GitHub Wiki
This code will take a feature set and project the feature set from a geographic coordinate system to the USA Contiguous Lambert Conic projected coordinate system.
VB Sample Code:
Imports System Imports DotSpatial.ProjectionsPublic Class Form1
<span style="color:blue">Private</span> <span style="color:blue">Sub</span> Button1_Click(<span style="color:blue">ByVal</span> sender <span style="color:blue">As</span> System.Object, <span style="color:blue">ByVal</span> e <span style="color:blue">As</span> System.EventArgs) <span style="color:blue">Handles</span> Button1.Click <span style="color:green">'Sets up a array to contain the x and y coordinates</span> <span style="color:blue">Dim</span> xy(1) <span style="color:blue">As</span> <span style="color:blue">Double</span> xy(0) = 0 xy(1) = 0 <span style="color:green">'An array for the z coordinate</span> <span style="color:blue">Dim</span> z(0) <span style="color:blue">As</span> <span style="color:blue">Double</span> z(0) = 1 <span style="color:green">'Defines the starting coordiante system</span> <span style="color:blue">Dim</span> pStart <span style="color:blue">As</span> ProjectionInfo = KnownCoordinateSystems.Geographic.World.WGS1984 <span style="color:green">'Defines the ending coordiante system</span> <span style="color:blue">Dim</span> pEnd <span style="color:blue">As</span> ProjectionInfo = KnownCoordinateSystems.Projected.NorthAmerica.USAContiguousLambertConformalConic <span style="color:green">'Calls the reproject function that will transform the input location to the output locaiton</span> Reproject.ReprojectPoints(xy, z, pStart, pEnd, 0, 1) MsgBox(<span style="color:#a31515">"The points have been reporjected."</span>) <span style="color:blue">End</span> <span style="color:blue">Sub</span>
End Class
C# Sample Code:
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(); }
<span style="color:blue">private</span> <span style="color:blue">void</span> button1_Click(<span style="color:blue">object</span> sender, EventArgs e) { <span style="color:green">//Sets up a array to contain the x and y coordinates</span> <span style="color:blue">double</span>[] xy = <span style="color:blue">new</span> <span style="color:blue">double</span>[2]; xy[0] = 0; xy[1] = 0; <span style="color:green">//An array for the z coordinate</span> <span style="color:blue">double</span>[] z = <span style="color:blue">new</span> <span style="color:blue">double</span>[1]; z[0] = 1; <span style="color:green">//Defines the starting coordiante system</span> ProjectionInfo pStart = KnownCoordinateSystems.Geographic.World.WGS1984; <span style="color:green">//Defines the ending coordiante system</span> ProjectionInfo pEnd = KnownCoordinateSystems.Projected.NorthAmerica.USAContiguousLambertConformalConic; <span style="color:green">//Calls the reproject function that will transform the input location to the output locaiton</span> Reproject.ReprojectPoints(xy, z, pStart, pEnd, 0, 1); Interaction.MsgBox(<span style="color:#a31515">"The points have been reporjected."</span>); } }
}