There might be situations where you need to convert JSON files to GeoJSON. If you have multiple files, doing this task programmatically will prove to be helpful. To that end, this article will teach you how to convert JSON files to GeoJSON using C#.
C# API for Converting JSON to GeoJSON
Aspose.GIS for .NET API allows you to render maps and create, read, and convert geographic data without additional software. Furthermore, the API enables you to convert JSON to GeoJSON. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.GIS
Convert JSON to GeoJSON using C#
The following are the steps to convert JSON to GeoJSON.
- Create an instance of the ConversionOptions class.
- Assign the SpatialReferenceSystem.Wgs84 to the ConversionOptions object using the DestinationSpatialReferenceSystem property.
- Convert the JSON to GeoJSON using the VectorLayer.Convert(string sourcePath, FileDriver sourceDriver, string destinationPath, FileDriver destinationDriver, ConversionOptions options) method.
The following sample code shows how to convert JSON to GeoJSON using C#
Get a Free License
In order to try the API without evaluation limitations, you can request a free temporary license.
Conclusion
In this article, you have learned how to convert JSON to GeoJSON using C#. The shared code snippet shows how to achieve this with just a few lines of code. Aspose.GIS for .NET is a robust 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.