This quick tutorial guides on how to convert SHP to GPX in C# by providing configuration details, a stepwise process, and a runnable sample code. You can perform this task with a single line of code also however the sample code will demonstrate setting conversion options as well. This process to convert Shapefile to GPX in C# can be performed on any Windows-based system having .NET installed on it or Linux/macOS system having .NET Core.
Steps to Convert Shape File to GPX in C#
- Install Aspose.GIS for .NET from the NuGet package manager to convert SHP file to GPX
- Instantiate the ConversionOptions class object to customize the conversion process
- Check if your Shapefile driver supports a particular spatial reference system or not
- Set the option for a desired spatial reference system
- Convert the SHP file to GPX using the Convert method in the VectorLayer class
These steps explain the process to convert shape file to GPX in C# by identifying the reference namespaces and classes that are required to accomplish the task. This process can be completed simply with the Convert method in the VectorLayer class however different options are explored to customize the conversion process. It also provides information to check if the selected driver supports a particular spatial reference system or not.
Code for SHP to GPX Converter in C#
This code has demonstrated the process to convert SHP to GPX in C#. You can use a specific driver for working with different file formats like GeoJson, Kml, Shapefile, OsmXml, and Gml to list a very few. This code has used the spatial reference system Wgs84 however you may use other options also like Wgs72, WebMercator, Etrs89LambertConformalConic, Etrs89, etc. based upon the support provided by the destination layer.
In this tutorial, we have learned the conversion of SHP to GPX. If you want to learn the process to convert GPX to KMZ, refer to the article on how to convert GPX to KMZ in C#.