Skip to content

Commit

Permalink
version 1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ghislainv committed Jul 8, 2024
1 parent bcdb2d5 commit f9b2522
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

forestatrisk 1.2.2
++++++++++++++++++

* Replacing ``gdal.TermProgress`` with ``gdal.TermProgress_nocb``.
* Changes: https://github.com/ghislainv/forestatrisk/compare/v1.2.1...v1.2.2

forestatrisk 1.2.1
++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion forestatrisk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# https://peps.python.org/pep-0008/#module-level-dunder-names
__author__ = "Ghislain Vieilledent"
__email__ = "[email protected]"
__version__ = "1.2.1"
__version__ = "1.2.2"

# GDAL exceptions
from osgeo import gdal
Expand Down
2 changes: 1 addition & 1 deletion forestatrisk/data/compute/compute_biomass_avitabile.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def compute_biomass_avitabile(proj, extent, verbose=False):
"""

# Callback
cback = gdal.TermProgress if verbose else 0
cback = gdal.TermProgress_nocb if verbose else 0

# Creation options
copts = ["COMPRESS=DEFLATE", "PREDICTOR=2", "BIGTIFF=YES"]
Expand Down
2 changes: 1 addition & 1 deletion forestatrisk/data/compute/compute_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def compute_distance(input_file, dist_file, values=0,
# Compute distance
val = "VALUES=" + str(values)
use_input_nodata = "USE_INPUT_NODATA=" + ui_nodata
cb = gdal.TermProgress if verbose else 0
cb = gdal.TermProgress_nocb if verbose else 0
gdal.ComputeProximity(
srcband,
dstband,
Expand Down
13 changes: 12 additions & 1 deletion forestatrisk/data/compute/compute_forest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Processing forest data."""

import subprocess
from glob import glob

from osgeo import gdal

Expand All @@ -22,11 +23,21 @@ def compute_forest(proj, extent, verbose=False):
"""

# Callback
cback = gdal.TermProgress if verbose else 0
cback = gdal.TermProgress_nocb if verbose else 0

# Creation options
copts = ["COMPRESS=DEFLATE", "PREDICTOR=2", "BIGTIFF=YES"]

# Make vrt
tif_forest_files = glob("forest_tiles/forest_*.tif")
forest_vrt = gdal.BuildVRT(
"forest.vrt",
tif_forest_files,
callback=cback)
# Flush cache
forest_vrt.FlushCache()
forest_vrt = None

# Reproject
param = gdal.WarpOptions(
warpOptions=["overwrite"],
Expand Down
2 changes: 1 addition & 1 deletion forestatrisk/data/compute/compute_gadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def compute_gadm(ifile, ofile, proj, verbose=False):

aoi_latlon_file = opj(opd(ofile), "aoi_latlon.gpkg")

cb = gdal.TermProgress if verbose else 0
cb = gdal.TermProgress_nocb if verbose else 0

# Change layer and file names
if not os.path.isfile(aoi_latlon_file):
Expand Down
2 changes: 1 addition & 1 deletion forestatrisk/data/compute/compute_osm.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def compute_osm(proj, extent, verbose=False):
print(rtn.stdout)

# Callback
cback = gdal.TermProgress if verbose else 0
cback = gdal.TermProgress_nocb if verbose else 0

# Creation options
copts = ["COMPRESS=DEFLATE", "PREDICTOR=2", "BIGTIFF=YES"]
Expand Down
2 changes: 1 addition & 1 deletion forestatrisk/data/compute/compute_srtm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def compute_srtm(proj, extent, verbose=False):
"""

# Callback
cback = gdal.TermProgress if verbose else 0
cback = gdal.TermProgress_nocb if verbose else 0

# Creation options
copts = ["COMPRESS=DEFLATE", "PREDICTOR=2", "BIGTIFF=YES"]
Expand Down
2 changes: 1 addition & 1 deletion forestatrisk/data/compute/compute_wdpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def compute_wdpa(iso, proj, extent, where=None, verbose=False):
"""

# Callback
cback = gdal.TermProgress if verbose else 0
cback = gdal.TermProgress_nocb if verbose else 0

# Defaut value for where
if where is None:
Expand Down
2 changes: 1 addition & 1 deletion forestatrisk/predict/predict_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def predict_raster(
)
rand_uuid = uuid.uuid4()
vrt_file = f"/vsimem/var_{rand_uuid}.vrt"
cback = gdal.TermProgress if verbose else 0
cback = gdal.TermProgress_nocb if verbose else 0
gdal.BuildVRT(vrt_file, raster_list,
options=param, callback=cback)
stack = gdal.Open(vrt_file)
Expand Down
2 changes: 1 addition & 1 deletion forestatrisk/predict/predict_raster_binomial_iCAR.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def predict_raster_binomial_iCAR(
)
rand_uuid = uuid.uuid4()
vrt_file = f"/vsimem/var_{rand_uuid}.vrt"
cback = gdal.TermProgress if verbose else 0
cback = gdal.TermProgress_nocb if verbose else 0
gdal.BuildVRT(vrt_file, raster_list,
options=param, callback=cback)
stack = gdal.Open(vrt_file)
Expand Down

0 comments on commit f9b2522

Please sign in to comment.