How to Convert GeoJSON to SHP in C#

This brief tutorial guides on how to convert GeoJSON to SHP in C#. It has all the required information to set the development environment and a list of steps along with the sample code to develop a JSON to SHP converter in C#. It provides different options to configure the output SHP file by checking the destination layer features.

Steps to Convert JSON to SHP in C#

  1. Set the environment to use Aspose.GIS for .NET to convert the GeoJSON to SHP
  2. Instantiate an object of the ConversionOptions to customize the output SHP file
  3. Check if the destination layer supports the Wgs84 spatial reference system
  4. If supported, create an object of the ConversionOptions class
  5. Set the DestinationSpatialReferenceSystem property to Wgs84
  6. Transform the input GeoJSON to SHP using the desired options

These steps summarize the process to change JSON to SHP in C#. The process is commenced by initializing the object of ConversionOptions to customize the output SHP file followed by setting the desired spatial reference system if supported. In the final step, the Convert() method of the VectorLayer class is called for conversion by providing the source and destination files along with the custom options.

Code to Convert GeoJSON to SHP in C#

This code demonstrates the process to transform GeoJSON to SHP in C#. This conversion can be performed with a single line of code only by calling the VectorLayer.Convert() method by providing the input and output file name without passing any options. However, you may exercise the features to customize the output SHP file by using the ConversionOptions class object as depicted in this sample code.

This article has taught us the process to change GeoJSON to SHP in C#. If you want to learn the reverse process i.e. conversion of SHP to GeoJSON file, refer to the article on how to convert SHP to GeoJSON in C#.

 English