-
Notifications
You must be signed in to change notification settings - Fork 120
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
Building merging #1689
Building merging #1689
Conversation
Nice! Huge file savings :)
For zoom 15 can I see a variant where we don’t combine the city buildings
in a “block”?
I do like the effect, but it tends to deemphasize the real world large
buildings. Are the real big buildings still notes so they could be called
out?
For zoom 16 historically we didn’t do dropping at this max zoom, can you
add details on this change? I’m curious how it effects the flower sculpture
building near the ferry building in SF and tiny backyard sheds in Daily
City south of SF.
|
Sure! But I'm not sure what you want to see. Some options:
Personally, I think that's a good trade-off for getting a better visual sense of the building density. Perhaps we could de-emphasise the "city blocks" in the style - for example, to use a less contrasting outline colour for buildings less than 50m in height or similar. Here's the view at zoom 15.9, and the tall buildings still stand out a lot from the background.
The changes should only have affected the - &z16_area_volume
- any:
- way_area: { min: 25 }
- volume: { min: 50000 }
+ way_area: { min: 10 } I'll go and check why there was a change in size at z16 - I wonder if perhaps I did the old/new test with different dates. |
Ah, that’s a good tip Re 50 meter height, that’s probably enough - good
demo image! I’d probably go farther and remove extrusion on those entirely
and stack under roads and then it’s fine client side.
Can you add screenshot sequences for SF and DC and Paris, please? They have
different urban patterns.
I wonder if for zoom 15 we should do larger dilation on the buffer to
reduce exterior details, and use large px value for dropper inners?
|
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.
Put in some questions/comments, but it looks good to me!
13: vectordatasource.transform.quantize_height_round_nearest_20_meters | ||
14: vectordatasource.transform.quantize_height_round_nearest_10_meters | ||
15: vectordatasource.transform.quantize_height_round_nearest_10_meters | ||
# todo: keep instead of drop? |
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.
I think keep/drop just depends on what's easier. IIRC the list of properties that are included on buildings are done so via a whitelist type of mechanism anyway, ie new properties won't suddenly appear to prevent merging, right? But in terms of what side we want to err on, a whitelist feels safer in that I think we'd prefer to merge if we forgot to update this list if we added another property, rather than stop merging because a new property was added. Anyway, just my thinking on this, either way feels fine to me.
# NOTE: max_merged_features is set to keep the time taken for geometry | ||
# merging down, as it seems to go up with the square of the number of | ||
# features. | ||
max_merged_features: 2000 |
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.
Wouldn't this mean that the size of the tile would stay larger than we'd like though? And would we want to try another strategy in these cases, like drop some buildings from even appearing that don't rank high enough (not sure this is possible), or increase the buffer size we are using? Maybe it's smarter to leave it and just track this somehow so after runs we can see which tiles triggered the max?
params: | ||
end_zoom: 15 | ||
source_layers: [buildings] | ||
pixel_area: 0.25 |
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.
Great idea!
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.
How is this different than line 962? We should only do this procedure once.
path: spreadsheets/scale_rank/buildings.csv | ||
params: | ||
source_layer: buildings | ||
target_value_type: int |
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.
Nice catch here.
source_layer: buildings | ||
start_zoom: 14 | ||
end_zoom: 15 | ||
where: scale_rank > 3 |
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 makes sense to drop afterwards, but is it crazy to initially drop some of the smaller buildings too to cut down on the candidates we need to consider for merging? Or is this actually counterproductive because it might cut down on the merging that we can actually do? Does the drop smaller inners handle this well enough anyway?
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.
It's more "coherent" to operate on the entire urban fabric... but agree it can result in large aggregate polygons that would otherwise have been dropped as smaller inputs. Generally they'll still have low height and can be filtered client-side, or we could later drop them server-side if we need more file size savings.
# round the smallest values up to the first step. | ||
if val < step: | ||
return int(step) | ||
|
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.
Great catch!
vectordatasource/transform.py
Outdated
assert isinstance(merger, RecursiveMerger) | ||
|
||
# don't keep recursing. if we haven't been able to get to a smaller number | ||
# of shaped by 5 levels down, then perhaps there are particularly large |
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.
# of shapes
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.
Good catch of typo
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.
Yup, well spotted, thanks! Fixed in 937023c.
# this formula seems to give a good balance between larger values, which | ||
# merge more but can merge everything into a blob if too large, and small | ||
# values which retain detail. | ||
tolerance = min(5, 0.4 * tolerance_for_zoom(zoom)) |
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.
⚡
Excited to see more work here! What's up with the (over-)simplification on that z15.9 screen? Existing or unrelated? And I'm sorry you remind me again about "nominal" zoom :) Is that the "display" zoom, or the underlying 512px tile zoom? My main interest here is ensuring that we have the full detail (for some definition) at the max tile zoom (sounds like that is addressed in comments). But to confirm, this would drastically reduce the buildings in a z14 view like this, right? |
Oops. That's an new error we should fix in this PR.
Yes, it's just too much data and file size at zoom 14, even after doing the generalization we see in zoom 15 example by combining the buildings in a city block. |
I think that's partly existing, although highlighted by the larger number of visible buildings now: However, there are some differences: for example, the two "H" shaped buildings above and to the right of the bend in Avenida Professor Alfonso Bovero (above where "Bovero" is in the right image). The new tile has a mangled version and the master version looks better. There are a bunch of places where they look about as bad as eachother, though. |
Yep, I've liked having higher building density available (and I think this is still considerably more at z15 than Mapbox?), but totally agree tile size needs to come down for typical base map cases (though may indicate the future value of a couple different tile flavors with more/less feature density, or you know, true "raw" tiles...). I am interested to also see if there is a noticeable improvement in tile build time from reduced feature processing (even in the cases where they are not displayed)! Let me know when an endpoint is available :) |
I re-ran the last run with a clean working copy. Looks like I must have had some local mods I'd forgotten about, because the results are different. (Although I'm going to check again, to make sure this is reproducible). I'll also do some runs in SF, Washington DC & Paris.
Zoom 14Zoom 15Zoom 16 |
San FranciscoSan Francisco does pretty well. Like São Paulo, there's a lot of "blocks" which can be merged at zoom 15 nominal. Overall results:
Zoom 14Zoom 15Zoom 16Washington DCDowntown DC has a lot of big buildings, most of which don't need any kind of merging. Outside those blocks of large buildings, the other blocks also seem to merge well, until we reach the suburbs. Overall results:
Zoom 14Zoom 15Zoom 16Georgetown InterludeJust outside DC, in the evocatively named Foxhall Village, there are a lot of detached houses, which don't get merged at all. However, it looks like we're still getting a decent reduction in size (about 80% rather than 90%, but coming from a lower base), perhaps due to more aggressive geometry simplification. The lack of individual large buildings means the buildings layer for this tile is almost empty at zoom 14 nominal. Overall results:
Zoom 15Zoom 16ParisParis seems to have a lot of buildings with inner courtyards or other non-rectangular features which result in many inners in the merged blocks at zoom 15 nominal. Perhaps the tolerance for dropping small inners needs to be increased to remove most of these? Overall results:
Zoom 14Zoom 15Zoom 16 |
Overall this feels like a good improvement and I think we should go forward with it as-is... after confirming we're not regressing zoom 16 as the Ferry Building in SF is missing it's tower and DC buildings look generalized... and file a followup issue to drop small courtyards at zoom 15. For Brazil zoom 15, it still feels like we're cluttering up the tile with "fake" low rise buildings: In San Francisco also at zoom 15: I see some merging... but overall too many small features: At zoom 16 in SF we seem to have lost the tower detail on the Ferry Building right along the water?! Please ensure there's not an off-by-one problem here before merging. In DC at zoom 15 it is aggregating row houses like I'd expect, so that's a vote to keep it as proposed in this PR: Zoom 16 in DC also feels over generalized, did that change in this PR? Zoom 15 in Georgetown does look nice! Zoom 15 in Paris feels like we could stand dropping small inner courtyards, but otherwise looks good: |
params: | ||
end_zoom: 15 | ||
source_layers: [buildings] | ||
pixel_area: 0.25 |
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.
Could make this 0.5 or 1? But let's track that with a new issue and merge this as-is.
|
We are, deliberately. We have one pass of dropping inners before the merge and another after the merge. The first is just to make life simpler for the merge; some things which were multipolygons are now simple polygons, which is much easier (and computationally cheaper) for the dilate / buffer algorithm to handle. The pass after merging is to because the merging process itself sometimes creates courtyards when merging adjacent buildings (e.g: neighbouring buildings like |
Instead of dropping small buildings and being left with a lot of individual buildings to merge, instead keep the small buildings and try to merge into city blocks by dropping more properties and quantizing height. Small gaps between buildings and internal courtyards are also dropped, leaving larger individual polygons.
… Refactor feature merging to support different ops at different parts of the hierarchical merge. This isn't used yet - but will be useful when we want to merge between blocks.
…similar and avoid blobbyness.
937023c
to
2ea6a68
Compare
And a closer read of the comments say that, sorry for the noise! |
Follow-up for a re-visit to drop more courtyards in #1696. |
PS: We also talked about the Ferry Building, and how the tower isn't visible in the new tiles. This is because the building footprint has We've seen a similar issue before with the Fernsehturm in Berlin #1274 and a sort-of similar issue with the Bank of England #1032. And it looks like the plan would be to add the Not adding a follow-up for this, as I think #1274 has it covered. |
Connects to #1686.
Better building merging, resulting in fewer polygons at zooms 14 & 15 (nominal). In summary, the buildings layer size is drastically reduced:
13/3033/4647
14/6067/9294
15/12134/18589
Zoom 14
Ignore the grey area to the south and west; that's just because I didn't render those tiles. The visual output is very similar to the style before, as we are now dropping buildings which weren't rendered anyway.
Zoom 15
At this zoom, we're now doing much more merging, and in most dense areas we now merge into single "city block" polygons.
Zoom 16
Zoom 16 is almost unfiltered, but we do now drop a few of the very small polygons.
Changes
short_name
,osm_relation
) to enable better merging.Overall, this leads to much less detail in the buildings layer, but this detail isn't really visible at zooms 14 and 15 anyway. The plus side is that we now include many more "city block" polygons to give better visual texture to cities.