Hey Jamie,
thanks for the quick reply! I'll answer the easy stuff first:
1) & 2) I'll reduce it later today and do that
3) i ran it from powershell just now, and added some logging after the first attempt, so the "create zone" bit looks like this now:
# create zones
i = 0
for idx, record in df.iterrows():
#new_zone = zones.new(record['source_id'])
new_zone = zones.new(i)
if i > 491: print(new_zone)
#new_zone = zones.new(idx + 1) # sonst: 'ValueError: Centroid IDs need to be positive'
# add data (only shows up when the whole script is run twice wtf)
z_geom = load_wkt(record['geometry'])
if i > 491: print(z_geom)
new_zone.geometry = z_geom
if i > 491: print(new_zone)
z_centroid = load_wkt(record['centroid'])
if i > 491: print(z_centroid)
new_zone.add_centroid(z_centroid)
if i > 491: print(new_zone)
new_zone.save()
if i > 491: print('saved zone', i)
i += 1
if i % 100 == 0: print(i, ' zones created, index ', idx)
zones.save()
The result in the powershell looks like the attached txt. So
- i get 496 zones today
- the script stops working when it should enter the centroid for zone 496
The log ends with:
2026-01-13 09:13:47,417;INFO ; Zone with id 495 was created
2026-01-13 09:13:47,417;INFO ; Zone with id 495 was created
2026-01-13 09:13:47,471;WARNING ; Centroid already exists. Failed to create it
2026-01-13 09:13:47,471;WARNING ; Centroid already exists. Failed to create it
2026-01-13 09:13:47,577;INFO ; Zone with id 496 was created
2026-01-13 09:13:47,577;INFO ; Zone with id 496 was created
4) I opened the database in QGIS (see attached png): It shows the osm-based network, the nodes are classified by "is_centroid" (I am doing a model of pedestrian traffic, which also has bus-stops as origins/destinations - hence the meaningless polygons). I am surprised that the database has 994 centroids; so ...
5) ...
next thing I'll try to throw these out first and see what happens.
I thought the centroids dissappear when you delete the zones like
# delete existing zones
i = 0
for z in list(zones.all_zones().keys()):
zones.get(z).delete()
i += 1
print(i, ' zones deleted')
6) It is indeed - it's my everyday and touring bike cobbled together around an old raleigh frame - now and then i like to deal with tech i can grasp ;)
Best, Tim
Op dinsdag 13 januari 2026 om 00:24:46 UTC+1 schreef Jamie Cook: