C#平面座標與經緯度轉換

來源:互聯網
上載者:User

<!-- [if gte mso 9]><![endif]--><!-- [if gte mso 9]><![endif]--><!-- [if gte mso 9]><![endif]--><!-- [if gte mso 10]>

<![endif]-->

<!-- [if gte mso 9]><![endif]--><!-- [if gte mso 9]><![endif]--><!-- [if gte mso 9]><![endif]--><!-- [if gte mso 10]>

<![endif]-->

一般空間參考ISpatialReferencemSpa;一般可從AE控制項axMapControl得到

 

ESRI.ArcGIS.Controls.AxMapControlaxMapControl;

mSpa= axMapControl. SpatialReference;

投影座標係為

mGeographic =(int)esriSRGeoCSType.esriSRGeoCS_WGS1984;

mProject=
(int)esriSRProjCSType.esriSRProjCS_Beijing1954GK_23N;


經緯度點轉換為平面座標:

public static IPoint GetProject(double x, double y)<br /> {<br />ISpatialReferenceFactory2 sprf = new SpatialReferenceEnvironmentClass();<br />IPoint pt = new PointClass();<br />pt.PutCoords(x, y);<br />IGeometry geo = (IGeometry)pt;<br />IGeographicCoordinateSystem pGeoSys<br />= sprf.CreateGeographicCoordinateSystem(mGeographic);<br />geo.SpatialReference = pGeoSys;<br />//建立你希望投影到的平面座標系統統<br />IProjectedCoordinateSystem pProSys<br /> = sprf.CreateProjectedCoordinateSystem(mSpa.FactoryCode);<br />geo.Project(pProSys);<br />return pt;<br />}<br />

 


<!-- [if gte mso 9]><![endif]--><!-- [if gte mso 9]><![endif]--><!-- [if gte mso 9]><![endif]--><!-- [if gte mso 10]>

<![endif]-->

平面座標轉換為經緯度
:

public static IPoint GetGeo(double x, double y)<br />{<br />ISpatialReferenceFactory2 sprf= new SpatialReferenceEnvironmentClass();<br />IPoint pt=new PointClass();<br />pt.PutCoords(x,y);<br />IGeometry geo = (IGeometry)pt;<br />if(null==mSpa)<br />{<br /> IProjectedCoordinateSystem pProSys<br />= sprf.CreateProjectedCoordinateSystem(mProject);<br /> geo.SpatialReference = pProSys;<br />}<br />else<br />{<br />geo.SpatialReference = mSpa;<br />}<br />IGeographicCoordinateSystem pGeoSys<br />=sprf.CreateGeographicCoordinateSystem(mGeographic);<br />geo.Project(pGeoSys);<br />return pt;<br />}<br />

 

<!-- [if gte mso 9]><![endif]--><!-- [if gte mso 9]><![endif]--><!-- [if gte mso 9]><![endif]--><!-- [if gte mso 10]>

<![endif]-->

Ps :
FactoryCode 是把空間參考轉換為相應的數值。預設為
0

 


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.