Update DuckDB longboard example

This commit is contained in:
Diego Ripley
2025-05-30 17:29:58 +00:00
parent bd7e8ee9f4
commit 34d2c50046
@@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 330, "execution_count": 12,
"id": "56ac906e", "id": "56ac906e",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -13,16 +13,8 @@
"from lonboard import BitmapTileLayer, Map, PolygonLayer\n", "from lonboard import BitmapTileLayer, Map, PolygonLayer\n",
"from lonboard.colormap import apply_categorical_cmap\n", "from lonboard.colormap import apply_categorical_cmap\n",
"import numpy as np\n", "import numpy as np\n",
"import pyarrow as pa" "import pyarrow as pa\n",
] "\n",
},
{
"cell_type": "code",
"execution_count": 2,
"id": "708e293d",
"metadata": {},
"outputs": [],
"source": [
"con = duckdb.connect()\n", "con = duckdb.connect()\n",
"con.install_extension(\"spatial\")\n", "con.install_extension(\"spatial\")\n",
"con.load_extension(\"spatial\")" "con.load_extension(\"spatial\")"
@@ -39,17 +31,17 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 345, "execution_count": 26,
"id": "580c82ad-f64d-439f-9055-2307fdf7cccd", "id": "580c82ad-f64d-439f-9055-2307fdf7cccd",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"<duckdb.duckdb.DuckDBPyConnection at 0x7f069ca09ab0>" "<duckdb.duckdb.DuckDBPyConnection at 0x7fd635715cb0>"
] ]
}, },
"execution_count": 345, "execution_count": 26,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -71,7 +63,7 @@
"FROM\n", "FROM\n",
" 'https://data.dataforcanada.org/processed/statistics_canada/census_of_population/2021/tabular/da_2021.parquet' AS cop,\n", " 'https://data.dataforcanada.org/processed/statistics_canada/census_of_population/2021/tabular/da_2021.parquet' AS cop,\n",
" 'https://data.dataforcanada.org/processed/statistics_canada/boundaries/2021/digital_boundary_files/da_2021.parquet' AS geo\n", " 'https://data.dataforcanada.org/processed/statistics_canada/boundaries/2021/digital_boundary_files/da_2021.parquet' AS geo\n",
"WHERE geo.csd_name IN ('Ottawa') AND cop.da_dguid = geo.da_dguid;\n", "WHERE geo.csd_name IN ('Vancouver') AND cop.da_dguid = geo.da_dguid;\n",
"\n", "\n",
"\"\"\")\n", "\"\"\")\n",
"\n", "\n",
@@ -82,7 +74,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 346, "execution_count": 30,
"id": "e4794c4d-6013-40b5-8e59-046fc2495d34", "id": "e4794c4d-6013-40b5-8e59-046fc2495d34",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -98,7 +90,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 347, "execution_count": 31,
"id": "8672f3f8-82bf-439e-8558-cb3566f2062f", "id": "8672f3f8-82bf-439e-8558-cb3566f2062f",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -121,7 +113,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 353, "execution_count": 32,
"id": "f265300a-9cf7-4ab7-8bdb-d66feae3a2f8", "id": "f265300a-9cf7-4ab7-8bdb-d66feae3a2f8",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -141,7 +133,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 355, "execution_count": 33,
"id": "a6a2ae6c-61b7-4c0e-bbe7-a580a511ee5a", "id": "a6a2ae6c-61b7-4c0e-bbe7-a580a511ee5a",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -160,7 +152,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 356, "execution_count": 34,
"id": "56e96627-0e82-436a-bd8e-e51546c7526b", "id": "56e96627-0e82-436a-bd8e-e51546c7526b",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -177,7 +169,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 357, "execution_count": 35,
"id": "fef53303-147d-44af-b8f4-b824f64b486f", "id": "fef53303-147d-44af-b8f4-b824f64b486f",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -187,12 +179,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 358, "execution_count": 36,
"id": "6935a061-41fc-4223-b155-4caf4c6df103", "id": "6935a061-41fc-4223-b155-4caf4c6df103",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"cop_layer = PolygonLayer.from_geopandas(gdf=gpf,\n", "cop_layer = PolygonLayer.from_geopandas(gdf=dwellings_df,\n",
" stroked=True,\n", " stroked=True,\n",
" get_fill_color=get_color,\n", " get_fill_color=get_color,\n",
" get_line_color=[255, 255, 255],\n", " get_line_color=[255, 255, 255],\n",
@@ -206,7 +198,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 359, "execution_count": 37,
"id": "1ab3dded-cff9-40cb-ac32-306581018083", "id": "1ab3dded-cff9-40cb-ac32-306581018083",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -216,14 +208,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 360, "execution_count": 38,
"id": "3ca8da4b-d287-47f9-8488-cff7b02586b8", "id": "afb530c1-f652-4aaa-a3fc-1214a71ffdce",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "fb9e669faec9417dbf4954620c6f9af6", "model_id": "5d5e30381eff4f839a04ae81eff1b1e2",
"version_major": 2, "version_major": 2,
"version_minor": 1 "version_minor": 1
}, },
@@ -231,7 +223,7 @@
"Map(custom_attribution='', layers=(BitmapTileLayer(data='http://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={…" "Map(custom_attribution='', layers=(BitmapTileLayer(data='http://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={…"
] ]
}, },
"execution_count": 360, "execution_count": 38,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }