Skip to content

Comments

Refactor buildings algorithm#46

Merged
JuhoErvasti merged 16 commits intomainfrom
refactor-buildings
Jan 9, 2026
Merged

Refactor buildings algorithm#46
JuhoErvasti merged 16 commits intomainfrom
refactor-buildings

Conversation

@JuhoErvasti
Copy link
Collaborator

@JuhoErvasti JuhoErvasti commented Dec 5, 2025

Description

Refactor buildings algorithm to use BaseAlgorithm and to support identity i.e. dataframe index is used for operations where a separate unique_key_column was used previously. Also merged buildings get a hashed index.

Includes the commits from #43. Building on the changes there dissolve_and_inherit_attributes can now inherit attributes from the feature with the most intersection with the dissolved geometry. This is now the default, and the previous "minimum index" behavior is left as an option.

Includes some new features for index handling in new modules identity and split. I didn't end up using some of the functions here but I think they'd be useful to have for future use (for instance with watercourse areas).

Some small changes had to be made for the 100k test dataset, this was because the aforementioned changes to how attributes are inherited affected which buildings turn to points and which points were reduced. There were 3 affected features in total, and running the refactored algorithm with the original attributes produced the same result, so I believe it was caused purely because of the dissolving changes. I think this is an acceptable change as the new inheritance method seems more logical to use for buildings.

TODO (I think these can be done in a different PR):

  • Handling Z values (inherit from nearest, and each vertex in a geometry should get the same, smallest value)
  • Allow entering these with the CLI:
    • classes_for_low_priority_buildings
    • classes_for_point_buildings
    • classes_for_always_kept_buildings
    • This is currently not possible because there can be multiple of them and they can be either int or str which typer doesn't support

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 nmaarnio December 5, 2025 18:46
@JuhoErvasti JuhoErvasti mentioned this pull request Dec 18, 2025
6 tasks
@JuhoErvasti JuhoErvasti removed the request for review from nmaarnio January 7, 2026 13:33
nmaarnio and others added 14 commits January 8, 2026 15:42
dissolve_members_column was removed since its purpose was basically
the same as old_ids column. unique_key_column parameter was removed
and IDs are assumed to be input GDFs index.
Test were adapted to changes introduced by new ID handling
and tests specific to the removed dissolve_members_column
were removed.
Attributes can now be inherited from feature with most intersecting area
with the dissolved geometry, in addition to picking the feature with the
minimum id. Inheriting from the feature with most intersecting area is
the default option.
Copy link
Collaborator

@rnousia rnousia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the performance (lots of union_all operations) but we can improve that later

choose generic english terms for default values, avoid unnecessary
union_all and copy calls
@JuhoErvasti
Copy link
Collaborator Author

@rnousia Ready for another round.

@rnousia
Copy link
Collaborator

rnousia commented Jan 9, 2026

Looking good, good to go!

@JuhoErvasti JuhoErvasti merged commit 38db683 into main Jan 9, 2026
3 checks passed
@JuhoErvasti JuhoErvasti deleted the refactor-buildings branch January 9, 2026 13:08
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.

3 participants