This tutorial explains the conversion of SHP to KML in C#. It explains the IDE settings, a list of steps, and a working sample code for developing a SHP to KML converter in C#. Moreover, you can follow this guide to implement this conversion in any operating system where the .NET environment is configured.
Steps to Convert SHP to KML in C#
- Prepare the system to use Aspose.GIS for .NET to convert SHP to KML format
- Create an instance of the ConversionOptions class
- Call the SupportsSpatialReferenceSystem method to check if the destination layer supports the required spatial reference
- Assign Wgs84 to the destination layer using the DestinationSpatialReferenceSystem property
- Export the Shapefile to KML format with the Convert method
These steps simplify the process to convert SHP to KML in C#. Initiate the conversion by specifying the conversion options and then determine if the spatial reference system is supported or not. Subsequently, convert the Shapefile and export the output KML file.
Code to Create SHP to KML Converter in C#
This code snippet demonstrates the workflow to convert Shapefile to KML in C#. It handles the exceptions as well in case some drivers do not support the spatial reference system of the destination layer. Moreover, you can work with different overloads of the Convert method to improvise the SHP to KML conversion as per your requirements.
This article has taught us to render Shapefile to KML in C#. However, if you want to export KML to CSV format, then read the article on Convert KML to CSV using C#.