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

momepy.Tessellation returns empty rows when buildings are outside of enclosures #286

Closed
matthew-law opened this issue Jul 29, 2021 · 2 comments
Labels
good first issue Good for newcomers
Milestone

Comments

@matthew-law
Copy link
Contributor

This isn't a bug as such, but it is the root cause of an error that's taken me ages to get to the bottom of and could potentially benefit from a warning (if this isn't too difficult to implement).

When generating an enclosed tessellation with momepy.Tessellation, on occasion some of my resulting geodataframes will have seemingly empty rows. After much investigation, I've realised that it's because the procedure I was following (using a small subset of my data for quick prototyping) led me to pass momepy.Tessellation a set of enclosures, and a set of buildings which included some outside of these enclosures. This was an error on my part, but it didn't stop momepy.Tessellation from running and passed unnoticed until much further down the line, by which point it wasn't obvious where the eventual error was coming from.

Here is a notebook showing what I did and the issue that resulted – the main 'error' (although it's not quite that) can be seen in the difference between these two valid and invalid/empty cells:

image

It's an edge case issue (eg this wouldn't happen if I'd used the city boundary as the edge of the enclosures and not a convex hull around the streets) and not an error as such, but it's taken me sufficiently long to get to the bottom of that I thought it worth flagging up!

@martinfleis
Copy link
Member

Thanks, that is a good point.

I'd say that the optimal solution would be to drop these empty columns. There will never be any geometry anyway. If you want to do a PR and add this check&drop after this line, that'd be very welcome.

https://github.com/martinfleis/momepy/blob/1ddb296fe3e2f17db77c2b20df6f16f89943deca/momepy/elements.py#L503

@martinfleis martinfleis added this to the 0.5.0 milestone Aug 6, 2021
@martinfleis martinfleis added the good first issue Good for newcomers label Aug 6, 2021
@martinfleis
Copy link
Member

Hey, I'll close this as they are no empty rows in the resulting tessellation. Rows for buildings outside of enclosures are not present at all. When you do enclosed_tess["uID"] == 2169, it returns all False, hence empty dataframe if you use it as indexer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants