Skip to content

Commit

Permalink
Replacing gdal_calc.py by gdal_calc
Browse files Browse the repository at this point in the history
gdal_calc.py does not work on Windows, while gdal_calc command works
on both Windows and Linux.
  • Loading branch information
ghislainv committed Jul 10, 2024
1 parent f9b2522 commit cd17b62
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions forestatrisk/data/compute/compute_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def compute_forest(proj, extent, verbose=False):
# Compute fcc
# Command to compute fcc
cmd_str = (
'gdal_calc.py --overwrite '
'gdal_calc --overwrite '
'-A {0} -B {1} '
'--outfile={2} --type=Byte '
'--calc="255-254*(A==1)*(B==1)-255*(A==1)*(B==0)" '
Expand Down Expand Up @@ -119,7 +119,7 @@ def compute_forest(proj, extent, verbose=False):
rast_in = [f"forest_t{i + k}_src.tif" for i in range(nbands)]
rast_out = [f"forest_t{i + k}.tif" for i in range(nbands)]
cmd_str = (
'gdal_calc.py --overwrite '
'gdal_calc --overwrite '
'-A {0} -B aoi_proj.tif '
'--outfile={1} --type=Byte '
'--calc="A*B" '
Expand All @@ -135,7 +135,7 @@ def compute_forest(proj, extent, verbose=False):
rast_in = [f"fcc{i + k}{i + k + 1}_src.tif" for i in range(nbands - 1)]
rast_out = [f"fcc{i + k}{i + k + 1}.tif" for i in range(nbands - 1)]
cmd_str = (
'gdal_calc.py --overwrite '
'gdal_calc --overwrite '
'-A {0} -B aoi_proj.tif '
'--outfile={1} --type=Byte '
'--calc={2} '
Expand All @@ -150,7 +150,7 @@ def compute_forest(proj, extent, verbose=False):

# Compute raster fcc13.tif for forecast (no need to crop with borders)
cmd_str = (
'gdal_calc.py --overwrite '
'gdal_calc --overwrite '
'-A {0} -B {1} '
'--outfile={2} --type=Byte '
'--calc="255-254*(A==1)*(B==1)-255*(A==1)*(B==0)" '
Expand All @@ -166,7 +166,7 @@ def compute_forest(proj, extent, verbose=False):
# Compute raster fcc123.tif
# (0: nodata, 1: t1, 2: t2, 3: t3)
cmd = (
'gdal_calc.py --overwrite '
'gdal_calc --overwrite '
'-A forest_t1.tif -B forest_t2.tif -C forest_t3.tif '
'--outfile=fcc123.tif --type=Byte '
'--calc="A+B+C" '
Expand Down

0 comments on commit cd17b62

Please sign in to comment.