-
Notifications
You must be signed in to change notification settings - Fork 23
fix: exposing simplify from Geometry.geojson by kwargs in explore #241
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
Conversation
@MarkusZehner thanks for this. Can we make it more "finished" though. Ideally we should address #240 not just provide an undocumented work-around. I think we need The default Please ensure the following:
pinging @robbibt as the original author of |
I am running into some problems calling Geometry.points
However, |
@MarkusZehner good point, I forgot it's not that easy to find "number of points" making up an arbitrary geometry object. Just counting exterior points of a polygon is not good enough for a polygon with fractal holes within it. This approach will also break for more complex geometries like feature collections. I'm not aware of an obvious shapely method that can return number of nodes geometry is made up of. Every type has a different method for exposing point nodes it's made of, and requires marshaling all those points through C-Python interface just to reduce that back to a single number. We can probably use |
Also, please rebase against the current |
@Kirill888 how about using shapely.count_coordinates, also the resolution is dependent on crs which hinders a simple threshold. While setting up |
Optionally simplify geometries by tolerance in degrees. | ||
By default if fewer than 100 points in geometry 0.0, | ||
else min(0.05, res*0.1). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too much detail, res
is not an argument, we should not mention it, 100 is an implementation detail, also no need to mention. Mostly this will be used as simplify=0
, so explain why would one use it.
def _auto_simplify(g: Geometry) -> float: | ||
r = _auto_resolution(g.to_crs(4326)) | ||
s = 0.0 if count_coordinates(g.geom) <= 100 else min(0.05, r * 0.1) | ||
return s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't feel right:
- converting to lonlat twice
- converting even when not needed (i.e.
s=0.0
case) - function not generic enough to be at module level, or be a function at all
Maybe it makes more sense to move simplify="auto"
processing into .geojson
method
See #248 instead |
Fix for issue #240
Simple workaround to expose simplify to the explore function.