Hi, How can we convert the coordinates from any format to WGS84. I am using C# with Arc objects.
The IGeometry has a method project which you can use to project the geometry object to what ever coordinate system you want.
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.
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.
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 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...
One useful trick is to get Geographic Coordinate System differently from geographic and projected coordinate systems
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?
I think the OP means that the input coordinate system could be anything, not that it's completely unknown.
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.
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((int)esriSRGeoCSType.esriSRGeoCS_WGS1984
);
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