Work with Open Street Map OSM files in C# API
Contents
[
Hide
]
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()); | |
} | |
} |