Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Created September 12, 2023 09:44
Convert KML to GPX Online for Free | KML to GPX Converter in C# .NET | Google Maps Google Earth
string sourceFile = "destination.kml";
string outputFile = "output.gpx";
// Specify conversion settings if necessary. It is optional.
ConversionOptions options = null;
// This options assigns Wgs84 to the destination layer.
// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check.
if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84))
{
options = new ConversionOptions()
{
DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84,
};
}
// Convert KML to GPX
VectorLayer.Convert(sourceFile, Drivers.Kml, outputFile, Drivers.Gpx, options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment