Skip to content

Commit dbc39ca

Browse files
authored
Updates to DEA Waterbodies notebooks and tools for v3.0 (#1199)
* start editing, change modified date * update v2 to v3 * update examples to v3 * add new image to DEA Waterbodies notebooks * rerun prior to PR * add @whatnick 's version support for v2 and v3 * change heading size for disclaimer text * include back compatibility in waterbodies.py script and pt and propagate to waterbodies notebooks * add header image and move disclaimer to info box * update links to knowledge hub * check knowledgehub links' * rollback to develop to fix merge conflict * reapply changes, and update knowledge hub links and GitHub references * having to roll back again because of merge conflicts
1 parent 268e99d commit dbc39ca

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed
Loading
Loading

Tools/dea_tools/waterbodies.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
If you would like to report an issue with this script, file one on
1717
GitHub: https://github.com/GeoscienceAustralia/dea-notebooks/issues/new
1818
19-
Last modified: September 2021
19+
Last modified: March 2024
2020
"""
2121

2222
import geopandas as gpd
@@ -26,9 +26,12 @@
2626
import pandas as pd
2727

2828
WFS_ADDRESS = "https://geoserver.dea.ga.gov.au/geoserver/wfs"
29+
LAYER_SELECT = {
30+
"v2" : "DigitalEarthAustraliaWaterbodies_v2",
31+
"v3" : "DigitalEarthAustraliaWaterbodies_v3"
32+
}
2933

30-
31-
def get_waterbody(geohash: str) -> gpd.GeoDataFrame:
34+
def get_waterbody(geohash: str, version: str = "v3") -> gpd.GeoDataFrame:
3235
"""Gets a waterbody polygon and metadata by geohash.
3336
3437
Parameters
@@ -45,15 +48,15 @@ def get_waterbody(geohash: str) -> gpd.GeoDataFrame:
4548
filter_ = PropertyIsEqualTo(propertyname="uid", literal=geohash)
4649
filterxml = etree.tostring(filter_.toXML()).decode("utf-8")
4750
response = wfs.getfeature(
48-
typename="DigitalEarthAustraliaWaterbodies_v2",
51+
typename=LAYER_SELECT[version],
4952
filter=filterxml,
5053
outputFormat="json",
5154
)
5255
wb_gpd = gpd.read_file(response)
5356
return wb_gpd
5457

5558

56-
def get_waterbodies(bbox: tuple, crs="EPSG:4326") -> gpd.GeoDataFrame:
59+
def get_waterbodies(bbox: tuple, crs="EPSG:4326", version: str = "v3") -> gpd.GeoDataFrame:
5760
"""Gets the polygons and metadata for multiple waterbodies by bbox.
5861
5962
Parameters
@@ -70,15 +73,15 @@ def get_waterbodies(bbox: tuple, crs="EPSG:4326") -> gpd.GeoDataFrame:
7073
"""
7174
wfs = WebFeatureService(url=WFS_ADDRESS, version="1.1.0")
7275
response = wfs.getfeature(
73-
typename="DigitalEarthAustraliaWaterbodies_v2",
76+
typename=LAYER_SELECT[version],
7477
bbox=tuple(bbox) + (crs,),
7578
outputFormat="json",
7679
)
7780
wb_gpd = gpd.read_file(response)
7881
return wb_gpd
7982

8083

81-
def get_geohashes(bbox: tuple = None, crs: str = "EPSG:4326") -> [str]:
84+
def get_geohashes(bbox: tuple = None, crs: str = "EPSG:4326", version: str = "v3") -> [str]:
8285
"""Gets all waterbody geohashes.
8386
8487
Parameters
@@ -97,7 +100,7 @@ def get_geohashes(bbox: tuple = None, crs: str = "EPSG:4326") -> [str]:
97100
if bbox is not None:
98101
bbox = tuple(bbox) + (crs,)
99102
response = wfs.getfeature(
100-
typename="DigitalEarthAustraliaWaterbodies_v2",
103+
typename=LAYER_SELECT[version],
101104
propertyname="uid",
102105
outputFormat="json",
103106
bbox=bbox,
@@ -106,7 +109,7 @@ def get_geohashes(bbox: tuple = None, crs: str = "EPSG:4326") -> [str]:
106109
return list(wb_gpd["uid"])
107110

108111

109-
def get_time_series(geohash: str = None, waterbody: pd.Series = None) -> pd.DataFrame:
112+
def get_time_series(geohash: str = None, waterbody: pd.Series = None, version: str = "v3") -> pd.DataFrame:
110113
"""Gets the time series for a waterbody. Specify either a GeoDataFrame row or a geohash.
111114
112115
Parameters
@@ -127,7 +130,7 @@ def get_time_series(geohash: str = None, waterbody: pd.Series = None) -> pd.Data
127130
raise ValueError("One of waterbody and geohash must be specified")
128131

129132
if geohash is not None:
130-
wb = get_waterbody(geohash)
133+
wb = get_waterbody(geohash, version)
131134
url = wb.timeseries[0]
132135
else:
133136
url = waterbody.timeseries

0 commit comments

Comments
 (0)