Skip to content

Commit

Permalink
fix Dataset/convert_longitude/fix unsuported in wrap new versions (#59)
Browse files Browse the repository at this point in the history
* revert the convert_longitude method to not use the gdal_wrap method

* update gdal

* update gdal

* update hooks

* bump up versions

* bump up versions

* bump up versions

* delete qodana files

* limit dependapot to 5 pull requests only
  • Loading branch information
MAfarrag authored Nov 27, 2023
1 parent e718db5 commit 6e765b5
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ updates:
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
open-pull-requests-limit: 5
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fail_fast: true
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: end-of-file-fixer
name: "[py - check] validate yaml"
Expand Down Expand Up @@ -70,7 +70,7 @@ repos:
# hooks:
# - id: black
- repo: https://github.com/ambv/black
rev: 23.7.0
rev: 23.11.0
hooks:
- id: black
name: "[py - format] black"
Expand Down
7 changes: 7 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,10 @@ FeatureCollection
* Rename bounds to total_bounds.
* The _gdf_to_ds can convert the GeoDataFrame to a ogr.DataSource and to a gdal.Dataset.
* The create_point method returns a shapely point object or a GeoDataFrame if an epsg number is given.

0.5.1 (2023-11-27)
------------------
Dataset
"""""""
* revert the convert_longitude method to not use the gdal_wrap method as it is not working with the new version of gdal (newer tan 3.7.1).
* bump up versions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Installing pyramids
Installing `pyramids` from the `conda-forge` channel can be achieved by:

```
conda install -c conda-forge pyramids=0.5.0
conda install -c conda-forge pyramids=0.5.1
```

It is possible to list all of the versions of `pyramids` available on your platform with:
Expand All @@ -68,7 +68,7 @@ pip install git+https://github.com/Serapieum-of-alex/pyramids
to install the last release you can easly use pip

```
pip install pyramids-gis==0.5.0
pip install pyramids-gis==0.5.1
```

Quick start
Expand Down
18 changes: 9 additions & 9 deletions environment-optional-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ channels:
dependencies:
- python >=3.11
- numpy >=1.25.2
- hpc >=0.1.2
- pip >=23.2.1
- gdal >=3.7.0, <3.7.2
- pandas >=2.0.0
- geopandas >=0.13.2
- Shapely >=2.0.1
- pyproj >=3.6.0
- hpc >=0.1.3
- pip >=23.3.1
- gdal >=3.7.0
- pandas >=2.1.0
- geopandas >=0.14.1
- Shapely >=2.0.2
- pyproj >=3.6.1
- cleopatra >=0.4.0
- PyYAML >=6.0.1
- loguru >=0.7.0
- pytest >=7.4.0
- loguru >=0.7.2
- pytest >=7.4.3
- pytest-cov >=4.1.0
18 changes: 9 additions & 9 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ channels:
dependencies:
- python >=3.11
- numpy >=1.25.2
- hpc >=0.1.2
- pip >=23.2.1
- gdal >=3.7.0, <3.7.2
- pandas >=2.0.0
- geopandas >=0.13.2
- Shapely >=2.0.1
- pyproj >=3.6.0
- hpc >=0.1.3
- pip >=23.3.1
- gdal >=3.7.0
- pandas >=2.1.0
- geopandas >=0.14.1
- Shapely >=2.0.2
- pyproj >=3.6.1
- PyYAML >=6.0.1
- loguru >=0.7.0
- pytest >=7.4.0
- loguru >=0.7.2
- pytest >=7.4.3
- pytest-cov >=4.1.0
39 changes: 33 additions & 6 deletions pyramids/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1475,12 +1475,39 @@ def convert_longitude(self, inplace: bool = False):
-------
Dataset.
"""
dst = gdal.Warp(
"",
self.raster,
dstSRS="+proj=longlat +ellps=WGS84 +datum=WGS84 +lon_0=0 +over",
format="VRT",
)
# dst = gdal.Warp(
# "",
# self.raster,
# dstSRS="+proj=longlat +ellps=WGS84 +datum=WGS84 +lon_0=0 +over",
# format="VRT",
# )
lon = self.lon
src = self.raster
# create a copy
drv = gdal.GetDriverByName("MEM")
dst = drv.CreateCopy("", src, 0)
# convert the 0 to 360 to -180 to 180
if lon[-1] <= 180:
raise ValueError("The raster should cover the whole globe")

first_to_translated = np.where(lon > 180)[0][0]

ind = list(range(first_to_translated, len(lon)))
ind_2 = list(range(0, first_to_translated))

for band in range(self.band_count):
arr = self.read_array(band=band)
arr_rearranged = arr[:, ind + ind_2]
dst.GetRasterBand(band + 1).WriteArray(arr_rearranged)

# correct the geotransform
pivot_point = self.pivot_point
gt = list(self.geotransform)
if lon[-1] > 180:
new_gt = pivot_point[0] - 180
gt[0] = new_gt

dst.SetGeoTransform(gt)
if not inplace:
return Dataset(dst)
else:
Expand Down
30 changes: 0 additions & 30 deletions qodana.yaml

This file was deleted.

16 changes: 8 additions & 8 deletions requirements-optional-packages.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cleopatra >=0.4.0
gdal >=3.7.0, <3.8.1
geopandas >=0.13.2
gdal >=3.7.0
geopandas >=0.14.1
hpc-utils ==0.1.3
loguru >=0.7.0
numpy ==1.25.2
pandas >=2.0.0
pip >=23.2.1
pyproj >=3.6.0
loguru >=0.7.2
numpy >=1.25.2
pandas >=2.1.0
pip >=23.3.1
pyproj >=3.6.1
PyYAML >=6.0.1
Shapely >=2.0.1
Shapely >=2.0.2
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
gdal >=3.7.0, <3.8.1
geopandas >=0.13.2
gdal >=3.7.0
geopandas >=0.14.1
hpc-utils ==0.1.3
loguru >=0.7.0
numpy ==1.25.2
pandas >=2.0.0
pip >=23.2.1
pyproj >=3.6.0
loguru >=0.7.2
numpy >=1.25.2
pandas >=2.1.0
pip >=23.3.1
pyproj >=3.6.1
PyYAML >=6.0.1
Shapely >=2.0.1
Shapely >=2.0.2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name="pyramids-gis",
version="0.5.0",
version="0.5.1",
description="GIS utility package",
author="Mostafa Farrag",
author_email="[email protected]",
Expand Down

0 comments on commit 6e765b5

Please sign in to comment.