Always good to see geospatial analysis, especially with the toolchain available in Python, these days!<p>One of the downsides of forming polygon from line segments in this way is that it implicitly assumes all lines have a vertex at the intersection of another line.<p>For example, something like this would fail ("o" represents a vertex):<p><pre><code> o o o
\ \/
\ /\
\ / \ o
\ / \ /
/ /
/ \ / \
o \ / \
\/ \
/\ o
/ \
o \
o
</code></pre>
You can handle this in a couple of ways:<p>1) Intersect the lines before-hand, ensuring that you wind up with a vertex at every intersection. (In shapely's case, you'd call `shapely.ops.cascaded_union(lines)` before applying `polygonize`.)<p>2) Cut a bounding polygon with the lines, rather than forming polygons from individual line segments.<p>The second method has the advantage of ensuring that everything inside of the bounding polygon is split up into smaller, block-level polygons. Usually this is what you want, though for something like city blocks, you'd need to filter out non-urban areas (e.g. water).
There's also the tag place=city_block [1]
which may be useful depending on its coverage but which has the advantage of being explicitly assigned by a human.<p>I've always thought of city blocks as an anti-pattern in urban layout e.g. exploring New York on foot for the first time I tried 'using my nose' to find interesting places but had the problem that I got zero incremental information until the next intersection at which point the large block size meant it was too far to turn back.<p>I prefer to live in cities for which the concept of a 'block' has less relevance, and I'd caution against trying to 'blockify' cities worldwide.<p>[1] <a href="http://wiki.openstreetmap.org/wiki/Key:place" rel="nofollow">http://wiki.openstreetmap.org/wiki/Key:place</a>
I have to keep trying to open those mapbox vector tiles. Zipped protocol buffers in a sqlite file. If you want to handle a lot of geo data, you can't keep using text. Although I wonder if protocol buffer+sqlite is really a good idea.
Looking at the visualizations provide I don't see a visual proof that the code is able to extract city blocks; by city block, I mean as defined by Wikipedia here:
<a href="https://en.m.wikipedia.org/wiki/City_block" rel="nofollow">https://en.m.wikipedia.org/wiki/City_block</a><p>Proof might be an interactive map that shows the city block of a selected area in NYC.<p>Is there a visual proof in the walkthrough I'm not seeing?