Select to view content in your preferred language

Convert Coordinates from any format to WGS84

10173
9
07-06-2015 05:28 AM
AnkurWalia
Deactivated User

Hi, How can we convert the coordinates from any format to WGS84. I am using C# with Arc objects.

0 Kudos
9 Replies
thejuskambi
Frequent Contributor

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

0 Kudos
YuanLiu
Deactivated User

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.

0 Kudos
AnkurWalia
Deactivated User

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.

0 Kudos
thejuskambi
Frequent Contributor

Without knowing the source coordinate system it is not possible to convert it to WGS84. you need two coordinate systems to convert between them.

0 Kudos
YuanLiu
Deactivated User

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

0 Kudos
thejuskambi
Frequent Contributor

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?

0 Kudos
MelitaKennedy
Esri Notable Contributor

I think the OP means that the input coordinate system could be anything, not that it's completely unknown.

0 Kudos
AnkurWalia
Deactivated User

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.

0 Kudos
SachinKanaujia
Deactivated User

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

0 Kudos