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

Tess simplification #595

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft

Tess simplification #595

wants to merge 17 commits into from

Conversation

u3ks
Copy link
Collaborator

@u3ks u3ks commented Jun 12, 2024

Adding the option to simplify the enclosed tessellations & a filtering fix

@@ -15,6 +15,7 @@
GPD_GE_013 = Version(gpd.__version__) >= Version("0.13.0")
GPD_GE_10 = Version(gpd.__version__) >= Version("1.0dev")
LPS_GE_411 = Version(libpysal.__version__) >= Version("4.11.dev")
SHPLY_GE_205 = Version(shapely.__version__) >= Version("2.0.5")
Copy link
Member

Choose a reason for hiding this comment

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

This shall check for shapely 2.1. There may be 2.0.5 or 2.0.6 none of which will include it. Shapely in the dev CI env reports shapely-2.1.0.dev0+83.ge9be991

from shapely import coverage_simplify

##simplify singles here and let the threads simplify the actual tesselations
simplified = coverage_simplify(enclosures.iloc[single], 1e-1)
Copy link
Member

Choose a reason for hiding this comment

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

nope, we should not touch enclosures. They are not problematic and this will result in mismatch with streets.

@@ -252,9 +271,14 @@ def _tess(ix, poly, blg, threshold, shrink, segment, enclosure_id):
return_input=False,
as_gdf=True,
)
if to_simplify:
tess.geometry = coverage_simplify(tess.geometry, 1e-1)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
tess.geometry = coverage_simplify(tess.geometry, 1e-1)
tess.geometry = coverage_simplify(tess.geometry, 1e-1, simplify_boundary=False)

Otherwise you break contiguity and match with streets

Comment on lines 279 to 280
if to_simplify:
poly = coverage_simplify(poly, 1e-1)
Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 30.76923% with 18 lines in your changes missing coverage. Please review.

Project coverage is 97.5%. Comparing base (4037c70) to head (2ba9442).
Report is 84 commits behind head on main.

Files with missing lines Patch % Lines
momepy/functional/tests/test_elements.py 21.1% 15 Missing ⚠️
momepy/functional/_elements.py 57.1% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #595     +/-   ##
=======================================
+ Coverage   97.4%   97.5%   +0.1%     
=======================================
  Files         26      38     +12     
  Lines       4328    6341   +2013     
=======================================
+ Hits        4214    6180   +1966     
- Misses       114     161     +47     
Files with missing lines Coverage Δ
momepy/functional/_elements.py 96.1% <57.1%> (ø)
momepy/functional/tests/test_elements.py 91.8% <21.1%> (ø)


if len(blg) > 1:
if len(blg) >= 1:
Copy link
Member

Choose a reason for hiding this comment

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

if else please

Comment on lines 265 to 267
from shapely import coverage_simplify

tess.geometry = coverage_simplify(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
from shapely import coverage_simplify
tess.geometry = coverage_simplify(
tess.geometry = shapely.coverage_simplify(

We do import shapely on top

@martinfleis
Copy link
Member

Please split simplification and the fix into two distinct PRs. The former will wait until we get shapely.coverage_simplify merged, while the latter shall be merged now.

@u3ks u3ks changed the title Tess single building & simplification Tess simplification Jun 20, 2024
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