Skip to content

Commit

Permalink
Update planetbasemaps app (#528)
Browse files Browse the repository at this point in the history
* Add dev dependency group

* Simplify dev conda env setup

* Update gitignore

* Rename environment file

* Update conda env setup

* Add date filtering for timeseries

* minor update

* Remove unused imports

* Move imports to top level

* Move imports to top level

* Minor changes

* Add error handling for coastlines overlay

* Remove unused imports

* minor edit

* Bump version

* Bump version

* Fix broken notebook
  • Loading branch information
vikineema authored Sep 3, 2024
1 parent 2530019 commit 7e46a03
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 141 deletions.
70 changes: 39 additions & 31 deletions Datasets/Planet_basemap.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"metadata": {},
"outputs": [],
"source": [
"#pip install localtileserver"
"# pip install localtileserver"
]
},
{
Expand Down Expand Up @@ -170,11 +170,11 @@
"# Method 1: Specify the latitude, longitude, and buffer\n",
"aoi = define_area(lat=6.74248, lon=-1.69340, buffer=0.05)\n",
"\n",
"# Method 2: Use a polygon as a GeoJSON or Esri Shapefile. \n",
"# Method 2: Use a polygon as a GeoJSON or Esri Shapefile.\n",
"# aoi = define_area(vector_path='aoi.shp')\n",
"\n",
"geopolygon = Geometry(aoi[\"features\"][0][\"geometry\"], crs=\"epsg:4326\")\n",
"geopolygon_gdf = gpd.GeoDataFrame(geometry=[geopolygon], crs=geopolygon.crs)\n",
"geopolygon_gdf = gpd.GeoDataFrame(geometry=[geopolygon.geom], crs=geopolygon.crs)\n",
"\n",
"# Get the latitude and longitude range of the geopolygon\n",
"lon_range = (geopolygon_gdf.total_bounds[0], geopolygon_gdf.total_bounds[2])\n",
Expand Down Expand Up @@ -214,41 +214,42 @@
" \n",
" <style>html, body {width: 100%;height: 100%;margin: 0;padding: 0;}</style>\n",
" <style>#map {position:absolute;top:0;bottom:0;right:0;left:0;}</style>\n",
" <script src="https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js"></script>\n",
" <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>\n",
" <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>\n",
" <script src="https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.js"></script>\n",
" <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>\n",
" <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js"></script>\n",
" <script src="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js"></script>\n",
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css"/>\n",
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>\n",
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"/>\n",
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"/>\n",
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.css"/>\n",
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css"/>\n",
" <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css"/>\n",
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.2.0/css/all.min.css"/>\n",
" <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css"/>\n",
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css"/>\n",
" \n",
" <meta name="viewport" content="width=device-width,\n",
" initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />\n",
" <style>\n",
" #map_d1c7256035306816612c48d549e6b74e {\n",
" #map_2d9926387269a65daae70d8b70f7e5e2 {\n",
" position: relative;\n",
" width: 100.0%;\n",
" height: 100.0%;\n",
" left: 0.0%;\n",
" top: 0.0%;\n",
" }\n",
" .leaflet-container { font-size: 1rem; }\n",
" </style>\n",
" \n",
"</head>\n",
"<body>\n",
" \n",
" \n",
" <div class="folium-map" id="map_d1c7256035306816612c48d549e6b74e" ></div>\n",
" <div class="folium-map" id="map_2d9926387269a65daae70d8b70f7e5e2" ></div>\n",
" \n",
"</body>\n",
"<script>\n",
" \n",
" \n",
" var map_d1c7256035306816612c48d549e6b74e = L.map(\n",
" "map_d1c7256035306816612c48d549e6b74e",\n",
" var map_2d9926387269a65daae70d8b70f7e5e2 = L.map(\n",
" "map_2d9926387269a65daae70d8b70f7e5e2",\n",
" {\n",
" center: [6.7424800000000005, -1.6934],\n",
" crs: L.CRS.EPSG3857,\n",
Expand All @@ -262,33 +263,36 @@
"\n",
" \n",
" \n",
" var tile_layer_0649989f976cbce99af9417821c3dee0 = L.tileLayer(\n",
" var tile_layer_b1d70385ccba87b2b11bc25afee35111 = L.tileLayer(\n",
" "http://mt1.google.com/vt/lyrs=y\\u0026z={z}\\u0026x={x}\\u0026y={y}",\n",
" {"attribution": "Google", "detectRetina": false, "maxNativeZoom": 18, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}\n",
" ).addTo(map_d1c7256035306816612c48d549e6b74e);\n",
" {"attribution": "Google", "detectRetina": false, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}\n",
" );\n",
" \n",
" \n",
" tile_layer_b1d70385ccba87b2b11bc25afee35111.addTo(map_2d9926387269a65daae70d8b70f7e5e2);\n",
" \n",
" \n",
" var poly_line_34df01c46c687967c97f8f33c653d79e = L.polyline(\n",
" var poly_line_3798352bdd75c346bc2a5920ac7a3568 = L.polyline(\n",
" [[6.69248, -1.7434], [6.69248, -1.6434], [6.79248, -1.6434], [6.79248, -1.7434], [6.69248, -1.7434]],\n",
" {"bubblingMouseEvents": true, "color": "red", "dashArray": null, "dashOffset": null, "fill": false, "fillColor": "red", "fillOpacity": 0.2, "fillRule": "evenodd", "lineCap": "round", "lineJoin": "round", "noClip": false, "opacity": 0.8, "smoothFactor": 1.0, "stroke": true, "weight": 3}\n",
" ).addTo(map_d1c7256035306816612c48d549e6b74e);\n",
" ).addTo(map_2d9926387269a65daae70d8b70f7e5e2);\n",
" \n",
" \n",
" var lat_lng_popup_3a35bedd0b11fee338fe5473d26f57a2 = L.popup();\n",
" var lat_lng_popup_61d430de38276b1b92c9852d5396cd9e = L.popup();\n",
" function latLngPop(e) {\n",
" lat_lng_popup_3a35bedd0b11fee338fe5473d26f57a2\n",
" lat_lng_popup_61d430de38276b1b92c9852d5396cd9e\n",
" .setLatLng(e.latlng)\n",
" .setContent("Latitude: " + e.latlng.lat.toFixed(4) +\n",
" "<br>Longitude: " + e.latlng.lng.toFixed(4))\n",
" .openOn(map_d1c7256035306816612c48d549e6b74e);\n",
" .openOn(map_2d9926387269a65daae70d8b70f7e5e2);\n",
" }\n",
" map_d1c7256035306816612c48d549e6b74e.on('click', latLngPop);\n",
" map_2d9926387269a65daae70d8b70f7e5e2.on('click', latLngPop);\n",
" \n",
"</script>\n",
"&lt;/html&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
],
"text/plain": [
"<folium.folium.Map at 0x7ff775397af0>"
"<folium.folium.Map at 0x7ff0f33db670>"
]
},
"execution_count": 4,
Expand Down Expand Up @@ -341,18 +345,20 @@
"WARNING:rasterio._env:CPLE_NotSupported in driver GTiff does not support creation option DTYPE\n",
"WARNING:rasterio._env:CPLE_NotSupported in driver GTiff does not support creation option CRS\n",
"WARNING:rasterio._env:CPLE_NotSupported in driver GTiff does not support creation option TRANSFORM\n",
"WARNING:rasterio._env:CPLE_NotSupported in driver GTiff does not support creation option NODATA\n",
"WARNING:rasterio._env:CPLE_NotSupported in driver GTiff does not support creation option WIDTH\n",
"WARNING:rasterio._env:CPLE_NotSupported in driver GTiff does not support creation option HEIGHT\n",
"WARNING:rasterio._env:CPLE_NotSupported in driver GTiff does not support creation option COUNT\n",
"WARNING:rasterio._env:CPLE_NotSupported in driver GTiff does not support creation option DTYPE\n",
"WARNING:rasterio._env:CPLE_NotSupported in driver GTiff does not support creation option CRS\n",
"WARNING:rasterio._env:CPLE_NotSupported in driver GTiff does not support creation option TRANSFORM\n"
"WARNING:rasterio._env:CPLE_NotSupported in driver GTiff does not support creation option TRANSFORM\n",
"WARNING:rasterio._env:CPLE_NotSupported in driver GTiff does not support creation option NODATA\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6ba997cfc5744b44ac1b78c74300a5d9",
"model_id": "6d1b25c35c91445f89c800c2a84c4e85",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -366,9 +372,9 @@
}
],
"source": [
"#NDVI threshold can be adjusted below; the NDVI value range is between 0 and 1, default value used is 0.6\n",
"# NDVI threshold can be adjusted below; the NDVI value range is between 0 and 1, default value used is 0.6\n",
"threshold_nvdi = 0.6\n",
"#BUI threshold can be adjsuted below, BUI value range is between -1 and 1, default value used is 0\n",
"# BUI threshold can be adjsuted below, BUI value range is between -1 and 1, default value used is 0\n",
"threshold_bui = 0\n",
"loadplanet(lon_range, lat_range, threshold_nvdi, threshold_bui)"
]
Expand Down Expand Up @@ -403,12 +409,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"1.8.15\n"
"1.8.19\n"
]
}
],
"source": [
"import datacube\n",
"\n",
"print(datacube.__version__)"
]
},
Expand All @@ -429,7 +436,7 @@
{
"data": {
"text/plain": [
"'2024-07-02'"
"'2024-09-03'"
]
},
"execution_count": 7,
Expand All @@ -439,7 +446,8 @@
],
"source": [
"from datetime import datetime\n",
"datetime.today().strftime('%Y-%m-%d')"
"\n",
"datetime.today().strftime(\"%Y-%m-%d\")"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion Tools/deafrica_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__locales__ = __path__[0] + "/locales"

__version__ = "2.4.7"
__version__ = "2.4.8"


def set_lang(lang=None):
Expand Down
Loading

0 comments on commit 7e46a03

Please sign in to comment.