Hello, I'm trying to get the GeoJSON MultiLineString geometry object from a topojson file by following the instructions.
Environment
$ python --version
Python 3.12.3
$ pip list
Package Version
------------------ --------
certifi 2025.8.3
charset-normalizer 3.4.3
idna 3.10
numpy 2.3.2
pip 24.0
pytopojson 1.1.2
requests 2.32.5
urllib3 2.5.0
Script
# main.py
import requests
import json
from pytopojson.feature import Feature
from pytopojson.mesh import Mesh
US_URL = "https://cdn.jsdelivr.net/npm/us-atlas@3/counties-10m.json"
us = json.loads(requests.get(US_URL).content)
nation = Feature().feature(us, us["objects"]["nation"])
statemesh = Mesh()(
us,
obj=us["objects"]["states"],
filt=lambda a, b: a != b,
)
countymesh = Mesh()(
us,
obj=us["objects"]["counties"],
filt=lambda a, b: a != b and int(a["id"] / 1000) == int(b["id"] / 1000),
)
Output
$ python main.py
Traceback (most recent call last):
File "/tmp/topojson/main.py", line 11, in <module>
statemesh = Mesh()(
^^^^^^^
File "/tmp/topojson/.venv/lib/python3.12/site-packages/pytopojson/mesh.py", line 72, in __call__
arcs = self.mesh_arcs(topology, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/topojson/.venv/lib/python3.12/site-packages/pytopojson/mesh.py", line 63, in __call__
return {"type": "MultiLineString", "arcs": self.stitch(topology, arcs)}
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/topojson/.venv/lib/python3.12/site-packages/pytopojson/stitch.py", line 39, in __call__
fg = f if g == f else f + g
~~^~~
TypeError: unsupported operand type(s) for +: 'dict' and 'dict'
Hello, I'm trying to get the GeoJSON MultiLineString geometry object from a topojson file by following the instructions.
Environment
Script
Output