IPolygon pg = MyFeature.Shape as IPolygon; if (pg.SpatialReference is IProjectedCoordinateSystem) { projCoordinateSystem = pg.SpatialReference as IProjectedCoordinateSystem; pg.Project(projCoordinateSystem.GeographicCoordinateSystem); // Update the DD textboxes. IArea area = pg as IArea; obj.set_Value(gpslatitude, string.Format("{0:0.######}", area.Centroid.Y)); obj.set_Value(gpslongitude, string.Format("{0:0.######}", area.Centroid.X)); }
If the geometry has a projected coordinate system then you should be able to just use the geographic coordinate system it's based on and project it. The following is a code snippet from one of our apps. ' Project the UTM to Lat/Long. Dim projCoordinateSystem As IProjectedCoordinateSystem = DirectCast(point.SpatialReference, IProjectedCoordinateSystem) point.Project(projCoordinateSystem.GeographicCoordinateSystem) ' Update the DD textboxes. DdLatitudeTextbox.Text = Format(point.Y, "0.000000") DdLongitudeTextbox.Text = Format(point.X, "0.000000")
' Project the UTM to Lat/Long. Dim projCoordinateSystem As IProjectedCoordinateSystem = DirectCast(point.SpatialReference, IProjectedCoordinateSystem) point.Project(projCoordinateSystem.GeographicCoordinateSystem) ' Update the DD textboxes. DdLatitudeTextbox.Text = Format(point.Y, "0.000000") DdLongitudeTextbox.Text = Format(point.X, "0.000000")
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.