Convert GeoJson to TopoJson and vice versa using C#


GeoJSON is used for representing geographical features with non-spatial features. Whereas, TopoJSON is an extension of GeoJSON that utilizes Topology. You can convert GeoJSON to TopoJSON as well as TopoJSON to GeoJSON as per your requirements. Let us explore the following use cases in details:

GeoJSON and TopoJSON inter-conversion – C# .NET API Installation

Aspose.GIS for .NET API can be used to manipulate or convert geographical data. You can easily configure the API by downloading its DLL file from the Downloads section, or via the NuGet gallery with the following installation command:

PM> Install-Package Aspose.GIS

Convert GeoJSON to TopoJSON Programmatically using C#

GeoJSON to TopoJSON file conversion is helpful because it encodes geospatial features and is smaller in file size. It is smaller in file size because of topology and eliminating redundancy. Furthermore, even when there is no shared topology, the fix-precision encoding is way more efficient than floating point encoding of GeoJSON file format. You can convert GeoJSON to TopoJSON with the following steps:

  1. Load input GeoJSON file
  2. Convert GeoJSON to TopoJSON

The following code snippet shows how to convert GeoJSON to TopoJSON programmatically using C#:

Convert GeoJSON to TopoJSON with Quantization using C#

GeoJSON to TopoJSON conversion is popular because of the fixed-precision efficiency and lesser file size. Moreover, quantization reduces the precision of coordinates. Resultantly, it optimizes the file size by representing the coordinates as integers. So you can convert GeoJSON to TopoJSON with quantization with the steps below:

  1. Initialize ConversionOptions class object
  2. Specify Quantization Number
  3. Or set Transform property
  4. Convert GeoJSON to TopoJSON with quantization

The code below shows how to convert GeoJSON to TopoJSON with quantization. It explains two alternative approaches for the conversion:

Convert TopoJSON to GeoJSON Programmatically in C#

Aspose.GIS for .NET API supports TopoJSON to GeoJSON file conversion. So you can add this feature in your .NET applications. Moreover, GeoJSON file are usually preferred in server-side manipulation of geometries which do not require topologies. You can follow the following steps for TopoJSON to GeoJSON conversion:

  1. Load input TopoJSON file
  2. Converting TopoJSON to GeoJSON

The following code shows how to convert TopoJSON to GeoJSON programmatically using C#:


In this article, you have learned the differences and suitability of GeoJSON and TopoJSON file formats. Moreover, you have explored how to convert them into each other as per your requirements. Aspose.GIS for .NET API can efficiently and quickly perform the inter-conversion in your applications. Furthermore, you can learn more by visiting the API Documentation. In case of any query or concerns, please feel free to write back to us at the Free Support Forums.

See Also

Create KML File or Read its Features Programmatically using C#