Questions tagged [gdal-calc]

Command line raster calculator with numpy syntax. Use any basic arithmetic supported by numpy arrays such as +-*\ along with logical operators such as >. Note that all files must have the same dimensions, but no projection checking is performed. Often referred to as gdal_calc.py or just gdal_calc.

0
votes
0answers
12 views

Gdal_calc changing the values incorrectly

I am trying to re-project a file to a uniform grid EPSG:4326 and for that I am using the command: gdalwarp -t_srs EPSG:4326 -srcnodata -32767 HDF5:"LC08_L1TP_029037_20190611_20190611_01_RT_L2GEN_2.nc"...
0
votes
1answer
17 views

GDAL Calc Set Specific Values to Another Number

I have a GeoTiff raster with a format of Float32 and values 0.00 to 5.00. I am attempting to change all raster cells with a value below 0.10 to 0.10, and leave all other cells in the raster dataset ...
0
votes
2answers
69 views

Classify DEM pixels

I have a differential surface model dataset. That was made: DSM subtracted from DTM, so for example trees have negative height. It is a raster (TIFF) dataset, Type=Float32. I want to create a ...
0
votes
1answer
48 views

Gdal_calc outputs image with no projection

I am trying to convert a pixel value above 0.02 to be nodata. However, the output file comes out with no projection. When I assign projection, QGIS loads it in the wrong place. gdal_calc.py -A "000-...
0
votes
1answer
24 views

Calculate max of all cells of a raster with gdal_calc.py

I want to calculate max of all cells of a raster, i.e. the result should be a scalar. Regardless of what I call amax, max, numpy.max(A, axis=0) I always get a raster with the same WxH as the original ...
1
vote
0answers
70 views

gdal_calc.py result are false and not the same as “direct” calculation

I need to do the raster calculator operation as "raster + constant" in Python. The input rasters are DEM data with float original type and -9999 for the NoData. The constant is float too. In 1st way, ...
1
vote
1answer
58 views

`gdal_calc.py` only outputs as Int16 even though set to Float32

The following code only outputs integer even though set to float32. 'gdal_calc.py -A input_raster.tif --A_band 1 --outfile output_raster.tif --calc "0.005 * A.astype(float)" --NoDataValue -32767 --...
0
votes
0answers
97 views

Error using gdal_calc.py with gdal 2.2.1 on linux (undefined symbol: GDALCreateDriver)

My gdal libraries work properly with any other function used. However, using gdal_calc.py I run into troubles. I use gdal from the shell (linux) with this command: gdal_calc.py -A /somepath/somefile....
1
vote
1answer
284 views

How to use gdal_calc.py to process multiple bands

I have 2 rasters (raster1 and raster2) with 5 bands for each one. I want to do some calculation using all bands and write the output to a file with 5 bands. I try this command : gdal_calc.py -A ...
0
votes
0answers
33 views

Recalculate pixel value based on stats

I want to recalculate pixel values of raster based on raster stats. In terms of gdal, I want to use gdal_calc together with gdal_stats. Is it possible to somehow pass an output of gdal_stats into ...
0
votes
1answer
154 views

Meaning of NULL when using condition in gdal_calc

I am confused with the results of using a condition in gdal_calc. Initially I thought that gdal_calc was setting pixels to nodata where a condition is not met. In the documentation (http://www.gdal....
3
votes
0answers
330 views

Merging two overlapping rasters

There are two rasters A and B. A is smaller but within B and since A has more up-to-date pixel values, I was able to merge A and B with "Mosaic raster layers" tool in QGIS which replaces B pixel ...
1
vote
0answers
235 views

Calculate Raster mean with gdal_calc - unexpected result

I have in input a single band 2 axis tif raster (float32 values). Using gdal_calc I need to produce an output raster (same dimensions of input) that contains in every pixel the mean value of the whole ...
1
vote
0answers
214 views

Run gdal_calc with more than 26 input bands

I'm trying to average 30 greyscale netCDF files pixel-by-pixel using gdal_calc.py. However the script seems to require the input files to be enumerated with letters A-Z, so I'm four letters short. ...
1
vote
1answer
57 views

GDAL calculation without stop python.exe error?

I want to create a simple raster calculation using python and GDAL and specific gdal_calc.py in osgeo4w shell. BUT any time that before finish my script python stopping I take error : python.exe ...
1
vote
0answers
44 views

Python GDAL calculation differend results

hello i want to create a raster calculation using python GDAL. First i try to use gdal_calc.py that work correct my new raster is correct is the some if i use QGIS raster calculation (some min/max all ...
3
votes
2answers
451 views

Reclassify raster in QGIS with GDAL raster calc

I'm trying to reclassify some categorical raster data in QGIS using GDAL raster calculator. My input Geotiff has four values, [26, 27, 31, 32] which I want reclassified to [1.25, 2.5, 3.75, 5] ...
1
vote
0answers
130 views

gdal_calc - FutureWarning: comparison to `None` will result in an elementwise object comparison in the future

I use gdal_calc in the loop: for inp, out in zip(input, output): input_str = ''.join(inp) print input_str output_str = ''.join(out) print output_str gdal_calc = 'python ...
2
votes
1answer
411 views

Inserting python variables into gdal_calc expression?

Is it possible to insert a python variable into gdal_calc expression? For example: mean = [stats[2]] ##mean value gdal_calc.py -A Input.tif --outfile=Output.tif --calc="1*(A>=mean)" --NoDataValue=...
3
votes
0answers
464 views

Difference between gdal_calc and QGIS raster calculator

I am hoping someone can help me with an issue I am having with gdal_calc. I am looking to create NDVI rasters from 4 band 8 bit ortho tiles. I have processed the tiles using the following calculation: ...
0
votes
1answer
213 views

Binarise Raster within a range with gdal_calc.py [closed]

I am looking to utilise gdal_calc to batch binarise a few hundred rasters. My problem is in relation to gdal_calc and the correct syntax for --calc to do what I wish to achieve. Using QGIS Raster ...
0
votes
1answer
274 views

gdal calc to convert multiple values

I'm trying to use GDAL calc to convert values in a .tif file, I've done this before with GDAL calc but for converting to a single value. Now I'm trying to convert multiple values in this fashion: 0.0 ...
2
votes
1answer
135 views

Gdal Calc quiet option not working

So I'm trying to use the quiet option for gdal calc, this is a cut of my code: call([sys.executable, 'C:\Program Files (x86)\GDAL\gdal_calc.py', '-A', Outer_Output_Raster, "--outfile=" + ...
1
vote
0answers
315 views

python GDAL raster calculation error message

hello I try to follow this post and Friend commend : import os gdal_calc = 'python C:/PROGRA~2/GDAL/gdal_calc.py -A d:/mnt_5x5.tif --outfile=d:/test.tif --calc="A+1"' os.system(gdal_calc) but I ...
1
vote
1answer
754 views

Gdal_calc NDVI for many rasters

Can anybody help me to solve a problem with running gdal_calc for many rasters? I have several multispectral images and I need a batch to perform NDVI calculation. I started with gdal code for one ...
1
vote
1answer
476 views

Raster calculator syntax to gdal_calc

I am looking to perform raster math on two large rasters (slope ~1.3GB and aspect ~2.4GB). When I use the GIS raster calculator code below, QGIS errors out (out of memory), which is odd considering ...
1
vote
0answers
165 views

Raster Calculation Using GDAL

I want to perform raster calculation from GDAL tool. I am using the formula as, gdal_calc.py -A Input_File.tif --outfile=yourOutput.tif -- calc="(A>=2200)*A" --NoDataValue=0 --type='Float32' But ...
4
votes
0answers
154 views

How do I get the maximum value of raster cells ignoring nodata with gdal_calc?

I have two integer rasters, A and B, with the same dimensions and cell sizes. I want to compare each cell in A with each cell in B and keep the maximum value. In cases where both have nodata, I want ...
0
votes
0answers
254 views

calculate percentiles with gdal_calc

I am trying to calculate percentiles with gdal_calc.py using my command line. I have a raster stack (11bands) and I would like to calculate the 0.85 percentile for each pixel over the entire stack (...
6
votes
1answer
1k views

How to indicate nodata into gdal_calc formula

I have a recurrent problem with gdal_calc. Say I have two rasters I need to sum together, in which the same nodatavalue is set (e.g. --NoDataValue = 0). In order to account for the fact that nodata +...
2
votes
0answers
95 views

gdal_calc.py does not work under sbt

I run a command line gdal_calc.py in a scala script. I run this script with 'sbt run' on my terminal. I got this error : Traceback (most recent call last): File "/usr/local/bin/gdal_calc.py", line ...
1
vote
0answers
76 views

GDAL_CALC weird results

Can anyone explain why for gdal_calc results differ in the two cases below? case 1: (A>0)-(A<10)+(A>0)-(A<10) case 2: ((A>0)-(A<10)) + ((A>0)-(A<10)) Mathematically speaking, the two ...
3
votes
0answers
67 views

Python stops during band algebra in GDAL calculator within modeler in QGIS

I'm trying to calculate four greenness indices using the GDAL calculator within the graphic modeler in QGIS 2.14.7 Essen. The tool systematically crashes with a Windows message stating that Python ...
4
votes
1answer
454 views

Wrong values using gdal_calc.py

I'm using gdal_calc.py to do some raster operations. The raster files stores precipitation values that are between 0 - 40 l/m² aprox. in some cases and the operations i'm trying to do: Values greater ...
12
votes
3answers
7k views

gdal_calc raster calculator syntax for logical operators and other functions

In documentation for gdal_calc it is stated Command line raster calculator with numpy syntax. Later on there are few examples where in one of them: gdal_calc.py -A input.tif --outfile=result.tif --...
5
votes
2answers
2k views

How to replace pixel values in a single band DEM?

I have a single band DEM as a GeoTiff. I would like to replace values above or below a certain threshold with 0. Can I do that with GDAL?
2
votes
1answer
152 views

Problem with algebra formulas for work with gdal_calc.py

I'm trying to update some values of a raster based on another raster. 1st raster (A): landuse data (values from 10 to 240) 2nd raster (B): mask data (only nodata values and a given value, for ...
4
votes
1answer
3k views

Conditional statement in gdal_calc with result as float, not boolean

Many examples on gis.se that refer to gdal_calc give a boolean example. example 1 example 2 If I need to calculate a conditional statement on a float: If Raster_Value >= 1024, then 1024; else ...
4
votes
1answer
638 views

Does gdal_calc only support 26 input raster files at a time?

In gdal_calc.py, input files are specified with letters A-Z. Here are two files, input.tif and input2.tif, being averaged into result.tif: gdal_calc.py -A input.tif -B input2.tif --outfile=result....
3
votes
2answers
534 views

Raster Caculator Qgis 2.6 v/s Gdal_calc.py by Terminal

I need calculated monthly mean of Snowcover data by MODIS product, and then modify this script gdal_calc.py in this section # create alphabetic list for storing input layers AlphaList=["A","B","C","...
6
votes
1answer
2k views

How does gdal_calc numpy operators work?

Gdal_calc manual Gdal_calc is introduced as : gdal_calc.py - Command line raster calculator with numpy syntax gdal_calc.py [-A <filename>] [--A_band] [-B...-Z filename] [other_options] OPTIONS:...
10
votes
3answers
1k views

How to create composite hillshade?

The concept of composite hillshade is to combine multiple hillshades with different sunlight orientation to avoid blind spot. It requires to merge 3 hillshades images with 315⁰ (NW sunlight, default ...
3
votes
1answer
219 views

How to average gdal_hillshades?

For some unknow reason, my average of 3 hillshades is very dark : gdaldem hillshade input.tif hillshades_C.tmp.tif -s 111120 -z 5 -az 315 -alt 60 -compute_edges gdaldem hillshade input.tif ...
1
vote
2answers
390 views

gdal_calc : fails with value 0?

I working to invert values of a one-band tif files (download sample). If i use 254 it works: $ gdal_calc.py -A ./shadedrelief.tmp.tif --outfile=whited.tmp.tif --calc="254*(A>180)" 0 .. 10 .. ...
34
votes
3answers
4k views

Creating transparent hillshade?

I get elegant transparent hillshades via a combination gdal and convert. Compare to grey-based hillshade commonly used, such transparent hillshades are very cool because they can be placed between the ...