Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update notebooks #133

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions examples/internet-speeds.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -365,20 +365,22 @@
"cell_type": "code",
"execution_count": 10,
"id": "326f5f4e-a8f7-425b-8e9f-6744ba65cf62",
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "30ba30dd2b9f4d47b307fa98ea9bf896",
"model_id": "cd6f767934bd451bb8f89088039e7af5",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ScatterplotLayer(table=pyarrow.Table\n",
"avg_d_kbps: int64\n",
"__index_level_0__: int64\n",
"geometry: fixed_size_list<item…"
"geometry: fixed_size_list<item: double>[2]\n",
" chi…"
]
},
"execution_count": 10,
Expand All @@ -387,7 +389,7 @@
}
],
"source": [
"map_ = viz(gdf)\n",
"map_ = viz(gdf.geometry)\n",
"map_"
]
},
Expand All @@ -396,7 +398,8 @@
"id": "91af2a88-9363-4c00-8e54-f06a635ff991",
"metadata": {},
"source": [
"This map object is a `ScatterplotLayer` type. You could have created the same map by using\n",
"This map object is a [`ScatterplotLayer`](https://developmentseed.org/lonboard/api/layers/scatterplot-layer/) type. You could have created the same map by using\n",
"\n",
"```py\n",
"map_ = lonboard.ScatterplotLayer.from_geopandas(gdf)\n",
"```"
Expand Down Expand Up @@ -531,7 +534,7 @@
"<div style=\"vertical-align: middle;\"><strong>BrBG</strong> </div><div class=\"cmap\"><img alt=\"BrBG colormap\" title=\"BrBG\" style=\"border: 1px solid #555;\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAABACAYAAABsv8+/AAAAE3RFWHRUaXRsZQBCckJHIGNvbG9ybWFwMTXIUAAAABl0RVh0RGVzY3JpcHRpb24AQnJCRyBjb2xvcm1hcLqHWMgAAAAwdEVYdEF1dGhvcgBNYXRwbG90bGliIHYzLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZ7rJ3hAAAAAydEVYdFNvZnR3YXJlAE1hdHBsb3RsaWIgdjMuNy4zLCBodHRwczovL21hdHBsb3RsaWIub3JnlG9BNwAAAilJREFUeJzt1k1u2zAURlGSQffTxXT/O7GYgSUHejahBPGgwHfOROWPKCYBitv//f0zW2ut99Zaa21cPu//GOPd+/t5/O7949h/39iP8WP+GI/TfO9l3yj79vXn88bL9/riO/Ueva4v7tHLd/rHx/7+6+d4rI/z+uq9sn8s18u5i/PG4tyrexz3bsffr5f3HvP7vnEer/a3Xu6x2N/K+V/7X8+3i++u7jn3v/Ns9+fWxv6s8+f15/lvnvPj7/32fne3Oe/j/XmbWxkf69ti/2/XV9970/q2nZ5bGd+2uZg/9pdzZj1nlv3fO/9p3/zhPco5x88763xZr/NzMb967+n8i/eX56/us1hv+++97b+Hr/GxPi/G/+n7+779fysAIIkAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAn0CyK5V+uT9Ti4AAAAASUVORK5CYII=\"></div><div style=\"vertical-align: middle; max-width: 514px; display: flex; justify-content: space-between;\"><div style=\"float: left;\"><div title=\"#543005ff\" style=\"display: inline-block; width: 1em; height: 1em; margin: 0; vertical-align: middle; border: 1px solid #555; background-color: #543005ff;\"></div> under</div><div style=\"margin: 0 auto; display: inline-block;\">bad <div title=\"#00000000\" style=\"display: inline-block; width: 1em; height: 1em; margin: 0; vertical-align: middle; border: 1px solid #555; background-color: #00000000;\"></div></div><div style=\"float: right;\">over <div title=\"#003c30ff\" style=\"display: inline-block; width: 1em; height: 1em; margin: 0; vertical-align: middle; border: 1px solid #555; background-color: #003c30ff;\"></div></div>"
],
"text/plain": [
"<matplotlib.colors.LinearSegmentedColormap at 0x1105c2950>"
"<matplotlib.colors.LinearSegmentedColormap at 0x2d8cd3590>"
]
},
"execution_count": 15,
Expand Down
141 changes: 86 additions & 55 deletions examples/north-america-roads.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"import geopandas as gpd\n",
"import palettable.colorbrewer.diverging\n",
"\n",
"from lonboard import PathLayer\n",
"from lonboard import PathLayer, viz\n",
"from lonboard.colormap import apply_continuous_cmap"
]
},
Expand Down Expand Up @@ -101,7 +101,9 @@
"cell_type": "code",
"execution_count": 4,
"id": "14d60ee4-4006-48b3-8ddb-52e3ae6002da",
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -277,7 +279,7 @@
"metadata": {},
"outputs": [],
"source": [
"gdf = gdf[(gdf['country'] == 'United States') & (~gdf['state'].isin(['Hawaii', 'Alaska']))]"
"gdf = gdf[gdf[\"state\"] == \"California\"]"
]
},
{
Expand All @@ -297,17 +299,14 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ab1597e0dde74743a143d1b4f35247a7",
"model_id": "8b473d8dd0c640d09b2f7b1163785f8d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"PathLayer(get_color=[0, 0, 0], table=pyarrow.Table\n",
"prefix: string\n",
"number: string\n",
"class: string\n",
"type: string\n",
"di…"
"PathLayer(table=pyarrow.Table\n",
"__index_level_0__: int64\n",
"geometry: list<item: list<item: fixed_size_list<item: d…"
]
},
"execution_count": 6,
Expand All @@ -316,11 +315,61 @@
}
],
"source": [
"black = [0, 0, 0]\n",
"map_ = PathLayer.from_geopandas(gdf, get_color=black, width_min_pixels=0.8)\n",
"map_ = viz(gdf.geometry, width_min_pixels=0.8)\n",
"map_"
]
},
{
"cell_type": "markdown",
"id": "42b7892e-b0b6-4fa8-87a5-937e363c6e34",
"metadata": {},
"source": [
"This map object is a [`PathLayer`](https://developmentseed.org/lonboard/api/layers/path-layer/) type. You could have created the same map by using\n",
"\n",
"```py\n",
"map_ = lonboard.PathLayer.from_geopandas(gdf)\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "8ff0879a-ae90-4302-91df-7c381a0a1f09",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"lonboard.layer.PathLayer"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(map_)"
]
},
{
"cell_type": "markdown",
"id": "a6bdfd6d-2689-42f6-a538-8f833c6d539a",
"metadata": {},
"source": [
"We can look at the [documentation for `PathLayer`](https://developmentseed.org/lonboard/api/layers/path-layer/) to see what other rendering options it allows. Let's set the path color to something other than black:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "75f67a77-062a-4043-9454-5b2b97b52288",
"metadata": {},
"outputs": [],
"source": [
"map_.get_color = [200, 0, 200]"
]
},
{
"cell_type": "markdown",
"id": "9bac0f0b-7129-476c-8ea0-51c1bede0f4d",
Expand All @@ -333,7 +382,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 9,
"id": "5c33098b-0348-4b07-9ae4-5c56d5d50723",
"metadata": {
"scrolled": true
Expand All @@ -343,20 +392,20 @@
"data": {
"text/plain": [
"scalerank\n",
"3 255\n",
"4 320\n",
"5 317\n",
"6 700\n",
"7 3332\n",
"8 4339\n",
"9 1228\n",
"10 5902\n",
"11 9859\n",
"12 10179\n",
"3 19\n",
"4 93\n",
"5 35\n",
"6 94\n",
"7 178\n",
"8 122\n",
"9 1\n",
"10 237\n",
"11 541\n",
"12 1562\n",
"Name: count, dtype: int64"
]
},
"execution_count": 7,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -375,7 +424,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 10,
"id": "c7d26678-418e-48f8-827d-050d9f2df1dd",
"metadata": {},
"outputs": [],
Expand All @@ -393,7 +442,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 11,
"id": "12be09c8-0857-44d8-ad14-69b4c7277fbc",
"metadata": {},
"outputs": [
Expand All @@ -403,7 +452,7 @@
"(0.0, 1.0)"
]
},
"execution_count": 9,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -422,7 +471,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 12,
"id": "1df9d2c9-6f10-49e6-aa4f-6718f3d2f765",
"metadata": {},
"outputs": [],
Expand All @@ -432,7 +481,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 13,
"id": "6e0f48ab-0cbe-4ce9-b804-9a1a3330ff9f",
"metadata": {},
"outputs": [
Expand All @@ -443,10 +492,10 @@
"<div style=\"vertical-align: middle;\"><strong>PuOr</strong> </div><div class=\"cmap\"><img alt=\"PuOr colormap\" title=\"PuOr\" style=\"border: 1px solid #555;\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAABACAYAAABsv8+/AAAAE3RFWHRUaXRsZQBQdU9yIGNvbG9ybWFw1Lg2NQAAABl0RVh0RGVzY3JpcHRpb24AUHVPciBjb2xvcm1hcF8Kpq0AAAAwdEVYdEF1dGhvcgBNYXRwbG90bGliIHYzLjcuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZ7rJ3hAAAAAydEVYdFNvZnR3YXJlAE1hdHBsb3RsaWIgdjMuNy4zLCBodHRwczovL21hdHBsb3RsaWIub3JnlG9BNwAAAgRJREFUeJzt1kFy2yAAhlFQNr1TD9eTS3QR5IyxsdEknS7+9zYMCIG8SOarf37/aqWUUmsrpZSy1bI01sV98/2v7/v++ZN92zmvS/NtO89/Pf9f5z3OP96M2/28Lu67+ryunrO2b+vj7Qf388ttfTL/9r439/30d5TP+44+tlL7OKy37fn68PwY3p+d8/B+Gd5fvm88pw739fOOz7//o7U+L5P1trheLu7/R+f094/j6GN7Om+T9a/nz9fP/W2y/tPnvP3Ova/vw/59eH7bfz6frQ/fvV98ftyfP65f/t52zve7+df663lr+2R99v7aPY/r1+45x/7fDQBIIgAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAAgAAAgkAAAgkAAAgkAAAgEACAAACCQAACCQAACCQAACAQAIAAAIJAAAIJAAAIJAAAIBAfwF0sXUGDv0RXAAAAABJRU5ErkJggg==\"></div><div style=\"vertical-align: middle; max-width: 514px; display: flex; justify-content: space-between;\"><div style=\"float: left;\"><div title=\"#7f3b08ff\" style=\"display: inline-block; width: 1em; height: 1em; margin: 0; vertical-align: middle; border: 1px solid #555; background-color: #7f3b08ff;\"></div> under</div><div style=\"margin: 0 auto; display: inline-block;\">bad <div title=\"#00000000\" style=\"display: inline-block; width: 1em; height: 1em; margin: 0; vertical-align: middle; border: 1px solid #555; background-color: #00000000;\"></div></div><div style=\"float: right;\">over <div title=\"#2d004bff\" style=\"display: inline-block; width: 1em; height: 1em; margin: 0; vertical-align: middle; border: 1px solid #555; background-color: #2d004bff;\"></div></div>"
],
"text/plain": [
"<matplotlib.colors.LinearSegmentedColormap at 0x125fcbcd0>"
"<matplotlib.colors.LinearSegmentedColormap at 0x2959c6b50>"
]
},
"execution_count": 11,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -460,51 +509,33 @@
"id": "74d9d749-4222-4aa8-bf12-ded79187a616",
"metadata": {},
"source": [
"Now we'll use `apply_continuous_cmap` onto this array to generate colors for our data:"
"Now we'll use `apply_continuous_cmap` onto this array to generate colors for our data. Just set this new array onto the existing map, and you'll see the map update with the new colors!"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 14,
"id": "7288a2d7-3190-4f9e-b29e-bbba32109024",
"metadata": {},
"outputs": [],
"source": [
"get_color = apply_continuous_cmap(normalized_scale_rank, palettable.colorbrewer.diverging.PuOr_10, alpha=0.8)"
]
},
{
"cell_type": "markdown",
"id": "efbe28aa-c004-41cd-90c9-d12c310b5d95",
"metadata": {},
"source": [
"Just set this new array onto the existing map, and you'll see the map update with the new colors!"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "0173cced-68fa-4966-9bb8-42f44f35e74b",
"metadata": {},
"outputs": [],
"source": [
"map_.get_color = get_color"
"map_.get_color = apply_continuous_cmap(normalized_scale_rank, palettable.colorbrewer.diverging.PuOr_10, alpha=0.8)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "82e50385-137d-46e5-91cc-558b252fd757",
"id": "72807632-f5de-4dcc-9c8e-f4e0c8495e2b",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "lonboard",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "lonboard"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand Down