Work with Open Street Map OSM files in C# API

Working with OpenStreetMap (OSM) XML Files

Aspose.GIS lets you open and read features from OpenStreetMap (OSM) XML files. At present, the API doesn’t provide the facility to create new OSM XML file and only reading is supported.

Reading Features from OSM XML File

// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET
using (var layer = Drivers.OsmXml.OpenLayer(dataDir + "fountain.osm"))
{
// get feratures count
int count = layer.Count;
Console.WriteLine("Layer count: " + count);
// get feature at index 2
Feature featureAtIndex2 = layer[2];
// iterate through all features.
foreach (Feature feature in layer)
{
// handle feature
Console.WriteLine(feature.Geometry.AsText());
}
}