Skip to content

Commit

Permalink
Improved key features notebook opengeos#83
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Jul 18, 2021
1 parent a14bdf8 commit 9965040
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 72 deletions.
120 changes: 84 additions & 36 deletions docs/notebooks/00_key_features.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@
"metadata": {},
"outputs": [],
"source": [
"import subprocess\n",
"\n",
"import os\n",
"import subprocess"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" import leafmap\n",
"except ImportError:\n",
Expand Down Expand Up @@ -131,7 +139,7 @@
"outputs": [],
"source": [
"m = leafmap.Map(google_map=\"TERRAIN\")\n",
"m.add_basemap(\"HYBRID\")\n",
"m.add_basemap(\"Esri National Geographic\")\n",
"m"
]
},
Expand Down Expand Up @@ -382,7 +390,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Add Planet imagery"
"## Create heat map"
]
},
{
Expand All @@ -392,18 +400,29 @@
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"m.add_planet_by_month(year=2020, month=8)\n",
"m.add_planet_by_quarter(year=2019, quarter=2)\n",
"in_csv = \"https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/world_cities.csv\"\n",
"m.add_heatmap(in_csv, latitude=\"latitude\", longitude='longitude', value=\"pop_max\", name=\"Heat map\", radius=20)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"colors = ['blue', 'lime', 'red']\n",
"vmin = 0\n",
"vmax = 10000\n",
"m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)\n",
"m.add_title(\"World Population Heat Map\", font_size=\"20px\", align=\"center\")\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Download OpenStreetMap data\n",
"\n",
"Add OSM data of place(s) by name or ID to the map."
"## Save map to HTML"
]
},
{
Expand All @@ -412,36 +431,34 @@
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(google_map=None, toolbar_control=False, layers_control=True)\n",
"m.add_osm_from_geocode(\"New York City\", layer_name='NYC')\n",
"m = leafmap.Map()\n",
"m.add_basemap(\"Esri Standard\")\n",
"m"
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Add OSM entities within boundaries of geocodable place(s) to the map."
"m.to_html(\"mymap.html\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map(google_map=None, toolbar_control=False, layers_control=True)\n",
"place = \"Bunker Hill, Los Angeles, California\"\n",
"tags = {\"building\": True}\n",
"m.add_osm_from_place(place, tags, layer_name=\"Los Angeles, CA\")\n",
"m"
"## Add Planet imagery"
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"## Create heat map"
"# os.environ[\"PLANET_API_KEY\"] = \"12345\""
]
},
{
Expand All @@ -451,21 +468,18 @@
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"in_csv = \"https://raw.githubusercontent.com/giswqs/leafmap/master/examples/data/world_cities.csv\"\n",
"m.add_heatmap(in_csv, latitude=\"latitude\", longitude='longitude', value=\"pop_max\", name=\"Heat map\", radius=20)\n",
"colors = ['blue', 'lime', 'red']\n",
"vmin = 0\n",
"vmax = 10000\n",
"m.add_colorbar(colors=colors, vmin=vmin, vmax=vmax)\n",
"m.add_title(\"World Population Heat Map\", font_size=\"20px\", align=\"center\")\n",
"m.add_planet_by_month(year=2020, month=8)\n",
"m.add_planet_by_quarter(year=2019, quarter=2)\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Save map to HTML"
"## Add OpenStreetMap data\n",
"\n",
"Add OSM data of place(s) by name or ID to the map."
]
},
{
Expand All @@ -474,18 +488,29 @@
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"m.add_basemap(\"HYBRID\")\n",
"m = leafmap.Map(google_map=None, toolbar_control=False, layers_control=True)\n",
"m.add_osm_from_geocode(\"New York City\", layer_name='NYC')\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Add OSM entities within boundaries of geocodable place(s) to the map."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m.to_html(\"mymap.html\")"
"m = leafmap.Map(google_map=None, toolbar_control=False, layers_control=True)\n",
"place = \"Bunker Hill, Los Angeles, California\"\n",
"tags = {\"building\": True}\n",
"m.add_osm_from_place(place, tags, layer_name=\"Los Angeles, CA\")\n",
"m"
]
},
{
Expand All @@ -512,6 +537,31 @@
"import leafmap.heremap as leafmap"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Set the API Key."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# os.environ[\"PLANET_API_KEY\"] = \"12345\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"api_key = os.environ.get(\"HEREMAPS_API_KEY\") # read api_key from environment variable."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -525,8 +575,6 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"api_key = os.environ.get(\"HEREMAPS_API_KEY\") # read api_key from environment variable.\n",
"m = leafmap.Map(api_key=api_key, center=(40, -100), zoom=4)\n",
"m"
]
Expand Down
Loading

0 comments on commit 9965040

Please sign in to comment.