{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": "# Example for the concept of LGU\n\nThis notebook shows how tessellation and its functionalities can help to create Local Geographic Units. Local Geographic Units are the combination of spatial discretization with additional information assigned to each tile. This concept makes further analysis easy." }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": "from tesspy import Tessellation\nfrom tesspy import count_poi_per_tile\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport contextily as ctx" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Tessellation\n", "\n", "First, we define a tessellation area. In the case Frankfurt am Main and Nairobi are chosen as case study.\n", "A regular tessellation method, i.e., hexagons, and an irregular method, i.e., city blocks, are used." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "ffm = Tessellation(\"Frankfurt am Main\")\n", "africa = Tessellation(\"Nairobi\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "africa_hex = africa.hexagons(resolution=9)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "MultiPolygon found. Splitting it up...\n" ] } ], "source": [ "ffm_cb = ffm.city_blocks(n_polygons=1000)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Creating LGU datasets\n", "\n", "Using the function `count_poi_per_tile`, an LGU dataset is created based on the tessellation and additional information (POI). " ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "gdf_africa_hex = count_poi_per_tile(\"Nairobi\", africa_hex, poi_categories=[\"amenity\",\"building\"])\n", "gdf_ffm_cb = count_poi_per_tile(\"Frankfurt\", ffm_cb, poi_categories=[\"amenity\",\"leisure\", \"office\"])" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | cityblock_id | \n", "geometry | \n", "amenity | \n", "leisure | \n", "office | \n", "
|---|---|---|---|---|---|
| 0 | \n", "cityblockID0 | \n", "POLYGON ((8.68230 50.10893, 8.68232 50.10887, ... | \n", "74.0 | \n", "1.0 | \n", "2.0 | \n", "
| 1 | \n", "cityblockID1 | \n", "POLYGON ((8.67928 50.10815, 8.67876 50.10797, ... | \n", "60.0 | \n", "1.0 | \n", "1.0 | \n", "
| 2 | \n", "cityblockID2 | \n", "POLYGON ((8.68671 50.11190, 8.68670 50.11194, ... | \n", "175.0 | \n", "3.0 | \n", "7.0 | \n", "
| 3 | \n", "cityblockID3 | \n", "POLYGON ((8.69298 50.11307, 8.69298 50.11309, ... | \n", "95.0 | \n", "10.0 | \n", "4.0 | \n", "
| 4 | \n", "cityblockID4 | \n", "POLYGON ((8.68545 50.10926, 8.68522 50.10925, ... | \n", "40.0 | \n", "1.0 | \n", "0.0 | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 1383 | \n", "cityblockID1383 | \n", "POLYGON ((8.59033 50.03088, 8.59031 50.03080, ... | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "
| 1384 | \n", "cityblockID1384 | \n", "POLYGON ((8.60164 50.04618, 8.60279 50.04852, ... | \n", "2.0 | \n", "0.0 | \n", "0.0 | \n", "
| 1385 | \n", "cityblockID1385 | \n", "POLYGON ((8.60788 50.04855, 8.60787 50.04857, ... | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "
| 1386 | \n", "cityblockID1386 | \n", "POLYGON ((8.58302 50.02316, 8.58270 50.02307, ... | \n", "3.0 | \n", "0.0 | \n", "1.0 | \n", "
| 1387 | \n", "cityblockID1387 | \n", "POLYGON ((8.58384 50.02264, 8.58339 50.02278, ... | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "
1388 rows × 5 columns
\n", "| \n", " | hex_id | \n", "geometry | \n", "amenity | \n", "building | \n", "
|---|---|---|---|---|
| 0 | \n", "897a6e54c37ffff | \n", "POLYGON ((36.72584 -1.36099, 36.72588 -1.35910... | \n", "3.0 | \n", "64.0 | \n", "
| 1 | \n", "897a6e47117ffff | \n", "POLYGON ((36.73657 -1.24548, 36.73661 -1.24360... | \n", "0.0 | \n", "0.0 | \n", "
| 2 | \n", "897a6e5a343ffff | \n", "POLYGON ((37.03414 -1.27108, 37.03418 -1.26920... | \n", "0.0 | \n", "0.0 | \n", "
| 3 | \n", "897a6e5505bffff | \n", "POLYGON ((36.83938 -1.32114, 36.83942 -1.31926... | \n", "11.0 | \n", "65.0 | \n", "
| 4 | \n", "897a6e5408bffff | \n", "POLYGON ((36.78535 -1.36950, 36.78539 -1.36761... | \n", "0.0 | \n", "0.0 | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 6328 | \n", "897a6e50817ffff | \n", "POLYGON ((36.88515 -1.35163, 36.88519 -1.34974... | \n", "0.0 | \n", "0.0 | \n", "
| 6329 | \n", "897a6e54c6fffff | \n", "POLYGON ((36.73271 -1.34999, 36.73275 -1.34811... | \n", "0.0 | \n", "45.0 | \n", "
| 6330 | \n", "897a6e51153ffff | \n", "POLYGON ((36.97667 -1.33054, 36.97671 -1.32866... | \n", "0.0 | \n", "0.0 | \n", "
| 6331 | \n", "897a6e40387ffff | \n", "POLYGON ((36.85312 -1.21716, 36.85316 -1.21527... | \n", "0.0 | \n", "33.0 | \n", "
| 6332 | \n", "897a6e0966bffff | \n", "POLYGON ((36.69048 -1.30834, 36.69052 -1.30646... | \n", "0.0 | \n", "0.0 | \n", "
6333 rows × 4 columns
\n", "