Skip to content

Commit

Permalink
Merge pull request #196 from emlys/task/update-gdal-3.3.0
Browse files Browse the repository at this point in the history
Support GDAL 3.3.0
  • Loading branch information
richpsharp authored Jun 15, 2021
2 parents 28b87ee + 391ffd4 commit 09b5847
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
max-parallel: 4
matrix:
python-version: [3.7, 3.8, 3.9]
gdal: [3.2.2, 3.3.0]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
Expand All @@ -36,6 +37,7 @@ jobs:
run: |
conda install --file requirements.txt
conda install $PACKAGES
conda install gdal==${{ matrix.gdal }}
python setup.py install
- name: Lint with flake8
Expand Down
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Unreleased Changes
off the edge of the raster had negative values rather than nodata values.
* Expanded the error message raised by ``transform_bounding_box`` when the
bounding box cannot be transformed to provide more helpful details.
* Add support and testing for GDAL 3.3.0.

2.2.0 (2020-05-14)
------------------
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# pygeoprocessing to work as expected.

Cython
GDAL>=3.0.4,<3.3.0
GDAL>=3.0.4
numpy>=1.10.1
Rtree>=0.8.3
scipy>=0.14.1,!=0.19.1
Expand Down
3 changes: 2 additions & 1 deletion src/pygeoprocessing/geoprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2239,8 +2239,9 @@ def calculate_disjoint_polygon_set(
f'no geometry in {vector_path} FID: {poly_feat.GetFID()}, '
'skipping...')
continue
# with GDAL>=3.3.0 ExportToWkb returns a bytearray instead of bytes
shapely_polygon_lookup[poly_feat.GetFID()] = (
shapely.wkb.loads(poly_geom_ref.ExportToWkb()))
shapely.wkb.loads(bytes(poly_geom_ref.ExportToWkb())))
poly_geom_ref = None
poly_feat = None

Expand Down
2 changes: 1 addition & 1 deletion src/pygeoprocessing/routing/routing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3698,7 +3698,7 @@ def extract_strahler_streams_d8(
multi_line = working_geom.Union(downstream_geom)
joined_line = ogr.CreateGeometryFromWkb(
shapely.ops.linemerge(shapely.wkb.loads(
multi_line.ExportToWkb())).wkb)
bytes(multi_line.ExportToWkb()))).wkb)

downstream_feature.SetGeometry(joined_line)
downstream_feature.SetField(
Expand Down
2 changes: 1 addition & 1 deletion src/pygeoprocessing/routing/watershed.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ def delineate_watersheds_d8(
'Outflow feature %s has empty geometry. Skipping.',
current_fid)
continue
geom_wkb = geom.ExportToWkb()
geom_wkb = bytes(geom.ExportToWkb())
shapely_geom = shapely.wkb.loads(geom_wkb)

LOGGER.debug('Testing geometry bbox')
Expand Down
3 changes: 2 additions & 1 deletion tests/test_watershed_delineation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

class WatershedDelineationTests(unittest.TestCase):
"""Main Watershed test module."""

def setUp(self):
"""Create empty workspace dir."""
self.workspace_dir = tempfile.mkdtemp()
Expand Down Expand Up @@ -181,7 +182,7 @@ def test_watersheds_trivial(self):
id_to_fields = {}
for feature in watersheds_layer:
geometry = feature.GetGeometryRef()
shapely_geom = shapely.wkb.loads(geometry.ExportToWkb())
shapely_geom = shapely.wkb.loads(bytes(geometry.ExportToWkb()))
self.assertEqual(
shapely_geom.area, expected_watershed_geometry.area)
self.assertEqual(
Expand Down

0 comments on commit 09b5847

Please sign in to comment.