Urban Grammar AI
This blog post covers some of the efforts the team has made to contribute code developed for the project to the broader Python eco-system for (geographic) data science. Processing of data within WP1 and morphometric assessment within WP2 entail the development of new bespoke algorithms and implementation of some which are currently available in the Python ecosystem. However, even those already existing were often not performant enough for the scale of this project.
As part of the data processing stage of the project, we have refactored some of them to gain the performance enhancements we needed. Since we strongly believe in replicability of research, all software developed within Urban Grammar AI project should be available for other researchers, optimally packaged in a friendly shape of a Python library. At the same time, we want to support open-source software which we use for the research.
We think the natural approach is to include enhancements made within the area of urban morphometrics to momepy an existing toolkit for urban morphology. WP2 heavily builds on momepy’s code and every relevant piece of code we made is now merged back into momepy. That covers both performance-focused changes to implementation (#219, #209, #207, #205), mostly based on pygeos and vectorization, and new additions.
Two key features of Spatial Signatures, the concepts of enclosures and enclosed tessellation are now available in momepy.elements module and you can create both using only a few lines of code:
enclosures = momepy.enclosures(
streets, limit=gpd.GeoSeries([convex_hull]), additional_barriers=[railway, rivers])
enclosed_tessellation = momepy.Tessellation(
buildings, unique_id='uID', enclosures=enclosures).tessellation
See the detailed guidance in momepy’s documentation.
Tools we used to preprocess street network and railway tracks before creating enclosures for a core of a new module momepy.preprocessing, where you can find them as momepy.remove_false_nodes, momepy.close_gaps and momepy.extend_lines. To measure percentiles used as a convolution layer for delineation of Spatial Signatures, you can use momepy.Percentiles and to link enclosed tessellation to street network, there is a new function momepy.get_network_ratio.
The complete list of pull requests implementing code resulting from Urban Grammar AI is below:
#219 REF: vectorize StreetProfile
#218 ENH: ratio-based network links
#217 ENH: extend_lines
#215 ENH: Close gaps
#214 REF: preprocessing module
#213 API: unified Tessellation
#212 ENH: Enclosed tessellation
#211 ENH: add enclosures function
#209 ENH: speedups, Percentiles
#207 REF: pygeos-based Tessellation
#205 ENH: faster circular compactness
#204 ENH: vectorised remove_false_nodes