Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new features #46

Merged
merged 9 commits into from
Mar 19, 2024
Merged

Add new features #46

merged 9 commits into from
Mar 19, 2024

Conversation

SakharovGeoalert
Copy link
Contributor

No description provided.

return self.copy().cast_property_to(key, new_type, inplace=True)

def ensure_unique_ids(self, key='id', verbose: bool = False):
Copy link
Member

Choose a reason for hiding this comment

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

Looks like a very specific function, which is not needed here in the lib. Need second opinion @adeshkin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I do use it a lot. When working with multiple collections (e.g. rooftops and footprints) it is crucial to have some unique key to match features across them. And if that key is not unique (like when there are several features with same key, or some features does not have key at all), it leads to severe bugs which are difficult to detect. Thats why we need a method like this.

Copy link
Contributor

@adeshkin adeshkin Sep 12, 2023

Choose a reason for hiding this comment

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

agree with @AlexeyTrekin

return FeatureCollection((f.copy() for f in self.features), crs=self.crs)

def simplify(self, sigma, inplace=True):
Copy link
Member

Choose a reason for hiding this comment

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

  1. There is an apply() function that implements non-inplace modification like this

fc2 = fc.apply(lambda f: f.simplify(tolerance)) so i think it is not worth to add as a separate funciton.

But I love inplace switch, maybe add it to apply() - with default value False?

  1. Why sigma? In shapely it is tolerance, good to preserve it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, but fc.simplify(tolerance) looks more readable, than fc = fc.apply(lambda f: f.simplify(tolerance)), isn't it?

Copy link
Member

Choose a reason for hiding this comment

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

OK, it's good to have it.

But let's do it as a convenience function to apply():

  • add inplace parameter to apply()
  • rewrite fc.simplify via apply

@SakharovGeoalert SakharovGeoalert merged commit 4a48e19 into master Mar 19, 2024
1 check passed
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