Created
October 6, 2025 21:05
-
-
Save aspose-com-gists/01af3223ebf3cc5f82bdd6960c5d0415 to your computer and use it in GitHub Desktop.
Convert GeoJSON to TopoJSON in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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