-
-
Save paleolimbot/4bbfaf9dd79a306e21e59156004c7e33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Get some bigish data to work with:\n", | |
"\n", | |
"```shell\n", | |
"curl -L https://github.com/geoarrow/geoarrow-data/releases/download/v0.1.0/microsoft-buildings-point.fgb.zip \\\n", | |
" -o microsoft-buildings-point.fgb.zip\n", | |
"unzip microsoft-buildings-point.fgb.zip\n", | |
"rm microsoft-buildings-point.fgb.zip\n", | |
"\n", | |
"pip install duckdb\n", | |
"```\n", | |
"\n", | |
"Getting a dev version of the geography extension. Doesn't quite work unless you have a PAT set...you can visit a [recent CI run result](https://github.com/paleolimbot/duckdb-geography/actions/runs/12187812016) to do basically the same thing.\n", | |
"\n", | |
"```shell\n", | |
"PLATFORM=\"osx_arm64\" # use linux_amd64_gcc4 for linux/Python\n", | |
"ARTIFACT_URL=$(curl -L \\\n", | |
" \"https://api.github.com/repos/paleolimbot/duckdb-geography/actions/artifacts?name=geography-v1.1.3-extension-$PLATFORM\" | \\\n", | |
" jq -r '.artifacts.[0].url')\n", | |
"\n", | |
"DOWNLOAD_URL=$(curl -L \"$ARTIFACT_URL\" | jq -r '.archive_download_url')\n", | |
"\n", | |
"curl -L \"$DOWNLOAD_URL\" \\\n", | |
" -H \"Authorization: Bearer <YOUR-TOKEN>\"\n", | |
" -o geography.duckdb_extension.zip\n", | |
"unzip geography.duckdb_extension.zip\n", | |
"\n", | |
"# then con.raw_sql(\"INSTALL 'geography.duckdb_extension';\") below\n", | |
"```" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Set up the connection. Using ibis because the geopandas integration lets us plot this quickly." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import shutil\n", | |
"import ibis\n", | |
"from ibis import _\n", | |
"\n", | |
"ibis.options.interactive = True\n", | |
"\n", | |
"# Because the geography extension isn't published yet and we'll use it!\n", | |
"con = ibis.duckdb.connect(allow_unsigned_extensions=True)\n", | |
"con.load_extension(\"spatial\")\n", | |
"con.load_extension(\"geography\")" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Make the .fgb into a .parquet so this all goes faster. Takes about 2.5 min for the first go but the Parquet read after that is almost instantaneous." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"con.raw_sql(\"\"\"\n", | |
"COPY (\n", | |
" SELECT geom,\n", | |
" FROM 'microsoft-buildings-point.fgb'\n", | |
") TO 'microsoft-buildings-point.parquet'\n", | |
"\"\"\")" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Partitioning by S2 cell:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<duckdb.duckdb.DuckDBPyConnection at 0x1295a4df0>" | |
] | |
}, | |
"execution_count": 26, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"shutil.rmtree(\"buildings_by_cell\", ignore_errors=True)\n", | |
"\n", | |
"# This mechanism takes a cell level as its only parameter\n", | |
"cell_level = 3\n", | |
"row_group_size = 122880\n", | |
"\n", | |
"con.raw_sql(f\"\"\"\n", | |
"COPY (\n", | |
" SELECT\n", | |
" geom.st_aswkb().s2_cellfromwkb().s2_cell_parent({cell_level}).s2_cell_token() as partition_cell,\n", | |
" geom\n", | |
" FROM 'microsoft-buildings-point.parquet'\n", | |
") TO \"buildings_by_cell\" WITH (\n", | |
" FORMAT PARQUET,\n", | |
" PARTITION_BY partition_cell,\n", | |
" -- Can also specify in bytes via ROW_GROUP_SIZE_BYTES\n", | |
" ROW_GROUP_SIZE {row_group_size}\n", | |
" -- Unfortunately we can't set file sizes here\n", | |
" -- Not implemented Error: Can't combine file rotation (e.g., ROW_GROUPS_PER_FILE) and PARTITION_BY for COPY\n", | |
")\n", | |
"\"\"\")" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Check file sizes (rather variable since DuckDB won't let us set a max and because some cells just don't have that many buildings):" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 27, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"-rw-r--r-- 1 deweydunnington staff 21M Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 9.5M Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 42M Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 24M Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 90M Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 197M Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 14K Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 196M Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 25M Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 106M Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 216M Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 525M Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 234M Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 3.0M Dec 5 15:54 data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 344M Dec 5 15:54 data_0.parquet\n" | |
] | |
} | |
], | |
"source": [ | |
"! ls -lh buildings_by_cell/** | grep -e \".parquet\"" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Check the partitioning:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 28, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<Axes: >" | |
] | |
}, | |
"execution_count": 28, | |
"metadata": {}, | |
"output_type": "execute_result" | |
}, | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAEBCAYAAADYacenAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAfq0lEQVR4nO3de3BU5f3H8U9QsiSQDRBCsikbJsotXKJDOgOhSpVbhiClkrYOGEULQWmkQtRiRlJFZEJ1qjIFUmppwMEMVgZqtQgDyqUqaJoQAxhioLHByQXrSDZESbic3x9t9teVANlNcs7u5v2a2ZF9ztmz3zwumw/PeZ5zQgzDMAQAAGCSHlYXAAAAuhfCBwAAMBXhAwAAmIrwAQAATEX4AAAApiJ8AAAAUxE+AACAqQgfAADAVDdaXcB3Xb58WTU1NYqIiFBISIjV5QAAgHYwDEONjY2Ki4tTjx7XHtvwu/BRU1Mjp9NpdRkAAMAHp0+f1qBBg665j1fh45lnntGKFSs82oYPH64TJ05Iks6fP6/HHntMW7duVXNzs1JTU7V+/XrFxMS0+z0iIiLcxdvtdm/KAwAAFnG5XHI6ne7f49fi9cjHqFGjtHfv3v8/wI3/f4ilS5fqb3/7m9544w1FRkbqkUce0ezZs/XBBx+0+/itp1rsdjvhAwCAANOeKRNeh48bb7xRsbGxV7Q3NDRo48aNKiws1KRJkyRJBQUFSkxM1OHDhzV+/Hhv3woAAAQhr1e7V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+0p9+qq6s1Y8YMhYeHa+DAgXriiSd08eJFj3262+etLSUlJZo6dar69u2rqKgoLVy4UOfOnfPYpz192d189tlnmjVrlgYMGCC73a7bbrtN+/bt89iHfvO0f/9+hYSEtPkoKipy7xcM32eED5O0tLTopz/9qRYtWtTm9uLiYg0cOFBbtmzR8ePH9dRTTyknJ0dr165171NVVaUZM2bozjvvVGlpqZYsWaIFCxZo9+7dZv0Yprtev7X6+c9/rnvuuafNbS6XS9OmTdPgwYNVXFysF154Qc8884z+8Ic/dEXJfuF6/Xbp0iXNmDFDLS0t+vDDD7V582Zt2rRJv/71r937dMfP23fV1NRoypQpGjJkiD766CPt2rVLx48f1wMPPODepz192R3dddddunjxot577z0VFxfrlltu0V133aW6ujpJ9FtbJkyYoNraWo/HggULlJCQoO9///uSguj7zICpCgoKjMjIyHbt+4tf/MK488473c9/9atfGaNGjfLY55577jFSU1M7s0S/1J5+e/rpp41bbrnlivb169cb/fr1M5qbm91ty5YtM4YPH97JVfqfq/Xbzp07jR49ehh1dXXutvz8fMNut7v7qTt/3lpt2LDBGDhwoHHp0iV3W1lZmSHJqKysNAyjfX3Z3Xz55ZeGJOPgwYPuNpfLZUgy9uzZYxgG/dYeLS0tRnR0tPHss8+624Ll+4yRDz/W0NCg/v37u58fOnRIU6ZM8dgnNTVVhw4dMru0gHLo0CFNnDhRoaGh7rbU1FRVVFTo66+/trAy6xw6dEhjxoxRTEyMuy01NVUul0vHjx9379PdP2/Nzc0KDQ31uENnWFiYJOn999+X1L6+7G6ioqI0fPhwvfrqq2pqatLFixe1YcMGDRw4UMnJyZLot/b461//qq+++koPPviguy1Yvs8IH37qww8/1Ouvv66FCxe62+rq6jz+okpSTEyMXC6Xvv32W7NLDBhX67fWbd1Re/qEz5s0adIk1dXV6YUXXlBLS4u+/vprPfnkk5Kk2tpaSXy+2hISEqK9e/fqyJEjioiIUK9evfTiiy9q165d6tevnyT6rT02btyo1NRUjzu9B0u/ET464Mknn7zq5KDWx4kTJ7w+7rF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//3Jg+fboRFhZmDBgwwHjssceMCxcueBynu33e2nLfffcZ/fv3N0JDQ42kpCTj1VdfvWKf9vRld1NUVGRMmzbN6N+/vxEREWGMHz/e2Llzp8c+9Fvb5syZY0yYMOGq24Ph+yzEMAzDrFEWAACA7jddGwAAWIrwAQAATEX4AAAApiJ8AAAAUxE+AACAqQgfAADAVIQPAABgKsIHAAAwFeEDAACYivABAABMRfgAAACm+j9VhzikKkwEAQAAAABJRU5ErkJggg==", | |
"text/plain": [ | |
"<Figure size 640x480 with 1 Axes>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"con.sql(\n", | |
" \"\"\"\n", | |
" SELECT partition_cell, st_extent_agg(geom)\n", | |
" FROM \"buildings_by_cell/*/*.parquet\"\n", | |
" GROUP BY partition_cell\n", | |
" \"\"\"\n", | |
").to_pandas().plot(edgecolor=\"black\", facecolor=\"none\")\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 34, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<duckdb.duckdb.DuckDBPyConnection at 0x1295a4df0>" | |
] | |
}, | |
"execution_count": 34, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"shutil.rmtree(\"buildings_by_sort\", ignore_errors=True)\n", | |
"\n", | |
"# This mechanism takes a file size as its only parameter\n", | |
"file_size_bytes = 104857600 # 100 MB\n", | |
"row_group_size = 122880\n", | |
"\n", | |
"con.raw_sql(f\"\"\"\n", | |
"COPY (\n", | |
" SELECT\n", | |
" geom\n", | |
" FROM 'microsoft-buildings-point.parquet'\n", | |
" ORDER BY geom.st_aswkb().s2_cellfromwkb()\n", | |
") TO \"buildings_by_sort\" WITH (\n", | |
" FORMAT PARQUET,\n", | |
" -- Can also specify in bytes via ROW_GROUP_SIZE_BYTES\n", | |
" ROW_GROUP_SIZE {row_group_size},\n", | |
" FILE_SIZE_BYTES {file_size_bytes}\n", | |
")\n", | |
"\"\"\")" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Perfect file size partitioning:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 35, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"-rw-r--r-- 1 deweydunnington staff 101M Dec 5 16:01 buildings_by_sort/data_0.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 101M Dec 5 16:01 buildings_by_sort/data_1.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 102M Dec 5 16:01 buildings_by_sort/data_10.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 102M Dec 5 16:01 buildings_by_sort/data_11.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 101M Dec 5 16:01 buildings_by_sort/data_12.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 101M Dec 5 16:01 buildings_by_sort/data_13.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 101M Dec 5 16:01 buildings_by_sort/data_14.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 101M Dec 5 16:01 buildings_by_sort/data_15.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 101M Dec 5 16:01 buildings_by_sort/data_16.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 101M Dec 5 16:01 buildings_by_sort/data_17.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 100M Dec 5 16:01 buildings_by_sort/data_18.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 50M Dec 5 16:01 buildings_by_sort/data_19.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 100M Dec 5 16:01 buildings_by_sort/data_2.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 102M Dec 5 16:01 buildings_by_sort/data_3.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 100M Dec 5 16:01 buildings_by_sort/data_4.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 101M Dec 5 16:01 buildings_by_sort/data_5.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 100M Dec 5 16:01 buildings_by_sort/data_6.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 100M Dec 5 16:01 buildings_by_sort/data_7.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 100M Dec 5 16:01 buildings_by_sort/data_8.parquet\n", | |
"-rw-r--r-- 1 deweydunnington staff 100M Dec 5 16:01 buildings_by_sort/data_9.parquet\n" | |
] | |
} | |
], | |
"source": [ | |
"! ls -lh buildings_by_sort/** | grep -e \".parquet\"" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"Terrible spatial partitioning:" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 38, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<Axes: >" | |
] | |
}, | |
"execution_count": 38, | |
"metadata": {}, | |
"output_type": "execute_result" | |
}, | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAEBCAYAAADYacenAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAmXUlEQVR4nO3dfXBU13nH8R8yaEFYEiALvRSJkV8AGaxkUDtYjkMxwlAg1LWh4zFW/FIMDsWuDXaC1bBxsMyIvDQ2rWFDEwrOCIXWGjNtYyrGEMCNA7EqIYOxLGQqV/JIAtUDkkxs8Xb7R2a3WrQr7eu9d3e/n5kdae89e+6zZ1e7j84959wRhmEYAgAAMEmS1QEAAIDEQvIBAABMRfIBAABMRfIBAABMRfIBAABMRfIBAABMRfIBAABMRfIBAABMNdLqAK537do1dXR0KDU1VSNGjLA6HAAAEADDMNTX16fc3FwlJQ3dt2G75KOjo0N5eXlWh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+eSTxpQpUzxl3KPBL1y4YGRlZRnf/OY3jQ8++MDYs2ePkZKSYmzfvt2qpxV1w7XblStXjBkzZhjz5883GhsbjdraWiMzM9MoLy/31JGI7zdf/uEf/sGor683mpubjddee80YM2aMsWXLFs/+QNoy0XR3dxsZGRnGAw88YDQ2NhrNzc3G888/b4waNcpobGw0DIN2G8qBAwcMSUZTU9OgffHyeUbyYZJHH33UkDTodujQIcMw/jBN1Nf+yZMne9Vz6NAh46tf/aqRnJxs3HzzzcbOnTtNfy5mGq7dDMMw/vRP/9RnmdbWVk+Z999/37j77rsNh8Nh/NEf/ZGxefNm85+MiQJpt08++cRYuHChMWbMGOOmm24ynnvuOePy5cte9STa+82Xb37zm8aECROM5ORko6ioyPjFL34xqEwgbZlo6urqjPnz5xsTJkwwUlNTjTvvvNPYt2+fVxnazbeHHnrIuOuuu/zuj4fPsxGGYRhm9bIAAAAk3nBtAABgKZIPAABgKpIPAABgKpIPAABgKpIPAABgKpIPAABgKpIPAABgKpIPAABgKpIPAABgKpIPAABgKpIPAABgqv8D2BB2S7A+pPAAAAAASUVORK5CYII=", | |
"text/plain": [ | |
"<Figure size 640x480 with 1 Axes>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"con.sql(\n", | |
" \"\"\"\n", | |
" SELECT filename, st_extent_agg(geom)\n", | |
" FROM read_parquet(\"buildings_by_sort/*.parquet\", filename = true)\n", | |
" GROUP BY filename\n", | |
" \"\"\"\n", | |
").to_pandas().plot(edgecolor=\"black\", facecolor=\"none\")" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": ".venv", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.12.7" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment