From fc4ca31305c34be0dc971ccd41ffb9622bb82cc4 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Fri, 1 Mar 2024 14:10:14 -0600 Subject: [PATCH 1/9] raise error if osmium isn't installed --- src/asf_tools/watermasking/generate_osm_tiles.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/asf_tools/watermasking/generate_osm_tiles.py b/src/asf_tools/watermasking/generate_osm_tiles.py index 4b93490..86281ed 100644 --- a/src/asf_tools/watermasking/generate_osm_tiles.py +++ b/src/asf_tools/watermasking/generate_osm_tiles.py @@ -202,6 +202,11 @@ def main(): args = parser.parse_args() + try: + subprocess.run(['osmium', '--help'], check=True, stdout=subprocess.DEVNULL) + except subprocess.CalledProcessError: + raise ImportError('osmium-tool must be installed to run this program.') + lat_begin = int(args.lat_begin) lat_end = int(args.lat_end) lon_begin = int(args.lon_begin) From 7f17adbd67dc378b0e8b7abd001e3c2c87d47405 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Fri, 1 Mar 2024 14:12:14 -0600 Subject: [PATCH 2/9] check for osmium --- src/asf_tools/watermasking/generate_osm_tiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/asf_tools/watermasking/generate_osm_tiles.py b/src/asf_tools/watermasking/generate_osm_tiles.py index 86281ed..5233c64 100644 --- a/src/asf_tools/watermasking/generate_osm_tiles.py +++ b/src/asf_tools/watermasking/generate_osm_tiles.py @@ -205,7 +205,7 @@ def main(): try: subprocess.run(['osmium', '--help'], check=True, stdout=subprocess.DEVNULL) except subprocess.CalledProcessError: - raise ImportError('osmium-tool must be installed to run this program.') + raise ImportError('osmium-tool must be installed to run this program: https://osmcode.org/osmium-tool/.') lat_begin = int(args.lat_begin) lat_end = int(args.lat_end) From e4a89cb8b233546486b2df085d1bd1545ba94a75 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Fri, 1 Mar 2024 14:22:00 -0600 Subject: [PATCH 3/9] added note about osmium-tool to pyproject --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 893453c..d2ac7a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ dependencies = [ "gdal>=3.3", "geopandas", "numpy", + # "osmium-tool", # C++ CLI tool available via conda-forge or 'https://osmcode.org/osmium-tool/', used by `asf_tools.watermasking.generate_osm_tiles`. "pyogrio", "pysheds>=0.3", "rasterio", From 23228b92d0343827ef0fce24dfe35cd4d33880c2 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Fri, 1 Mar 2024 14:41:29 -0600 Subject: [PATCH 4/9] added init and osmium note --- src/asf_tools/watermasking/README.MD | 13 +++++++------ src/asf_tools/watermasking/__init__.py | 0 2 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 src/asf_tools/watermasking/__init__.py diff --git a/src/asf_tools/watermasking/README.MD b/src/asf_tools/watermasking/README.MD index dde4045..276b59b 100644 --- a/src/asf_tools/watermasking/README.MD +++ b/src/asf_tools/watermasking/README.MD @@ -2,12 +2,13 @@ These scripts are for creating a global (or regional) water mask dataset based o For the OSM water mask dataset, follow these steps to replicate our dataset: -1. Download the "Latest Weekly Planet PBF File" file from here: "https://planet.openstreetmap.org/". -2. Download the WGS84 water polygons shapefile from: "https://osmdata.openstreetmap.de/data/water-polygons.html". -3. The files should be unzipped and you should have something like `planet.osm.pbf` or `planet.pbf` and `water_polygons.shp` (and the support files for `water_polygons.shp`). -4. Run ```generate_osm_dataset --planet-file-path [path-to-planet.pbf] --ocean-polygons-path [path-to-water-polygons.shp] --lat-begin -85 --lat-end 85 --lon-begin -180 --lon-end 180 --tile-width 5 --tile-height 5``` -5. Run ```fill_missing_tiles --fill-value 0 --lat-begin -90 --lat-end -85 --lon-begin -180 --lon-end 180 --tile-width 5 --tile-height 5``` -6. Run ```fill_missing_tiles --fill-value 1 --lat-begin 85 --lat-end 90 --lon-begin -180 --lon-end 180 --tile-width 5 --tile-height 5``` +1. Install osmium-tool from conda-forge or "https://osmcode.org/osmium-tool/". +2. Download the "Latest Weekly Planet PBF File" file from here: "https://planet.openstreetmap.org/". +3. Download the WGS84 water polygons shapefile from: "https://osmdata.openstreetmap.de/data/water-polygons.html". +4. The files should be unzipped and you should have something like `planet.osm.pbf` or `planet.pbf` and `water_polygons.shp` (and the support files for `water_polygons.shp`). +5. Run ```generate_osm_dataset --planet-file-path [path-to-planet.pbf] --ocean-polygons-path [path-to-water-polygons.shp] --lat-begin -85 --lat-end 85 --lon-begin -180 --lon-end 180 --tile-width 5 --tile-height 5``` +6. Run ```fill_missing_tiles --fill-value 0 --lat-begin -90 --lat-end -85 --lon-begin -180 --lon-end 180 --tile-width 5 --tile-height 5``` +7. Run ```fill_missing_tiles --fill-value 1 --lat-begin 85 --lat-end 90 --lon-begin -180 --lon-end 180 --tile-width 5 --tile-height 5``` For the WorldCover water mask dataset, follow these steps: diff --git a/src/asf_tools/watermasking/__init__.py b/src/asf_tools/watermasking/__init__.py new file mode 100644 index 0000000..e69de29 From 0114e1db754ee9763ff8a5f57d9fbb0a6a96b224 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Fri, 1 Mar 2024 15:33:39 -0600 Subject: [PATCH 5/9] rename tmp --- src/asf_tools/watermasking/{README.MD => READMEasd.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/asf_tools/watermasking/{README.MD => READMEasd.md} (100%) diff --git a/src/asf_tools/watermasking/README.MD b/src/asf_tools/watermasking/READMEasd.md similarity index 100% rename from src/asf_tools/watermasking/README.MD rename to src/asf_tools/watermasking/READMEasd.md From 738c50ebfdc0c92ea09e45a34a274f66e95f8d27 Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Fri, 1 Mar 2024 15:33:52 -0600 Subject: [PATCH 6/9] rename --- src/asf_tools/watermasking/{READMEasd.md => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/asf_tools/watermasking/{READMEasd.md => README.md} (100%) diff --git a/src/asf_tools/watermasking/READMEasd.md b/src/asf_tools/watermasking/README.md similarity index 100% rename from src/asf_tools/watermasking/READMEasd.md rename to src/asf_tools/watermasking/README.md From 8569fd62283d3301a21fa79ef9987219c7092fbf Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Fri, 1 Mar 2024 15:42:37 -0600 Subject: [PATCH 7/9] readme note about watermasking --- src/asf_tools/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/asf_tools/README.md b/src/asf_tools/README.md index 5f5a4a7..f7aea0b 100644 --- a/src/asf_tools/README.md +++ b/src/asf_tools/README.md @@ -161,3 +161,10 @@ flood_map --help ``` For details on the algorithm see the `asf_tools.flood_map.make_flood_map` docstring. + +### Water Mask Dataset Generation + +The `asf_tools.watermasking` sub-package allows you to create a watermasking dataset +over an arbitrary ROI (including global) using OpenStreetMap and ESA WorldCover data. +Note, this program requires `osmium-tool`. See [README.md](watermasking/README.md) +for more information on setup and usage. \ No newline at end of file From 53e9c32ab13eeb5008cfd667998ef759f7d3654e Mon Sep 17 00:00:00 2001 From: Andrew Player Date: Fri, 1 Mar 2024 15:44:35 -0600 Subject: [PATCH 8/9] removed redundant phrase --- src/asf_tools/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/asf_tools/README.md b/src/asf_tools/README.md index f7aea0b..7afba99 100644 --- a/src/asf_tools/README.md +++ b/src/asf_tools/README.md @@ -165,6 +165,6 @@ For details on the algorithm see the `asf_tools.flood_map.make_flood_map` docstr ### Water Mask Dataset Generation The `asf_tools.watermasking` sub-package allows you to create a watermasking dataset -over an arbitrary ROI (including global) using OpenStreetMap and ESA WorldCover data. +over an arbitrary ROI using OpenStreetMap and ESA WorldCover data. Note, this program requires `osmium-tool`. See [README.md](watermasking/README.md) for more information on setup and usage. \ No newline at end of file From b00754657055a069287f8c4d2cfa7aeec4376102 Mon Sep 17 00:00:00 2001 From: Joseph H Kennedy Date: Fri, 1 Mar 2024 20:49:16 -0900 Subject: [PATCH 9/9] Update CHANGELOG.md --- CHANGELOG.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd1d075..7a1c22b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,15 +6,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/) and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.7.1] + +### Added +- A description of the `asf_tools.watermasking` sub-package has been added to the [`asf_tools` README](src/asf_tools/README.md) +- Installation instructions for `osmium-tool` have been added to the [`asf_tools.watermasking` README](src/asf_tools/watermasking/README.md) + +### Fixed +- `osmium-tool` dependency handling. Because `osmium-tool` is not distributed on PyPI and thus is not installed when `pip` installing `asf_tools`, `asf_tools` will now raise an `ImportError` when `osmium-tool` is missing that provides installation instructions. Note: `osmium-tool` is distributed on conda-forge and will be included when conda installing `asf_tools`. + ## [0.7.0] ## Added * Scripts and entrypoints for generating our global watermasking dataset added to `watermasking`. - ## [0.6.0] -## Added +### Added * You can choose whether the `ts` (threat score; default) or `fmi` (Fowlkes-Mallows index) minimization metric is used for the flood mapping iterative estimator: * the `flood_map` console script entrypoint now accepts a `--minimization-metric` argument * the `asf_tools.hydrosar.floopd_map.make_flood_map` function now accepts a `minimization_metric` keyword argument