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.

25 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
0answers
1k 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: ...
5
votes
0answers
276 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 ...
4
votes
0answers
808 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 ...
3
votes
0answers
65 views

Accessing MODIS subdatasets from the command line?

FYI I'm new to command-line geospatial operations. I'm working with the MODIS BRDF-Albedo Quality product (MCD43A2) and am trying to: 1) do a simple gdal_calc.py operation to mask certain QA values ...
3
votes
0answers
86 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 ...
2
votes
0answers
46 views

gdalwarp cuts off top and right edge of globe from gfs data

I am using data from this GFS forecast: https://nomads.ncdc.noaa.gov/data/gfs4/201905/20190502/gfs_4_20190502_1800_000.grb2 Specifically the bands 102 and 103 containing wind data. I first combine ...
2
votes
0answers
100 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
63 views

Combine two raster with PostGIS or gdal_calc

I want to combine two rasters (GeoTIFF or PostGIS raster) so that the result is a table showing each combination of values and their count. Example: raster 1 raster 2 1 2 3 40 40 10 2 3 3 10 20 ...
1
vote
2answers
112 views

gdal_calc raster calculation fails on 28 GB GeoTiff

I am trying to do a raster calculations on a 28 GB GeoTiff using gdal_calc.py (3.0.4) but the process fails gdal_calc.py -A DEM_0.tif --outfile=DEM_1.tif --calc="A+0.33" --format=GTiff --...
1
vote
0answers
64 views

Getting inconsistent raster output from gdal_calc.py raster calculation

I'm attempting to do what is generally a straightforward raster calculation when I do this in QGIS, but am trying to do this with gdal_calc.py in terminal. The output is close, but produces banding ...
1
vote
0answers
65 views

Get maximum value from two raster using gdal_calc.py with option Ignore NoData calculation enabled

I would like to get maximum value from two raster using gdal_calc.py with option Ignore NoData calculation enabled. My question is similar to this unsolved problem: How do I get the maximum value of ...
1
vote
0answers
183 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
0answers
490 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
0answers
157 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 ...
1
vote
0answers
228 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 ...
1
vote
0answers
91 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 ...
0
votes
0answers
17 views

Running Batch Files with QGIS .asc/.tif files

I have the following two batch files and the following error message in the run window. What I want the Trimming Depths.bat file to do is to create a new .tif file that shows values larger than 0.05m ...
0
votes
0answers
72 views

GDAL: sum of all bands in a raster

I'm familiar with using gdal_calc.py to sum individual raster bands. However, I am curious whether there is an easy way to programmatically sum all bands of a raster into a single value. I have a list ...
0
votes
0answers
71 views

How to sum pixels of two overlapping rasters with different extents

I have two DEM rasters which overlap and have different extents. I would like to create a new raster which sums the pixels where there is an overlap. I tried using gdal_calc first by doing A+B but ...
0
votes
1answer
30 views

Problem with raster calculator gdal_calc.py

I have two rasters. One with the following values: 0,1,2,3,4,5,6,7,8,9,10 and the other one with continuous values ranging from 0 to 10000. I would like to create a raster where only values of the ...
0
votes
0answers
44 views

Mirroring raster using gdal_calc

I am trying to flip (mirror) a raster upside-down. Using following command incoporating numpy function flipud() gdal_calc.py -A input.tif --calc="flipud(A)" --output output.flipud.tif resulted with ...
0
votes
0answers
48 views

gdal_calc in C#

I am writing a .NET core application and have been trying to utilize the Gdal libraries. I have added Gdal.Core and Gdal.Core.WindowsRuntime NuGet packages to my project. I have been able to ...
0
votes
0answers
231 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....
0
votes
0answers
562 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 ...
0
votes
0answers
399 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 (...