There are different situations where having data in a Shapefile or GeoJSON format can be helpful. If you have a Shapefile that you want to convert to GeoJSON or vice versa, you can easily achieve it programmatically with C#. In this article, you will learn how to do just that.
- C# API to Convert Shapefile to GeoJSON and Vice Versa
- Convert Shapefile to GeoJSON
- Convert GeoJSON to Shapefile
C# API for Converting Shapefile to GeoJSON and Vice Versa
Aspose.GIS for .NET API allows you to render maps and create, read, and convert geographic data without additional software. Furthermore, the API allows you to convert Shapefile to GeoJSON and vice versa. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.GIS
Convert Shapefile to GeoJSON in C#
The following is the step to convert Shapefile to GeoJSON.
- Use the VectorLayer.Convert(string sourcePath, FileDriver sourceDriver, string destinationPath, FileDriver destinationDriver) method to convert the Shapefile to GeoJSON.
The following sample code shows how to convert a Shapefile to GeoJSON using C#.
Convert GeoJSON to Shapefile in C#
Similar to converting Shapefile to GeoJSON, GeoJSON files can be converted to Shapefile with just a single line of code. The following is the step to convert GeoJSON to Shapefile.
- Use the VectorLayer.Convert(string sourcePath, FileDriver sourceDriver, string destinationPath, FileDriver destinationDriver) method to convert the GeoJSON to Shapefile.
The following sample code shows how to convert GeoJSON to Shapefile using C#.
Get a Free License
In order to try the API without evaluation limitations, you can get a free temporary license.
In this article, you have learned how to convert Shapefile to GeoJSON and vice versa using C#. The shared code snippets demonstrate how to achieve these conversions with just a single line of code. Aspose.GIS for .NET is a powerful and feature-rich API that assists you in working with geospatial data. You can explore the API in detail by visiting the official documentation. In case of any questions, please feel free to reach us at our free support forum.