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.
Solved! Go to Solution.
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);
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
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.
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);
Brilliant! It's easy when you know how. Solves problem completely. Thanks for getting me past my roadblock.