Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active November 1, 2022 09:47
Convert OSM to KML in C# | C# OSM to KML Converter
// This code example demonstrates how to convert OSM to KML.
// 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 file format from OSM to KML.
VectorLayer.Convert("C:\\Files\\sample.osm", Drivers.OsmXml, "C:\\Files\\destination.kml", Drivers.Kml, options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment