Skip to content

Commit

Permalink
dataset/crop/bugfix/up-updated-extent-for-cropped-raster (#75)
Browse files Browse the repository at this point in the history
* add exception in the stats method to bridge error in the GetStatistics method

* remove the bug test

* correct the gdal error when cutline is false in gdal.wrap

* test __str__ and __repr__
  • Loading branch information
MAfarrag authored Dec 31, 2023
1 parent d645dd6 commit b540ab2
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 235 deletions.
4 changes: 2 additions & 2 deletions docs/dataset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -742,9 +742,9 @@ Parameters
method: [String]
resampling technique default is "Nearest"
https://gisgeography.com/raster-resampling/
"nearest neigbour" for nearest neighbour,"cubic" for cubic convolution,
"nearest neighbour" for nearest neighbour,"cubic" for cubic convolution,
"bilinear" for bilinear
maintain_alighment : [bool]
maintain_alignment : [bool]
True to maintain the number of rows and columns of the raster the same after re-projection. Default is False.
Returns
Expand Down
8 changes: 4 additions & 4 deletions examples/MatchTwoRasters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
match two rasters
"""
#%links
# %links
import os

rpath = r"C:\MyComputer\01Algorithms\gis\pyramids"
Expand All @@ -17,11 +17,11 @@
from pyramids.dataset import Dataset

# import matplotlib.pyplot as plt
#%% inputs
# %% inputs
RasterAPath = f"{rpath}/examples/data/DEM5km_Rhine_burned_acc.tif"
RasterBPath = f"{rpath}/examples/data/MSWEP_1979010100_reprojected.tif"
SaveTo = f"{rpath}/examples/data/MSWEP_1979010100_Matched.tif"
#%% Read the Input rasters
# %% Read the Input rasters
# the source raster is of the ASCII format
src = gdal.Open(RasterAPath)
src_Array = src.ReadAsArray()
Expand All @@ -45,7 +45,7 @@

# %% Match the NODataValue
# TODO : fix bug in nearestneighbor
NewRasterB_ND = Dataset._crop_alligned(src, NewRasterB)
NewRasterB_ND = Dataset._crop_aligned(src, NewRasterB)

NoDataValue = NewRasterB_ND.GetRasterBand(1).GetNoDataValue()

Expand Down
2 changes: 1 addition & 1 deletion pyramids/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
)

INTERPOLATION_METHODS = {
"nearest neigbour": gdal.GRA_NearestNeighbour,
"nearest neighbour": gdal.GRA_NearestNeighbour,
"cubic": gdal.GRA_Cubic,
"bilinear": gdal.GRA_Bilinear,
}
Expand Down
Loading

0 comments on commit b540ab2

Please sign in to comment.