The create_geojson function in viz_utils.py throws an KeyError error because cid is always a list or tuple. The error occurs because the code attempts to directly use cid as a key to the lookup dict, leading to incorrect handling and subsequent failures.
Error Message:
Traceback (most recent call last):
File "path/to/main.py", line 232, in <module>
main(params)
File "path/to/main.py", line 117, in main
z_pp = post_process_main(
^^^^^^^^^^^^^^^^^^
File "path/to/src/post_process.py", line 95, in post_process_main
create_polygon_output(pinst_out, pcls_out, params["output_dir"], params)
File "path/to/src/viz_utils.py", line 118, in create_polygon_output
create_geojson(
File "path/to/src/viz_utils.py", line 34, in create_geojson
"name": lookup[cid],
~~~~~~^^^^^
KeyError: (6, (1248.144578313253, 9795.885542168675))
Suggested Fix:
Checking classids is a list/tuple and extracting the first element of cid.
I think the polygon/geojson output needs to be properly integrated, perhaps already at class-assignment so that this re-search of all objects is not necessary.
Description:
The
create_geojson
function inviz_utils.py
throws anKeyError
error becausecid
is always a list or tuple. The error occurs because the code attempts to directly usecid
as a key to the lookup dict, leading to incorrect handling and subsequent failures.Error Message:
Suggested Fix:
Checking
classids
is a list/tuple and extracting the first element ofcid
.Current Code:
Proposed Code: