ArcGIS geographic coordinates and projected coordinate transformations [go]

Source: Internet
Author: User
Tags ipoint

Reprint Address: http://blog.163.com/lai_xiao_hui/blog/static/123037324201151443221942/

The code is to convert WGS84 geographic coordinates to WGS84UTM projection coordinates, and if you want to convert to Xi ' an 80 or Beijing 54 coordinates, the parameters are:

Beijing 54 Coordinates:

The geographic coordinates enumeration value is: esrisrgeocstype.esrisrgeocs_beijing1954

The projected coordinate enumeration value is: Esrisrprojcstype.esrisrprojcs_beijing1954gk_13 ...

Xi ' an 80 coordinates:

The geographic coordinates enumeration value is: esrisrgeocs3type.esrisrgeocs_xian1980

The projected coordinate enumeration value is: esrisrprojcs4type.esrisrprojcs_xian1980_3_degree_gk_cm_102e ...

public class Wgs84utm
{
<summary>
Convert from geographic coordinates to projected coordinates
</summary>
<param name= "Longitude" > Longitude </param>
<param name= "Latitude" > Latitude, Southern Hemisphere negative </param>
<param name= "x" >X</param>
<param name= "Y" >Y</param>
<param name= "zone" > Zone (1-60, from 180 to +180,6 degrees) </param>
public static void Geotoprj (double longitude, double latitude, out Double X, out double y, out int zone)
{
Ispatialreferencefactory pspatialreferencefactory = new Spatialreferenceenvironmentclass ();
Igeographiccoordinatesystem Pgeocoordsys = Pspatialreferencefactory.creategeographiccoordinatesystem ((int) Esrisrgeocstype.esrisrgeocs_wgs1984);
int startprjnum = 32601;
if (Latitude < 0) Startprjnum = 32701;
zone = (int) Math.Round (((longitude + 3)/6) + 30;
int prjnum = Startprjnum + zone-1;
Iprojectedcoordinatesystem Pprjcoordsys = Pspatialreferencefactory.createprojectedcoordinatesystem (Prjnum);

IPoint pt = new Pointclass ();
Pt. Putcoords (longitude, latitude);
Igeometry Geo = (igeometry) pt;
Geo. Spatialreference = Pgeocoordsys;
Geo. Project (Pprjcoordsys);
x = pt. X
y = pt. Y
if (Latitude < 0)
y = 0-y;
}
<summary>
Convert from projected coordinates to geographic coordinates
</summary>
<param name= "x" >X</param>
<param name= "y" >y, negative Southern hemisphere </param>
<param name= "zone" > Zone (1-60, from 180 to +180,6 degrees) </param>
<param name= "Longitude" > Longitude </param>
<param name= "Latitude" > Latitude </param>
public static void Prjtogeo (double x, double y, int zone, out double longitude, out double latitude)
{
Ispatialreferencefactory pspatialreferencefactory = new Spatialreferenceenvironmentclass ();
Igeographiccoordinatesystem Pgeocoordsys = Pspatialreferencefactory.creategeographiccoordinatesystem ((int) Esrisrgeocstype.esrisrgeocs_wgs1984);
int startprjnum = 32601;
BOOL South = FALSE;
if (Y < 0)
{
south = true;
y = 0-y;
}
if (south) startprjnum = 32701;
int prjnum = Startprjnum + zone-1;
Iprojectedcoordinatesystem Pprjcoordsys = Pspatialreferencefactory.createprojectedcoordinatesystem (Prjnum);

IPoint pt = new Pointclass ();
Pt. Putcoords (x, y);
Igeometry Geo = pt as igeometry;
Geo. Spatialreference = Pprjcoordsys;
Geo. Project (Pgeocoordsys);
Longitude = pt. X
Latitude = pt. Y
if (south) latitude = 0-latitude;

}
}

ArcGIS geographic coordinates and projected coordinate transformations [go]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.