Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created October 6, 2025 21:05
Show Gist options
  • Save aspose-com-gists/01af3223ebf3cc5f82bdd6960c5d0415 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/01af3223ebf3cc5f82bdd6960c5d0415 to your computer and use it in GitHub Desktop.
Convert GeoJSON to TopoJSON in Python
import os
import aspose.gis as gis
from aspose.gis import VectorLayer, Drivers, ConversionOptions
from aspose.gis.formats.topojson import TopoJsonOptions
from aspose.pycore import cast
# Define path for the working directory and load the Aspose.GIS license.
dataDir = "files"
license = gis.License()
license.set_license("License.lic")
# Set path for the source GeoJSON file.
sample_geojson_path = os.path.join(dataDir, "sample.geojson")
output_file_path = os.path.join(dataDir, "convertedSample_out.topojson")
# Call the convert method to convert GeoJSON to TopoJSON
VectorLayer.convert(sample_geojson_path, Drivers.geo_json, output_file_path, Drivers.topo_json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment