{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://githubtocolab.com/gee-community/geemap/blob/master/examples/notebooks/107_pydeck.ipynb)\n", "\n", "Uncomment the following line to install [geemap](https://geemap.org) if needed." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# !pip install -U geemap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ee\n", "import geemap.deck as geemap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create an interactive map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m = geemap.Map(center=(40, -100), zoom=3)\n", "m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add basemap." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m = geemap.Map()\n", "m.add_basemap(\"HYBRID\")\n", "m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add vector data to the map. It supports any GeoPandas supported format, such as GeoJSON, shapefile, KML." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m = geemap.Map()\n", "filename = (\n", " \"https://github.com/giswqs/streamlit-geospatial/raw/master/data/us_states.geojson\"\n", ")\n", "m.add_vector(filename, random_color_column=\"STATEFP\")\n", "m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add a GeoPandas GeoDataFrame to the map." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import geopandas as gpd" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "url = (\n", " \"https://github.com/giswqs/streamlit-geospatial/raw/master/data/us_counties.geojson\"\n", ")\n", "gdf = gpd.read_file(url)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m = geemap.Map()\n", "m.add_gdf(gdf, random_color_column=\"STATEFP\")\n", "m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a 3D view of the map. **Press Ctrl and hold down the left mouse button to rotate the 3D view.**" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "initial_view_state = {\n", " \"latitude\": 40,\n", " \"longitude\": -100,\n", " \"zoom\": 3,\n", " \"pitch\": 45,\n", " \"bearing\": 10,\n", "}\n", "m = geemap.Map(initial_view_state=initial_view_state)\n", "filename = (\n", " \"https://github.com/giswqs/streamlit-geospatial/raw/master/data/us_states.geojson\"\n", ")\n", "m.add_vector(\n", " filename,\n", " random_color_column=\"STATEFP\",\n", " extruded=True,\n", " get_elevation=\"ALAND\",\n", " elevation_scale=0.000001,\n", ")\n", "m" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "![](https://i.imgur.com/LbCKhcM.gif)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add Earth Engine layers." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map(center=(40, -100), zoom=3)\n", "\n", "dem = ee.Image('USGS/SRTMGL1_003')\n", "\n", "vis_params = {\n", " 'min': 0,\n", " 'max': 4000,\n", " 'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5'],\n", "}\n", "\n", "Map.addLayer(dem, vis_params, 'SRTM DEM')\n", "Map" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }