peckhams / topoflow36

TopoFlow is a component-based, spatial hydrologic model along with a large collection of utilities for data preparation, visualization and so on. Distributed as a Python package and version 3.6 has been updated to run in Python 3.*.
MIT License
26 stars 10 forks source link

Bug in regrid.py #3

Open binh-vu opened 4 years ago

binh-vu commented 4 years ago

The get_raster_bounds in topoflow36.utils.regrid returns incorrect bounds for some GeoTIFF files. The problem is in these lines:

ulx, xres, xskew, uly, yskew, yres  = ds.GetGeoTransform()
lrx = ulx + (ds.RasterXSize * xres)
lry = uly + (ds.RasterYSize * yres)

The function ds.GetGeoTransform from GDAL does not always return the upper left corner of the raster. Instead, it return an affine transformation from a corner of the raster, with delta x and delta y (i.e., xres and yres), and in the case of GLDAS tiff files, ds.GetGeoTransform returns the lower left corner instead of upper left corner. Hence the function get_raster_bounds returns incorrect boundary.