maptrace icon indicating copy to clipboard operation
maptrace copied to clipboard

Error in Example pa-counties.png

Open RRYontz opened this issue 3 years ago • 1 comments

Glad to see that last update was a few months back and the project is not completely dead. I am having an issue replicating the pa-counties.svg from the examples provided in the README.md. Below is the traceback I get on the error when running maptrace.

Traceback (most recent call last):
  File "/home/reese/Projects/python/maptrace/maptrace.py", line 1264, in <module>
    main()
  File "/home/reese/Projects/python/maptrace/maptrace.py", line 1248, in main
    num_labels, labels, slices, colors = get_labels_and_colors_outlined(mask, opts)
  File "/home/reese/Projects/python/maptrace/maptrace.py", line 730, in get_labels_and_colors_outlined
    save_debug_image(opts, 'regions', colors[labels])
IndexError: index 81 is out of bounds for axis 0 with size 71

While my python skills are not very good, I tried looking through those section and nothing obvious stood out to me. Poking around and trying a few different things, it looks like the issue may be something surrounding the new '-S' option that was added in September 2020. Still testing and debugging.

RRYontz avatar Jan 31 '21 22:01 RRYontz

using python 3.8, as soon as some labels are removed in the get_labels_and_colors_outlined(), the index error will show up.

if opts.min_area > areas[-1]:
    print('killing all labels with area < {} px'.format(opts.min_area))
    kill_labels = np.nonzero(areas < opts.min_area)[0]
    num_labels = kill_labels.min()
    kill_mask = (labels > num_labels)
    save_debug_image(opts, 'kill_labels', kill_mask)
    unlabeled = unlabeled | kill_mask
    print('killed {} labels, now at {} total'.format(len(kill_labels), num_labels))

klankschap avatar Apr 11 '21 09:04 klankschap