Skip to content

Commit

Permalink
Merge pull request #43 from sackh/here-map-widget-2
Browse files Browse the repository at this point in the history
Added methods to add vector data on map for here-map-widget-for-jupyter backend
  • Loading branch information
giswqs authored Jun 16, 2021
2 parents caddf8c + 00cd391 commit fa047f5
Show file tree
Hide file tree
Showing 6 changed files with 443 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,5 @@ ENV/
.mypy_cache/

# IDE settings
.vscode/
.vscode/
.idea/
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

## Introduction

**leafmap** is a Python package for geospatial analysis and interactive mapping in a Jupyter environment. It is a spin-off project of the [geemap](https://geemap.org) Python package, which was designed specifically to work with [Google Earth Engine](https://earthengine.google.com) (GEE). However, not everyone in the geospatial community has a GEE account. **leafmap** is designed to fill this gap for non-GEE users. It enables users to perform advanced geospatial analysis and interactive mapping with minimal coding in a Jupyter environment (e.g., Google Colab, JupyterLab, Jupyter notebook). It is built upon a number of open-source packages, such as [folium](https://github.com/python-visualization/folium) and [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet) (for creating interactive maps), [WhiteboxTools](https://github.com/jblindsay/whitebox-tools) and [whiteboxgui](https://github.com/giswqs/whiteboxgui) (for analyzing geospatial data), and [ipywidgets](https://github.com/jupyter-widgets/ipywidgets) (for designing interactive graphical user interface).
**leafmap** is a Python package for geospatial analysis and interactive mapping in a Jupyter environment. It is a spin-off project of the [geemap](https://geemap.org) Python package, which was designed specifically to work with [Google Earth Engine](https://earthengine.google.com) (GEE). However, not everyone in the geospatial community has a GEE account. **leafmap** is designed to fill this gap for non-GEE users. It enables users to perform advanced geospatial analysis and interactive mapping with minimal coding in a Jupyter environment (e.g., Google Colab, JupyterLab, Jupyter notebook). It is built upon a number of open-source packages, such as [folium](https://github.com/python-visualization/folium) and [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet) and [here-map-widget-for-jupyter](https://github.com/heremaps/here-map-widget-for-jupyter) (for creating interactive maps), [WhiteboxTools](https://github.com/jblindsay/whitebox-tools) and [whiteboxgui](https://github.com/giswqs/whiteboxgui) (for analyzing geospatial data), and [ipywidgets](https://github.com/jupyter-widgets/ipywidgets) (for designing interactive graphical user interface).

The [WhiteboxTools](https://github.com/jblindsay/whitebox-tools) library currently contains **468** tools, which are each grouped based on their main function into one of the following categories. For a list of available tools with comprehensive documentation and usage details, please see the [WhiteboxTools User Manual](https://jblindsay.github.io/wbt_book/available_tools/index.html).

Expand Down
129 changes: 128 additions & 1 deletion examples/notebooks/16_heremap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "a7424420",
"metadata": {},
"source": [
"[![image](https://binder.pangeo.io/badge_logo.svg)](https://gishub.org/leafmap-pangeo)\n",
Expand All @@ -12,6 +13,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "eeac34ce",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -20,6 +22,7 @@
},
{
"cell_type": "markdown",
"id": "8c209034",
"metadata": {},
"source": [
"## Prerequisites\n",
Expand All @@ -36,6 +39,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "59c8949c",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -46,6 +50,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4847d0d4",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -56,6 +61,7 @@
},
{
"cell_type": "markdown",
"id": "f005b1ad",
"metadata": {},
"source": [
"## HERE default basemap"
Expand All @@ -64,6 +70,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "46779f36",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -74,6 +81,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4c766874",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -84,6 +92,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "de61460b",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -94,6 +103,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0db899d8",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -103,6 +113,7 @@
},
{
"cell_type": "markdown",
"id": "7eedd319",
"metadata": {},
"source": [
"## Basemaps"
Expand All @@ -111,16 +122,36 @@
{
"cell_type": "code",
"execution_count": null,
"id": "194c557c",
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(api_key=api_key, basemap=\"HERE_RASTER_TERRAIN_MAP\")\n",
"m"
]
},
{
"cell_type": "markdown",
"id": "e98ba5e9",
"metadata": {},
"source": [
"### zoom to bounds"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2f45058d",
"metadata": {},
"outputs": [],
"source": [
"m.zoom_to_bounds((-9.0882278, -55.3228175, 168.2249543, 72.2460938)) # South West North East"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b89127d1",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -130,6 +161,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4eac1fe9",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -140,6 +172,7 @@
},
{
"cell_type": "markdown",
"id": "3a3790fe",
"metadata": {},
"source": [
"## Add vector data\n",
Expand All @@ -149,6 +182,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e90cc80a",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -163,6 +197,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3aae4b8b",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -178,6 +213,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "92da3625",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -194,6 +230,97 @@
"m.add_geojson(url, layer_name=\"Countries\", style=style, hover_style=hover_style)\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d1d2c714",
"metadata": {},
"outputs": [],
"source": [
"in_shp = '../data/countries.shp'\n",
"in_geojson = '../data/us-states.json'\n",
"in_kml = '../data/us-states.kml'"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f933d905",
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=2)\n",
"m.add_shp(in_shp, layer_name=\"Shapefile\")\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "971acbff",
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(api_key=api_key, center=[40.273502, -86.126976], zoom=4)\n",
"m.add_kml(in_kml, layer_name=\"KML\")\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3fad34a2",
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=2)\n",
"url = \"https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/countries.geojson\"\n",
"m.add_vector(url, layer_name=\"Countries\")\n",
"m"
]
},
{
"cell_type": "markdown",
"id": "e6f21a6c",
"metadata": {},
"source": [
"### Point style for GeoJSON"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0ffb5367",
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=2)\n",
"\n",
"url = \"http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/2.5_month.geojson\"\n",
"point_style = {\"strokeColor\": 'white', \"lineWidth\": 1, \"fillColor\": \"red\", \"fillOpacity\": 0.7, \"radius\": 5}\n",
"m.add_geojson(url, layer_name=\"Countries\", point_style=point_style, default_popup=True)\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "144aa0d8",
"metadata": {},
"outputs": [],
"source": [
"import geopandas\n",
"import json\n",
"import os\n",
"\n",
"countries = geopandas.read_file(geopandas.datasets.get_path(\"naturalearth_cities\"))\n",
"point_style = {\"strokeColor\": 'white', \"lineWidth\": 1, \"fillColor\": \"blue\", \"fillOpacity\": 0.7, \"radius\": 5}\n",
"\n",
"m = leafmap.Map(api_key=api_key, center=[0, 0], zoom=3)\n",
"m.add_gdf(countries, zoom_to_layer=False, point_style=point_style, default_popup=True)\n",
"m"
]
}
],
"metadata": {
Expand All @@ -213,7 +340,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.9.5"
},
"toc": {
"base_numbering": 1,
Expand Down
Loading

0 comments on commit fa047f5

Please sign in to comment.