Hi, How can we convert the coordinates from any format to WGS84. I am using C# with Arc objects.
If your input is a Geometry (say points) then you can use the below sample
//Create Spatial Reference Factory
ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass();
ISpatialReference sr1;
//GCS to project from
IGeographicCoordinateSystem gcs = srFactory.CreateGeographicCoordinateSystem(<SPAN class="pun">(</SPAN><SPAN class="typ">int</SPAN><SPAN class="pun">)</SPAN><SPAN class="pln">esriSRGeoCSType</SPAN><SPAN class="pun">.</SPAN><SPAN class="pln">esriSRGeoCS_WGS1984</SPAN>);
<SPAN class="pun">(</SPAN><SPAN class="typ">int</SPAN><SPAN class="pun">)</SPAN><SPAN class="pln">esriSRGeoCSType</SPAN><SPAN class="pun">.</SPAN><SPAN class="pln">esriSRGeoCS_WGS1984</SPAN>
sr1 = gcs;
IProjectedCoordinateSystem pcs = srFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983N_AmericaLambert);
pcs.SetFalseOriginAndUnits(0, 0, 1000);
ISpatialReference sr2;
sr2 = pcs;
//Point to project
IPoint point = new PointClass() as IPoint;
point.PutCoords(xCoord,yCoord);
//Geometry Interface to do actual project
IGeometry geometry;
geometry = point;
geometry.SpatialReference = sr2;
geometry.Project(sr1);
You can use ProjectEx method if you also want to use specific Datum shift methods
yes input coordinate system could be anything, we will get the existing coordinate system, after that how to convert that coordinates to WGS84. Please send me some links.
Even that code sample, there is fromSR and ToSR. Any conversion would require type from and to.
If a value X has to be converted to Meters. But you dont know if th value is Feet or inches or miles ... how will you convert?
If it comes to geotransformation on spatial reference that's not known yet, this might be interesting: projection conversions - How to use ArcObjects to choose GeoTransformation? - Geographic Information Systems Stack Excha…
One useful trick is to get Geographic Coordinate System differently from geographic and projected coordinate systems
Without knowing the source coordinate system it is not possible to convert it to WGS84. you need two coordinate systems to convert between them.
if i have some shape files with any coordinate system (i don't know the coordinates system) and i have use the coordinates of this shape file in my another application which accepts only WGS84 coordinates. I have to read the coordinates from shape file and convert those into WGS84 and provide these to another application. Please provide any solution of this.
Thanks in advance.
Could you be more specific about what you are trying to accomplish? For example, if you are just changing spatial reference of the map on-the-fly, IMap, ILayer, and IMapControl all have the SpatialReference property.
The IGeometry has a method project which you can use to project the geometry object to what ever coordinate system you want.
ArcObjects 10 .NET SDK Help
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.