|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "[](https://demo.leafmap.org/lab/index.html?path=notebooks/83_vector_viz.ipynb)\n", |
| 8 | + "[](https://studiolab.sagemaker.aws/import/github/opengeos/leafmap/blob/master/examples/notebooks/83_vector_viz.ipynb)\n", |
| 9 | + "[](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/opengeos/leafmap&urlpath=lab/tree/leafmap/examples/notebooks/83_vector_viz.ipynb&branch=master)\n", |
| 10 | + "[](https://githubtocolab.com/opengeos/leafmap/blob/master/examples/notebooks/01_leafmap_intro.ipynb)\n", |
| 11 | + "[](https://gishub.org/leafmap-binder)\n", |
| 12 | + "\n", |
| 13 | + "**Visualizing large vector datasets with lonboard**\n", |
| 14 | + "\n", |
| 15 | + "This notebook demonstrates how to visualize large vector datasets with [lonboard](https://github.com/developmentseed/lonboard). Please note that lonboard does not support Visual Studio Code's interactive notebook yet. You will need to run this notebook in Jupyter Notebook or JupyterLab.\n", |
| 16 | + "\n", |
| 17 | + "Uncomment the following line to install [leafmap](https://leafmap.org) if needed." |
| 18 | + ] |
| 19 | + }, |
| 20 | + { |
| 21 | + "cell_type": "code", |
| 22 | + "execution_count": null, |
| 23 | + "metadata": {}, |
| 24 | + "outputs": [], |
| 25 | + "source": [ |
| 26 | + "# %pip install -U leafmap lonboard" |
| 27 | + ] |
| 28 | + }, |
| 29 | + { |
| 30 | + "cell_type": "code", |
| 31 | + "execution_count": null, |
| 32 | + "metadata": { |
| 33 | + "tags": [] |
| 34 | + }, |
| 35 | + "outputs": [], |
| 36 | + "source": [ |
| 37 | + "import leafmap.deckgl as leafmap\n", |
| 38 | + "import geopandas as gpd" |
| 39 | + ] |
| 40 | + }, |
| 41 | + { |
| 42 | + "cell_type": "markdown", |
| 43 | + "metadata": {}, |
| 44 | + "source": [ |
| 45 | + "Download sample datasets." |
| 46 | + ] |
| 47 | + }, |
| 48 | + { |
| 49 | + "cell_type": "code", |
| 50 | + "execution_count": null, |
| 51 | + "metadata": { |
| 52 | + "tags": [] |
| 53 | + }, |
| 54 | + "outputs": [], |
| 55 | + "source": [ |
| 56 | + "url = \"https://open.gishub.org/data/duckdb/nyc_data.zip\"\n", |
| 57 | + "leafmap.download_file(url, unzip=True)" |
| 58 | + ] |
| 59 | + }, |
| 60 | + { |
| 61 | + "cell_type": "markdown", |
| 62 | + "metadata": {}, |
| 63 | + "source": [ |
| 64 | + "Create an interactive map." |
| 65 | + ] |
| 66 | + }, |
| 67 | + { |
| 68 | + "cell_type": "code", |
| 69 | + "execution_count": null, |
| 70 | + "metadata": { |
| 71 | + "tags": [] |
| 72 | + }, |
| 73 | + "outputs": [], |
| 74 | + "source": [ |
| 75 | + "m = leafmap.Map(center=[20, 0], zoom=1.2)\n", |
| 76 | + "m" |
| 77 | + ] |
| 78 | + }, |
| 79 | + { |
| 80 | + "cell_type": "markdown", |
| 81 | + "metadata": {}, |
| 82 | + "source": [ |
| 83 | + "Add GeoDataFrame." |
| 84 | + ] |
| 85 | + }, |
| 86 | + { |
| 87 | + "cell_type": "code", |
| 88 | + "execution_count": null, |
| 89 | + "metadata": { |
| 90 | + "tags": [] |
| 91 | + }, |
| 92 | + "outputs": [], |
| 93 | + "source": [ |
| 94 | + "streets = gpd.read_file('nyc_streets.shp')\n", |
| 95 | + "m.add_gdf(streets, zoom_to_layer=True, pickable=True, get_width=5)" |
| 96 | + ] |
| 97 | + }, |
| 98 | + { |
| 99 | + "cell_type": "markdown", |
| 100 | + "metadata": {}, |
| 101 | + "source": [ |
| 102 | + "Add any vector format supported by GeoPandas." |
| 103 | + ] |
| 104 | + }, |
| 105 | + { |
| 106 | + "cell_type": "code", |
| 107 | + "execution_count": null, |
| 108 | + "metadata": { |
| 109 | + "tags": [] |
| 110 | + }, |
| 111 | + "outputs": [], |
| 112 | + "source": [ |
| 113 | + "m.add_vector('nyc_subway_stations.shp', get_radius=10, get_fill_color=[255, 0, 0, 180])" |
| 114 | + ] |
| 115 | + }, |
| 116 | + { |
| 117 | + "cell_type": "markdown", |
| 118 | + "metadata": {}, |
| 119 | + "source": [ |
| 120 | + "Change layer properties." |
| 121 | + ] |
| 122 | + }, |
| 123 | + { |
| 124 | + "cell_type": "code", |
| 125 | + "execution_count": null, |
| 126 | + "metadata": { |
| 127 | + "tags": [] |
| 128 | + }, |
| 129 | + "outputs": [], |
| 130 | + "source": [ |
| 131 | + "m.layers[-1].get_fill_color = [0, 0, 255, 255]" |
| 132 | + ] |
| 133 | + } |
| 134 | + ], |
| 135 | + "metadata": { |
| 136 | + "kernelspec": { |
| 137 | + "display_name": "Python 3 (ipykernel)", |
| 138 | + "language": "python", |
| 139 | + "name": "python3" |
| 140 | + }, |
| 141 | + "language_info": { |
| 142 | + "codemirror_mode": { |
| 143 | + "name": "ipython", |
| 144 | + "version": 3 |
| 145 | + }, |
| 146 | + "file_extension": ".py", |
| 147 | + "mimetype": "text/x-python", |
| 148 | + "name": "python", |
| 149 | + "nbconvert_exporter": "python", |
| 150 | + "pygments_lexer": "ipython3", |
| 151 | + "version": "3.11.5" |
| 152 | + } |
| 153 | + }, |
| 154 | + "nbformat": 4, |
| 155 | + "nbformat_minor": 5 |
| 156 | +} |
0 commit comments