TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Extracting city blocks from OpenStreetMap data

151 pointsby p8donaldalmost 9 years ago

5 comments

joferalmost 9 years ago
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 (&quot;o&quot; represents a vertex):<p><pre><code> o o o \ \&#x2F; \ &#x2F;\ \ &#x2F; \ o \ &#x2F; \ &#x2F; &#x2F; &#x2F; &#x2F; \ &#x2F; \ o \ &#x2F; \ \&#x2F; \ &#x2F;\ o &#x2F; \ 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&#x27;s case, you&#x27;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&#x27;d need to filter out non-urban areas (e.g. water).
评论 #12270217 未加载
评论 #12269393 未加载
评论 #12271561 未加载
muxxaalmost 9 years ago
There&#x27;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&#x27;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 &#x27;using my nose&#x27; 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 &#x27;block&#x27; has less relevance, and I&#x27;d caution against trying to &#x27;blockify&#x27; cities worldwide.<p>[1] <a href="http:&#x2F;&#x2F;wiki.openstreetmap.org&#x2F;wiki&#x2F;Key:place" rel="nofollow">http:&#x2F;&#x2F;wiki.openstreetmap.org&#x2F;wiki&#x2F;Key:place</a>
jokoonalmost 9 years ago
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&#x27;t keep using text. Although I wonder if protocol buffer+sqlite is really a good idea.
评论 #12270817 未加载
nxzeroalmost 9 years ago
Looking at the visualizations provide I don&#x27;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:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;City_block" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;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&#x27;m not seeing?
评论 #12268979 未加载
marcodenaalmost 9 years ago
Nice, could you try it with an irregular city? Like Rome?<p>thx
评论 #12269930 未加载