From 37c3de2a98aecbae1196dcc111748c919f3bbe7f Mon Sep 17 00:00:00 2001 From: k034b363 Date: Mon, 9 Sep 2024 09:52:54 -0500 Subject: [PATCH 1/3] Fix logic in transform points to accomodate geojson enumerate issue --- plantcv/geospatial/transform_points.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plantcv/geospatial/transform_points.py b/plantcv/geospatial/transform_points.py index fdb9b6c..c73413e 100644 --- a/plantcv/geospatial/transform_points.py +++ b/plantcv/geospatial/transform_points.py @@ -19,11 +19,11 @@ def transform_points(img, geojson): coord = [] with fiona.open(geojson, 'r') as shapefile: - for i, _ in enumerate(shapefile): - if type((shapefile[i].geometry["coordinates"])) is list: - pixel_point = ~(geo_transform) * (shapefile[i].geometry["coordinates"][0]) - if type((shapefile[i].geometry["coordinates"])) is tuple: - pixel_point = ~(geo_transform) * (shapefile[i].geometry["coordinates"]) + for row in shapefile: + if type((row.geometry["coordinates"])) is list: + pixel_point = ~(geo_transform) * (row.geometry["coordinates"][0]) + if type((row.geometry["coordinates"])) is tuple: + pixel_point = ~(geo_transform) * (row.geometry["coordinates"]) rounded = (int(pixel_point[0]), int(pixel_point[1])) coord.append(rounded) From b878289eb705d840184df192a9e85b97d5aa8c0e Mon Sep 17 00:00:00 2001 From: HaleySchuhl Date: Fri, 20 Sep 2024 11:12:52 -0500 Subject: [PATCH 2/3] update transformation metadata when cropto used in read_geotif --- plantcv/geospatial/read_geotif.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plantcv/geospatial/read_geotif.py b/plantcv/geospatial/read_geotif.py index 4d33190..055e240 100644 --- a/plantcv/geospatial/read_geotif.py +++ b/plantcv/geospatial/read_geotif.py @@ -90,8 +90,9 @@ def _read_geotif_and_shapefile(filename, cropto): shapes = [mapping(convex_hull)] # rasterio does the cropping within open with rasterio.open(filename, 'r') as src: - img_data, _ = mask(src, shapes, crop=True) + img_data, trans_metadata = mask(src, shapes, crop=True) metadata = src.meta.copy() + metadata.update({"transform": trans_metadata}) d_type = src.dtypes[0] else: From 9503653b0ddb79c35f44c667273d6c0b19bbadf1 Mon Sep 17 00:00:00 2001 From: HaleySchuhl Date: Fri, 20 Sep 2024 11:17:29 -0500 Subject: [PATCH 3/3] Update PULL_REQUEST_TEMPLATE.md minor clarification specific to this repo --- .github/PULL_REQUEST_TEMPLATE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 0f9f940..cd08d47 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -22,7 +22,7 @@ See [this page](https://plantcv.readthedocs.io/en/latest/pr_review_process/) for - [ ] All tests pass - [ ] Test coverage remains 100% - [ ] Documentation tested -- [ ] New documentation pages added to `plantcv/mkdocs.yml` -- [ ] Changes to function input/output signatures added to `updating.md` +- [ ] New documentation pages added to `plantcv-geospatial/mkdocs.yml` +- [ ] Changes to function input/output signatures added to `changelog.md` - [ ] Code reviewed - [ ] PR approved