Skip to content

Handle NaN coords in assign_nearest_z - #176

Merged
JuhoErvasti merged 7 commits into
mainfrom
perf-assign_nearest_z
Oct 22, 2026
Merged

JuhoErvasti merged 7 commits into
mainfrom
perf-assign_nearest_z

Conversation

@JuhoErvasti

Copy link
Copy Markdown
Collaborator

Description

If target_gdf has NaN, assign those from the source_gdf even if overwrite_z is off.

Also optimize the function (about 3x faster with just 1 worker thread)

Type of change

  • Bug fix

  • New feature

  • Other

  • Non-breaking change

  • Breaking change

Developer checklist

  • A CHANGELOG entry has been included (only when change is visible to users)

@JuhoErvasti
JuhoErvasti requested a review from rnousia October 22, 2026 09:56
@JuhoErvasti JuhoErvasti reopened this Oct 22, 2026
@JuhoErvasti
JuhoErvasti removed the request for review from rnousia October 22, 2026 10:31
@github-actions

Copy link
Copy Markdown

Benchmark Change Report

Comparing perf-assign_nearest_z against main (threshold at ±25.0)

No benchmarks changed by more than ±25.0%.

Does not pass threshold
Benchmark Base Mean PR Mean Change Status
test_count_connections[5000] 16.73 ms 19.25 ms +15.07%
test_count_connections[10000] 42.77 ms 48.86 ms +14.23%
test_gaussian_smooth[100000] 7.16 ms 8.01 ms +11.94%
test_get_line_connection_points[10000] 7.73 ms 8.57 ms +10.93%
test_merge_connecting_lines_by_attribute[1000] 18.87 ms 20.41 ms +8.17%
test_merge_connecting_lines_by_attribute[5000] 81.97 ms 88.57 ms +8.05%
test_generalize_slopelines 10.36 ms 11.15 ms +7.63%
test_gaussian_smooth[1000000] 79.66 ms 84.95 ms +6.64%
test_add_contiguous_lines_information[1000] 5.37 ms 5.60 ms +4.28%
test_get_line_connection_points[1000] 782.37 µs 810.94 µs +3.65%
test_generalize_cliffs 14.48 ms 14.99 ms +3.52%
test_get_contiguous_lengths[5000] 8.26 ms 8.55 ms +3.51%
test_flag_connections[5000] 17.19 ms 17.80 ms +3.50%
test_get_topological_points[10000] 7.32 ms 7.57 ms +3.34%
test_get_line_connection_points[5000] 3.80 ms 3.92 ms +3.02%
test_flag_connections[10000] 44.98 ms 46.25 ms +2.82%
test_generalize_shared_paths 2.782 s 2.858 s +2.73%
test_count_connections[100] 625.01 µs 641.76 µs +2.68%
test_concatenate_lines 685.00 µs 700.90 µs +2.32%
test_flag_connections[100] 628.46 µs 642.92 µs +2.30%
test_add_contiguous_lines_information[10000] 61.09 ms 62.50 ms +2.30%
test_gaussian_smooth[30000] 2.36 ms 2.40 ms +1.89%
test_flag_connections_to_reference 14.35 ms 14.61 ms +1.83%
test_get_topological_points[100] 138.96 µs 141.47 µs +1.80%
test_flag_connections[1000] 2.88 ms 2.92 ms +1.32%
test_get_line_connection_points_roads 1.36 ms 1.38 ms +1.31%
test_gaussian_smooth[10000000] 1.228 s 1.244 s +1.29%
test_get_contiguous_lengths[100] 484.29 µs 489.43 µs +1.06%
test_substring 118.25 µs 119.47 µs +1.03%
test_merge_connecting_lines_by_attribute[10000] 174.01 ms 175.56 ms +0.89%
test_keep_intersection[polygons] 16.95 ms 17.09 ms +0.82%
test_gaussian_smooth[1000] 325.65 µs 328.24 µs +0.80%
test_add_contiguous_lines_information[100] 1.50 ms 1.51 ms +0.66%
test_generalize_address_points 242.73 ms 244.04 ms +0.54%
test_get_contiguous_lengths[10000] 17.16 ms 17.25 ms +0.51%
test_get_contiguous_lengths[1000] 1.68 ms 1.69 ms +0.22%
test_get_topological_points_roads 2.87 ms 2.88 ms +0.09%
test_gaussian_smooth[10000] 972.36 µs 972.75 µs +0.04%
test_merge_connecting_lines_by_attribute[100] 4.92 ms 4.92 ms +0.03%
test_assign_z_from_attribute 4.08 ms 4.08 ms -0.08%
test_get_topological_points[1000] 698.40 µs 695.28 µs -0.45%
test_generalize_watercourse_areas 6.606 s 6.574 s -0.47%
test_get_topological_points[5000] 3.55 ms 3.53 ms -0.51%
test_generalize_points[aggfunc] 16.48 ms 16.37 ms -0.67%
test_generalize_conservation_areas 17.596 s 17.456 s -0.79%
test_generalize_watercourse_lines 840.02 ms 832.13 ms -0.94%
test_generalize_points[displacement] 341.83 ms 338.37 ms -1.01%
test_generalize_buildings_100k 6.821 s 6.746 s -1.10%
test_keep_intersection[points] 15.01 ms 14.80 ms -1.39%
test_generalize_roads 11.24 ms 11.08 ms -1.42%
test_generalize_power_lines 4.173 s 4.098 s -1.80%
test_generalize_points[points] 16.26 ms 15.95 ms -1.89%
test_generalize_contours 100.72 ms 98.67 ms -2.03%
test_generalize_landcover 8.897 s 8.711 s -2.09%
test_generalize_railroads 1.646 s 1.609 s -2.21%
test_keep_intersection[lines] 15.50 ms 15.16 ms -2.22%
test_remove_overlap[polygons] 13.44 ms 13.14 ms -2.26%
test_generalize_polygons_to_points 2.04 ms 1.98 ms -2.76%
test_get_line_connection_points[100] 194.09 µs 187.86 µs -3.21%
test_add_contiguous_lines_information[5000] 29.29 ms 28.31 ms -3.35%
test_remove_overlap[lines] 12.04 ms 11.62 ms -3.50%
test_thin_points 81.03 ms 77.60 ms -4.24%
test_remove_overlap[points] 11.64 ms 11.14 ms -4.30%
test_generalize_building_areas 1.303 s 1.242 s -4.62%
test_gaussian_smooth[100] 260.63 µs 246.21 µs -5.54%
test_generalize_buildings_50k 19.965 s 18.792 s -5.87%
test_generalize_fences 842.18 ms 791.64 ms -6.00%
test_dissolve_polygons 21.42 ms 19.83 ms -7.45%
test_generalize_water_areas 1.480 s 1.295 s -12.47%
test_count_connections[1000] 3.06 ms 2.67 ms -12.76%

@github-actions

Copy link
Copy Markdown

Benchmark Change Report

Comparing perf-assign_nearest_z against main (threshold at ±25.0)

No benchmarks changed by more than ±25.0%.

Does not pass threshold
Benchmark Base Mean PR Mean Change Status
test_flag_connections[1000] 2.86 ms 2.97 ms +3.65%
test_get_contiguous_lengths[10000] 16.24 ms 16.51 ms +1.67%
test_generalize_contours 96.89 ms 98.20 ms +1.35%
test_generalize_conservation_areas 16.950 s 17.166 s +1.27%
test_get_topological_points[100] 136.01 µs 137.23 µs +0.90%
test_generalize_polygons_to_points 1.94 ms 1.95 ms +0.63%
test_get_contiguous_lengths[1000] 1.64 ms 1.64 ms -0.07%
test_generalize_buildings_50k 18.846 s 18.793 s -0.28%
test_gaussian_smooth[30000] 2.28 ms 2.28 ms -0.32%
test_get_topological_points[1000] 669.24 µs 666.96 µs -0.34%
test_generalize_buildings_100k 6.708 s 6.678 s -0.44%
test_merge_connecting_lines_by_attribute[10000] 167.27 ms 166.04 ms -0.73%
test_add_contiguous_lines_information[100] 1.44 ms 1.43 ms -0.75%
test_get_line_connection_points[1000] 765.16 µs 759.34 µs -0.76%
test_generalize_power_lines 4.039 s 4.006 s -0.81%
test_get_contiguous_lengths[5000] 8.08 ms 8.00 ms -0.87%
test_gaussian_smooth[10000] 962.17 µs 952.63 µs -0.99%
test_concatenate_lines 575.92 µs 569.96 µs -1.03%
test_generalize_cliffs 15.22 ms 15.06 ms -1.04%
test_dissolve_polygons 19.70 ms 19.49 ms -1.05%
test_flag_connections[100] 612.66 µs 606.21 µs -1.05%
test_gaussian_smooth[10000000] 1.025 s 1.014 s -1.10%
test_generalize_points[displacement] 319.31 ms 315.74 ms -1.12%
test_gaussian_smooth[1000] 318.02 µs 314.40 µs -1.14%
test_count_connections[100] 616.43 µs 609.13 µs -1.18%
test_get_line_connection_points[100] 182.10 µs 179.75 µs -1.29%
test_generalize_address_points 232.09 ms 229.10 ms -1.29%
test_generalize_shared_paths 2.741 s 2.696 s -1.65%
test_generalize_roads 10.28 ms 10.11 ms -1.67%
test_get_contiguous_lengths[100] 471.05 µs 462.99 µs -1.71%
test_generalize_watercourse_lines 807.66 ms 792.24 ms -1.91%
test_gaussian_smooth[1000000] 80.17 ms 78.62 ms -1.94%
test_substring 117.71 µs 115.19 µs -2.14%
test_remove_overlap[lines] 11.49 ms 11.22 ms -2.34%
test_get_topological_points[10000] 6.82 ms 6.66 ms -2.38%
test_generalize_slopelines 9.98 ms 9.74 ms -2.40%
test_get_line_connection_points_roads 1.33 ms 1.29 ms -2.46%
test_flag_connections[5000] 16.43 ms 16.03 ms -2.47%
test_add_contiguous_lines_information[10000] 57.92 ms 56.49 ms -2.48%
test_get_topological_points[5000] 3.40 ms 3.31 ms -2.52%
test_gaussian_smooth[100] 246.47 µs 240.09 µs -2.59%
test_generalize_landcover 8.630 s 8.385 s -2.83%
test_add_contiguous_lines_information[1000] 5.20 ms 5.05 ms -2.89%
test_count_connections[1000] 2.87 ms 2.79 ms -2.92%
test_generalize_railroads 1.607 s 1.560 s -2.95%
test_merge_connecting_lines_by_attribute[5000] 85.34 ms 82.77 ms -3.01%
test_merge_connecting_lines_by_attribute[100] 4.79 ms 4.65 ms -3.04%
test_thin_points 81.13 ms 78.43 ms -3.32%
test_generalize_building_areas 1.284 s 1.241 s -3.35%
test_get_line_connection_points[5000] 3.73 ms 3.60 ms -3.36%
test_get_topological_points_roads 2.81 ms 2.72 ms -3.41%
test_generalize_fences 792.17 ms 763.36 ms -3.64%
test_remove_overlap[points] 11.15 ms 10.72 ms -3.82%
test_gaussian_smooth[100000] 7.17 ms 6.89 ms -3.95%
test_get_line_connection_points[10000] 7.46 ms 7.15 ms -4.18%
test_keep_intersection[points] 14.65 ms 14.02 ms -4.32%
test_generalize_points[points] 14.94 ms 14.28 ms -4.39%
test_generalize_points[aggfunc] 15.60 ms 14.89 ms -4.56%
test_generalize_watercourse_areas 6.400 s 6.105 s -4.61%
test_keep_intersection[lines] 15.10 ms 14.33 ms -5.08%
test_flag_connections_to_reference 13.87 ms 13.12 ms -5.42%
test_merge_connecting_lines_by_attribute[1000] 20.26 ms 19.15 ms -5.50%
test_keep_intersection[polygons] 16.66 ms 15.72 ms -5.63%
test_flag_connections[10000] 41.70 ms 39.08 ms -6.28%
test_remove_overlap[polygons] 13.38 ms 12.52 ms -6.38%
test_add_contiguous_lines_information[5000] 27.71 ms 25.67 ms -7.35%
test_assign_z_from_attribute 4.24 ms 3.90 ms -7.88%
test_count_connections[5000] 17.47 ms 15.87 ms -9.17%
test_generalize_water_areas 1.405 s 1.267 s -9.79%
test_count_connections[10000] 41.26 ms 37.17 ms -9.91%

@github-actions

Copy link
Copy Markdown

Benchmark Change Report

Comparing perf-assign_nearest_z against main (threshold at ±25.0)

No benchmarks changed by more than ±25.0%.

Does not pass threshold
Benchmark Base Mean PR Mean Change Status
test_generalize_cliffs 14.74 ms 14.98 ms +1.64%
test_generalize_slopelines 10.36 ms 10.41 ms +0.53%
test_gaussian_smooth[1000] 319.98 µs 318.53 µs -0.45%
test_generalize_shared_paths 2.858 s 2.843 s -0.50%
test_substring 116.84 µs 115.96 µs -0.76%
test_generalize_points[displacement] 311.34 ms 308.93 ms -0.78%
test_get_contiguous_lengths[100] 467.54 µs 462.93 µs -0.99%
test_get_topological_points[5000] 3.30 ms 3.27 ms -1.09%
test_generalize_conservation_areas 17.346 s 17.156 s -1.10%
test_generalize_buildings_50k 18.687 s 18.479 s -1.11%
test_gaussian_smooth[30000] 2.41 ms 2.38 ms -1.20%
test_generalize_contours 97.84 ms 96.61 ms -1.25%
test_get_line_connection_points[1000] 799.43 µs 787.20 µs -1.53%
test_gaussian_smooth[100] 242.27 µs 238.56 µs -1.53%
test_get_contiguous_lengths[1000] 1.67 ms 1.65 ms -1.53%
test_add_contiguous_lines_information[100] 1.46 ms 1.43 ms -1.71%
test_gaussian_smooth[100000] 7.91 ms 7.77 ms -1.79%
test_dissolve_polygons 19.83 ms 19.46 ms -1.85%
test_count_connections[100] 629.05 µs 617.10 µs -1.90%
test_get_line_connection_points[100] 186.32 µs 182.76 µs -1.91%
test_get_topological_points[1000] 702.15 µs 687.89 µs -2.03%
test_generalize_buildings_100k 6.629 s 6.483 s -2.20%
test_gaussian_smooth[10000] 1.01 ms 986.81 µs -2.31%
test_thin_points 80.74 ms 78.74 ms -2.47%
test_generalize_polygons_to_points 2.02 ms 1.97 ms -2.50%
test_generalize_building_areas 1.283 s 1.249 s -2.66%
test_gaussian_smooth[10000000] 1.267 s 1.233 s -2.68%
test_generalize_power_lines 4.138 s 4.018 s -2.89%
test_get_topological_points[100] 142.32 µs 138.21 µs -2.89%
test_generalize_address_points 249.30 ms 241.88 ms -2.98%
test_gaussian_smooth[1000000] 83.91 ms 81.30 ms -3.11%
test_get_line_connection_points_roads 1.39 ms 1.35 ms -3.21%
test_get_topological_points_roads 2.96 ms 2.86 ms -3.30%
test_add_contiguous_lines_information[10000] 62.40 ms 60.33 ms -3.31%
test_get_topological_points[10000] 8.07 ms 7.80 ms -3.34%
test_keep_intersection[lines] 15.70 ms 15.12 ms -3.65%
test_generalize_watercourse_lines 853.73 ms 821.99 ms -3.72%
test_remove_overlap[points] 11.89 ms 11.43 ms -3.85%
test_concatenate_lines 713.86 µs 685.12 µs -4.03%
test_get_line_connection_points[5000] 4.13 ms 3.96 ms -4.13%
test_flag_connections[100] 645.95 µs 619.10 µs -4.16%
test_generalize_roads 11.22 ms 10.75 ms -4.19%
test_generalize_watercourse_areas 6.790 s 6.499 s -4.29%
test_generalize_railroads 1.644 s 1.573 s -4.30%
test_generalize_fences 825.73 ms 790.07 ms -4.32%
test_merge_connecting_lines_by_attribute[100] 4.81 ms 4.60 ms -4.38%
test_keep_intersection[polygons] 17.31 ms 16.53 ms -4.48%
test_generalize_landcover 8.942 s 8.522 s -4.70%
test_generalize_points[aggfunc] 16.91 ms 16.07 ms -4.98%
test_get_contiguous_lengths[10000] 17.26 ms 16.37 ms -5.15%
test_remove_overlap[lines] 12.38 ms 11.71 ms -5.42%
test_flag_connections[1000] 2.98 ms 2.81 ms -5.82%
test_remove_overlap[polygons] 13.81 ms 12.99 ms -5.97%
test_get_contiguous_lengths[5000] 8.60 ms 8.08 ms -5.98%
test_keep_intersection[points] 15.74 ms 14.77 ms -6.13%
test_count_connections[10000] 46.58 ms 43.06 ms -7.57%
test_add_contiguous_lines_information[1000] 5.65 ms 5.21 ms -7.75%
test_get_line_connection_points[10000] 9.08 ms 8.31 ms -8.45%
test_add_contiguous_lines_information[5000] 30.10 ms 27.55 ms -8.49%
test_assign_z_from_attribute 4.74 ms 4.30 ms -9.13%
test_flag_connections[10000] 45.94 ms 41.59 ms -9.47%
test_generalize_points[points] 17.10 ms 15.47 ms -9.53%
test_merge_connecting_lines_by_attribute[5000] 90.59 ms 81.85 ms -9.64%
test_count_connections[5000] 18.58 ms 16.78 ms -9.65%
test_merge_connecting_lines_by_attribute[10000] 181.66 ms 163.27 ms -10.12%
test_merge_connecting_lines_by_attribute[1000] 21.16 ms 18.93 ms -10.53%
test_flag_connections[5000] 18.57 ms 16.59 ms -10.67%
test_flag_connections_to_reference 14.92 ms 13.23 ms -11.35%
test_generalize_water_areas 1.457 s 1.277 s -12.39%
test_count_connections[1000] 3.04 ms 2.63 ms -13.48%

@JuhoErvasti
JuhoErvasti merged commit 57b40a6 into main Oct 22, 2026
4 checks passed
@JuhoErvasti
JuhoErvasti deleted the perf-assign_nearest_z branch October 22, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants