Quantcast
Channel: Question and Answer » raster-calculator
Viewing all 43 articles
Browse latest View live

Standardising DEM raster for a MCE

$
0
0

I’m trying to complete a Multi-Criteria Evaluation for an MSc assessment and am in the process of standardising my factor maps. Unfortunately, my DEM layer (ASCII file) keeps changing from this:

enter image description here

To this:

enter image description here

The syntax used in Raster Calculator is: (“DEM” – 0) / (544 – 0) where DEM is the layer, 0 is the minimum values and 544 is the max value.

Has anyone come across this before? Does anyone know how to standardise it so the surface variation is still present?

I’ve done the same for Topographic Wetness Index but that’s done ok (both layers are visualised the same)


Performing raster calculations along line feature or within polygon using QGIS?

$
0
0

I need to add a value to a dem file along a polyline feature or within a polygon. How can I add 100 to the values of the raster cells intersected by my line feature or within my polygon feature.

I would like to know how to do this in QGIS, if possible.

how to calculate the mean value of pixels of a raster in Grass plugin in qgis?

$
0
0

I am using grass plugin in qgis 2.12. I have to estimate the average value of all the pixels but don’t know how to do it.

Using decimals in ArcGIS Raster Calculator tool?

$
0
0

I would like to create a new raster by using the following regression equation in the Raster Calculator tool in ArcGIS 10.3:

Outputras=0,000826345+(0,000203494*"Roads_density.tif")

(“Roads_density.tif” being an existing raster among my set of layers)

However I get the following message error:

ERROR 000989 Python syntax error: Parsing error SyntaxError: invalid syntax (line 1).

When I try :

Outputras=0,8+0,2*"Roads_density.tif" 

the message error disappears.

Is it thus a problem related to the presence of too many decimals ? What do I need to do to force ArcGIS to take in account all the decimals?

Convert 0's to NoData in QGIS Raster Calculator [duplicate]

Sequentially distilling several raster data sets into final map based on first time pixel’s value was greater than zero?

$
0
0

I have 120 daily data sets that contain a value only when a threshold temperature is exceeded. If the threshold has been reached that pixel was assigned a value indicating the day it occurred (the Julian day), all the rest of the cells for that day were assigned a value of zero. I’d like to combine these raster data sets to create a final map indicating the Julian day when the threshold was first reached or exceeded.

I could use the raster calculator (in QGIS it would look something like this):

(“julian1” = 1) * “julian1” + (“julian2” = 2) * “julian2” + (“julian3” = 3)* “julian3” 

up to 120 but I have 30 years of data parsed into 120 day blocks and it would take a really long time. I’ll bet there is a way better solution in either QGIS or ArcMap or a python script.

Using attribute table values as input for raster calculation – modelbuilder and iteration

$
0
0

I have multiple years of daily XY point shapefiles that contains multiple attributes. I would like to choose one attribute from my XY point and perform a raster calculation with that value and apply it to a raster to create a new raster. For example, my XY point is a base station for temperature and I would like to associate temperature with elevation (using a DEM as my raster).

The raster calculation would go something like this:

New raster temp = shapefile temp + (6.5 * (shapefile elev – DEM elev))

Each day has a different temperature. I have been unsuccessful so far in creating a model to perform this action on one day, let alone iterating through multiple days, without having to manually enter in my attribute value (temperature) into the calculation. Raster calculation manually will become very tedious over 2000 days… Does anyone have any suggestions for a tool or sequence of tools that I may have overlooked, and especially how to get it working iteratively in ModelBuilder?

Polygon to raster. How to keep same values?

$
0
0

I have a polygon with values 3, 6, 9, 12, 15, 18, 21, 24, 27 an 30. These are the time it takes for the firetruck to reach certain destinations. Now i want to compare these to another raster that have time for helicopter to reach destinations.

The problem is that when i convert the polygon to raster it doesn’t keep the old values, it instead makes new ones 11, 12, 13, 14, 15, 16, 17, 18, 19 and 20.

Is there a way to keep old values so i can make a correct calculation between the two rasters?

Pic


QGIS raster calculator – crash minidump

$
0
0

I’m new to QGIS and using version 2.10.1-Pisa.

I have two raster layers created from ASTER DEM data. I have one for slope and want to create a binary layer where only pixels between 8 and 60 degrees are included. I’ve tried “Nepal_Mosaic_Slope@1″ >=8 and “Nepal_Mosaic_Slope@1″ <= 60 but it says crash dumped and closes QGIS?? Is there something stupid I am doing?
Once I have done this I want to combine the result with a binary raster of elevation which I assume you can do with merge?

Conditional statement in gdal_calc with result as float, not boolean

$
0
0

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 Raster_Value.

How do I perform that operation in the gdal raster calculator command line

EDIT
I tried radouxju answer and it worked, except for the cell values that didn’t.
here are 3 kinds of results I got

enter image description here

Here is the tool gui and the parameters I’ve entered
enter image description here

How to iterate a raster calculator with a change in the input raster and in the values calculated? Than, how to put the results in a table?

$
0
0

What I do without iteration is the following:

  1. Change radiance to reflectance for band 3 with raster calculator
  2. Samething as #1 on band 4 (the values in the formula are different from #1)
  3. Calculate NDVI with band 3_ref and band 4_ref with raster calculator
  4. Extract by mask with a polygon (the site of interest)
  5. get the mean and the std of the final raster
  6. Put in manually in a table with the attributes: #scene, mean, std

I am looking for a faster way to analyse over 75 scenes. I tried with iterate raster on #4 but it seem to not work on other tasks. The difficulty is that I have to change the input values in the formula for every scene for #1 and 2 than input both output in a formula in #3. Then for #5 and #6 I do it manually. Maybe I can do it with create statistics table? I am not sure How to create a template.dbf?

Raster Calculator subtraction giving wrong difference

$
0
0

I’m performing a pretty simple subtraction:

enter image description here

The values of the resulting raster are correct for some pixels:

enter image description here

But many pixels are calculated wrong:

enter image description here
enter image description here

Which settings do I have to change to get reliable results?

Addition of rasters using raster calculator

$
0
0

I have five classes of rivers as different rasters. fisrt image

and I want to add them all in a new raster file using raster calculator. But when I do this, it creates 16 types of classes, while I want am expecting seven.

second image.

When the classes are combined in the raster calculator, it creates a new class on the final raster file. I want to create a map with a legend that gives me only the seven classes of each raster file.

What am I doing wrong?

Summing pixel values from several raster layers with partial overlap in QGIS?

$
0
0

I have several presence maps (rasters values 1 and 0) from different species. They are all from South America, but they do not have the same extend (i.e., different sizes).

So, I am trying to develop a “richness” map, trying to sum all these values, which would give me a value of the number of species for each pixel (from 1 to 6, as they are six species).

However, when trying to use the raster calculator and other grid analysis tools, this fails because: 1) it shows me only a map with areas where they all overlap (this happens with raster calculator), or 2) fails because the layers are different (different extent, this happens with grid sum, and other analysis tools).

How can I have a map that sums all pixels values, and includes the areas of all the different presence maps?

Conditional statement in ArcGIS Raster Calculator?

$
0
0

I am new to Arcmap… I want to make a conditional statement in Raster calculator that checks if the pixel does not contain water or forest value ,, assign them snow as 1 and vice versa… Like the statement in Erdas Model maker that is “Conditional statement that says if the NDSI mask has identified a pixel as snow it is snow as long as it is not a forest pixel or a water pixel:
CONDITIONAL{(NOT (forest mask) AND NOT (water mask) AND (NDSI mask)) 1} “


How to change value in raster layer?

$
0
0

I have created future temperature raster (tiff format) in ArcGIS. However I want all pixel’s value to be multiply with 10 (constant value). I tried to use con tool and raster calculator in spatial analysis, but it didn’t work or may be I set incorrect parameter.

Can anyone help me to solve this problem?

Adding all Binary Rasters in a Directory Using Raster Calculator in a Standalone Python Script

$
0
0

I have a directory with binary raster files (1 band only) which I need to add in a standalone python script. The problem is the rasters have different number of rows and columns and different resolution (reading them in as numpy arrays and adding them does not work). When I use the raster calculator, it manages to do what I want, but now I need to use it outside QGIS and do it automatically for all rasters in the folder. How can I add all my rasters in my directory inputFolder and create one output raster? I have the following code so far:

inputFolder = "/home/usr/Desktop/"

def findRasters(path, filter):
    for root, dirs, files in os.walk(path, filter):
        for file in fnmatch.filter(files, filter):
            yield os.path.join(root, file)

entries = []

for l in findRasters(inputFolder, '*.tif'):
    fileInfo = QFileInfo(l)
    baseName = fileInfo.baseName()
    rlayer = QgsRasterLayer(l,baseName)
    QgsMapLayerRegistry.instance().addMapLayer(rlayer) 
    layer = QgsRasterCalculatorEntry()
    layer.ref = l.name() + '@1'
    layer.raster = l 
    layer.bandNumber = 1
    entries.append(layer) 

expression = '(' + entries[1].ref + ' + ' + entries[0].ref + ')'
calc = QgsRasterCalculator(expression,'/home/usr/Desktop/final.tif',
                           'GTiff',
                           layers[0].extent(),
                           layers[0].width(),
                           layers[0].height(),
                           entries)

calc.processCalculation()

I am not sure how I should formulate my expression such that it takes into account all rasters in the folder

problem with raster calculator results when subtracting two rasters with different resolutions

$
0
0

I have two elevation datasets which I am trying to subtract to calculate thickness (using ArcGIS raster calculator). The first datset is a tif which is oriented north-south and has a cell size of 5 ft x 5 ft. The second data set is a surfer grid which has a cell size of 10 ft x 10 ft but is rotated by approximately 30 degrees to the east. When I subtract the two rasters, I select bilinear re-sampling in the environments section of raster calculator. However, when I spot check my resulting output raster of thickness, I often get a thickness that is vastly underestimated (e.g. thickness should be 10 ft but the raster output equals a thickness of 2). Strangely enough, other cells that I spot check will have a thickness that is close to what I expect. I also re-ran the same calculation but used nearest neighbor re-sampling; I got the exact same results.

What is causing this discrepancy? Is it the rotated grid? How can I fix this?

Markov chains, cellular automata, and raster algebra

$
0
0

I need to build a probabilistic cellular automaton for simulating land-use changes and am wondering how to implement this in a GIS. I understand that Markov chains are a way of doing this, and IDRISI has some sort of module for Markov chains, but I have no access to IDRISI. Someone said earlier that, with raster data, this can, in theory, be done with any GIS that can do raster algebra. Presumably this means that it can even be done in ArcGIS, and I think I’ve figured out how to build cellular automata in ModelBuilder (once I know with certainty how to make iteration work there).

Still, I can find next to no practical advice on this. Once I have two datasets, one showing the land use at a certain point in time (time A) and the other at a later time (time B), I imagine doing the following (correct me if I’m wrong):

  1. If there are (for example) 3 types of land use, then there are 9 possible things that can happen to a cell from time A to time B; thus, reclassify each dataset such that each land use is represented by a different number (for example, 9, 11, and 14 at time A and 3, 4, and 5 at time B);

  2. Divide one raster by the other, obtaining a raster with 9 possible cell values.

  3. Determine the percentage of cells in the new raster that has each of the 9 values (I forgot, how does one do this in ArcGIS?); those will be the probabilities of each type of change (or lack thereof) in land use.

What I cannot figure out, though, is how to apply these probabilities during the next iteration. Finally, I wonder if there is a way of making an external factor (say, proximity to roads) influence the spatial distribution (not the overall likelihood) of change in my model.

Can anyone recommend where to find information on how to do this in ArcGIS?

unexpected output from raster calculator function

$
0
0

Working in ArcMap, I am trying to convert the logit values in raster into their actual probabilities (logistic regression,) using the following function:

1/(1+Exp(-”sn_topo_poly_log”))

Ive used this function before and it should return a raster with values from 0 to 1. Instead I get a raster with all values=0.

the input raster “sn_topo_poly_log,” looks correct and has values from close to zero to -871361

Viewing all 43 articles
Browse latest View live