Select to view content in your preferred language

coordinate conversion

1723
4
Jump to solution
02-27-2018 03:55 AM
MarcHillman
Regular Contributor

I need a little help. I have been successfully reading a number of shapefiles, extracting the polygons, and exporting them as KML. All works well, but now I've hit a shapefile that isn't WGS84. How do I convert all the points to WGS84?

I know the shapefile uses EPSG:2193.

To keep the KML file to a sensible size, I also do a generalize.

Not sure whether I transform "compressed" or "geo" in the code below.

Any help much appreciated.

For Each fragment As Esri.ArcGISRuntime.Data.GeodatabaseFeature In fragments

                Dim compressed As Esri.ArcGISRuntime.Geometry.Geometry = Esri.ArcGISRuntime.Geometry.GeometryEngine.Generalize(fragment.Geometry, My.Settings.TrackSmoothness * DegPerM, True)
                Dim geo As Esri.ArcGISRuntime.Geometry.Polygon = compressed

Next

Skill level - knows enough to be dangerous.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Notable Contributor

Sorry for the C# (I've long forgotten my VB skills), but here's how you would project a geometry to WGS84:

Geometry geometryWgs84 = GeometryEngine.Project(inputGeometry, SpatialReferences.Wgs84);

View solution in original post

4 Replies
DanPatterson_Retired
MVP Emeritus

Project.. the shapefile to a Geographic Coordinate System (aka unprojected.  a GCS WGS84 will do), then export to kml  The same tool exists in ArcMap and PRO, depending on which platform you are using

0 Kudos
MarcHillman
Regular Contributor

Examples are sparse, but this is as far as I've gotten

                Dim WGS84 As New Esri.ArcGISRuntime.Geometry.SpatialReference("WGS84")  ' datum for Google Earth
                Dim converter As New ProjectionConverter()
                compressed = converter.Convert(compressed, TypeOf compressed, WGS84, System.Globalization.CultureInfo.InvariantCulture)

I can't for the life of me work out what the Type parameter (2nd) of convert should be.

0 Kudos
dotMorten_esri
Esri Notable Contributor

Sorry for the C# (I've long forgotten my VB skills), but here's how you would project a geometry to WGS84:

Geometry geometryWgs84 = GeometryEngine.Project(inputGeometry, SpatialReferences.Wgs84);

MarcHillman
Regular Contributor

Brilliant! It's easy when you know how. Solves problem completely. Thanks for getting me past my roadblock.

0 Kudos