-
-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
442 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/80_solar.ipynb)\n", | ||
"[![image](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/opengeos/leafmap/blob/master/examples/notebooks/80_solar.ipynb)\n", | ||
"[![image](https://img.shields.io/badge/Open-Planetary%20Computer-black?style=flat&logo=microsoft)](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/opengeos/leafmap&urlpath=lab/tree/leafmap/examples/notebooks/80_solar.ipynb&branch=master)\n", | ||
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://githubtocolab.com/opengeos/leafmap/blob/master/examples/notebooks/80_solar.ipynb)\n", | ||
"[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/leafmap-binder)\n", | ||
"\n", | ||
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# %pip install -U leafmap" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import leafmap" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Set Google API key. Get one from https://developers.google.com/maps/documentation/solar/get-api-key\n", | ||
"\n", | ||
"You also need to enable the Google Solar API at https://console.cloud.google.com/google/maps-apis/api-list" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"os.environ[\"GOOGLE_API_KEY\"] = \"YOUR-API-KEY\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Set download directory." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"out_dir = os.path.expanduser(\"~/Downloads\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Download Solar data from Google's [Solar API](https://developers.google.com/maps/documentation/solar)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"lat = 50.97579908646006\n", | ||
"lon = 11.023334842349778\n", | ||
"radiusMeters = 50\n", | ||
"view = \"FULL_LAYERS\"\n", | ||
"requiredQuality = \"HIGH\"\n", | ||
"pixelSizeMeters = 0.1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"files = leafmap.get_solar_data(\n", | ||
" lat, \n", | ||
" lon, \n", | ||
" radiusMeters, \n", | ||
" view, \n", | ||
" requiredQuality, \n", | ||
" pixelSizeMeters, \n", | ||
" out_dir=out_dir\n", | ||
" )\n", | ||
"files" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Create an interactive map and add the Solar data." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"m = leafmap.Map()\n", | ||
"m.add_raster(files['rgb'], layer_name=\"RGB\")\n", | ||
"m.add_raster(files['mask'], layer_name=\"Mask\")\n", | ||
"m.add_raster(files['dsm'], cmap='terrain', layer_name=\"DSM\", visible=False)\n", | ||
"m.add_raster(files['annualFlux'], cmap='plasma', layer_name=\"annualFlux\")\n", | ||
"m.add_raster(files['monthlyFlux'], cmap='plasma', band=[7], layer_name=\"monthlyFlux\", visible=False)\n", | ||
"\n", | ||
"m.add_colormap(cmap='terrain', vmin=190, vmax=250, label='Elevation (m)')\n", | ||
"m.add_colormap(cmap='plasma', vmin=500, vmax=1000, label='Annual flux (kWh/kW/year)')\n", | ||
"m" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"![](https://i.imgur.com/XZ1i8O6.png)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"[![image](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://demo.leafmap.org/lab/index.html?path=notebooks/80_solar.ipynb)\n", | ||
"[![image](https://studiolab.sagemaker.aws/studiolab.svg)](https://studiolab.sagemaker.aws/import/github/opengeos/leafmap/blob/master/examples/notebooks/80_solar.ipynb)\n", | ||
"[![image](https://img.shields.io/badge/Open-Planetary%20Computer-black?style=flat&logo=microsoft)](https://pccompute.westeurope.cloudapp.azure.com/compute/hub/user-redirect/git-pull?repo=https://github.com/opengeos/leafmap&urlpath=lab/tree/leafmap/examples/notebooks/80_solar.ipynb&branch=master)\n", | ||
"[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://githubtocolab.com/opengeos/leafmap/blob/master/examples/notebooks/80_solar.ipynb)\n", | ||
"[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/leafmap-binder)\n", | ||
"\n", | ||
"Uncomment the following line to install [leafmap](https://leafmap.org) if needed." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# %pip install -U leafmap" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import leafmap" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Set Google API key. Get one from https://developers.google.com/maps/documentation/solar/get-api-key\n", | ||
"\n", | ||
"You also need to enable the Google Solar API at https://console.cloud.google.com/google/maps-apis/api-list" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"os.environ[\"GOOGLE_API_KEY\"] = \"YOUR-API-KEY\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Set download directory." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"out_dir = os.path.expanduser(\"~/Downloads\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Download Solar data from Google's [Solar API](https://developers.google.com/maps/documentation/solar)." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"lat = 50.97579908646006\n", | ||
"lon = 11.023334842349778\n", | ||
"radiusMeters = 50\n", | ||
"view = \"FULL_LAYERS\"\n", | ||
"requiredQuality = \"HIGH\"\n", | ||
"pixelSizeMeters = 0.1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"files = leafmap.get_solar_data(\n", | ||
" lat, \n", | ||
" lon, \n", | ||
" radiusMeters, \n", | ||
" view, \n", | ||
" requiredQuality, \n", | ||
" pixelSizeMeters, \n", | ||
" out_dir=out_dir\n", | ||
" )\n", | ||
"files" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Create an interactive map and add the Solar data." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"m = leafmap.Map()\n", | ||
"m.add_raster(files['rgb'], layer_name=\"RGB\")\n", | ||
"m.add_raster(files['mask'], layer_name=\"Mask\")\n", | ||
"m.add_raster(files['dsm'], cmap='terrain', layer_name=\"DSM\", visible=False)\n", | ||
"m.add_raster(files['annualFlux'], cmap='plasma', layer_name=\"annualFlux\")\n", | ||
"m.add_raster(files['monthlyFlux'], cmap='plasma', band=[7], layer_name=\"monthlyFlux\", visible=False)\n", | ||
"\n", | ||
"m.add_colormap(cmap='terrain', vmin=190, vmax=250, label='Elevation (m)')\n", | ||
"m.add_colormap(cmap='plasma', vmin=500, vmax=1000, label='Annual flux (kWh/kW/year)')\n", | ||
"m" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"![](https://i.imgur.com/XZ1i8O6.png)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.