Project to Lat/Long for Google maps using arcobjects

2083
1
10-08-2014 01:05 PM
JohnBerg
New Contributor

I'm trying to take a coordinate and convert it to Lat/Long for google maps but I don't know enough about projections to handle this.   I know it should be something like this but not sure what my Geo Types should ge or what the SetFalseOriginAndUnits is used for - can someone point me in the right direction?  I'm guessing I don't have the coordinate types correct or I need to project the coordinate somehow.

                ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass();

                //GCS to project from

                int geoType = (int)esriSRGeoCSType.esriSRGeoCS_NAD1983;

                var gcs = srFactory.CreateGeographicCoordinateSystem(geoType);

                ISpatialReference sr1 = gcs;

                // what should this be???

                //sr1.SetFalseOriginAndUnits(-180, -90, 1000000);

                

                //Projected Coordinate System to project into

                int geoType2 = (int)esriSRProjCSType.esriSRProjCS_NAD1983N_AmericaLambert;

                var pcs = srFactory.CreateProjectedCoordinateSystem(geoType2);

                // what should this be???

                //pcs.SetFalseOriginAndUnits(0, 0, 1000);

                ISpatialReference sr2 = pcs;

                //Point to project

                var point = new PointClass() as IPoint;

                 point.PutCoords(2396130.0831298800, 15867438.6259155000);

                //Geometry Interface to do actual project

                var geometry = point;

                geometry.SpatialReference = sr1;

                geometry.Project(sr2);

                point = geometry;

                double latitude;

                double longitude;

                point.QueryCoords(out latitude, out longitude);

My map layer has this info:

                NAD83 UTM, Zone 18 North, US Foot

                Authority: Custom

                Projection: Transverse_Mercator

                false_easting: 1640416.614993545

                false_northing: 0.0

                central_meridian: -75.0

                scale_factor: 0.9996

                latitude_of_origin: 0.0

                Linear Unit: Foot_US (0.3048006096012192)

                Geographic Coordinate System: North_American_Datum_1983

                Angular Unit: Degree (0.0174532925199433)

                Prime Meridian: Greenwich (0.0)

                Datum: D_North_American_1983

                  Spheroid: Geodetic_Reference_System_of_1980

                    Semimajor Axis: 6378137.0

                    Semiminor Axis: 6356752.31414035

                    Inverse Flattening: 298.2572221009113

Tags (1)
0 Kudos
1 Reply
RiyasDeen
Occasional Contributor III

Hi John,

  1. Your coordinates seem to be projected coordinates but your are assigning a geographic coordinates system in this line geometry.SpatialReference = sr1; You should assign a projected coordinate system for this coordinates (esriSRProjCS_NAD1983UTM_18N in your case)
  2. Geographic coordinates are latitude (valid values -90 to +90) and longitude (valid values are -180 to +180), projected coordiates are generally in linear units meter or miles.
  3. Google maps coordinates are in WGS84 you should project your geometry to esriSRGeoCS_WGS1984
0 Kudos