23 votes

Performing Raster Reclassification in QGIS

I was able to reclassify a raster using the raster calculator Here the "Habitat" raster is reclassed from continuous values (0-1) to discrete values of 1,2,3 ("Habitat@1" < 0.3)* 1 + (("Habitat@...
user avatar
  • 330
20 votes

Raster reclassify using python, gdal and numpy

Instead of doing the reclassification as a double for loop described by dmh126, do it using np.where: # reclassification lista[np.where( lista < 200 )] = 1 lista[np.where((200 < lista) &...
user avatar
  • 886
12 votes
Accepted

When to use Con or Reclass

you can do more with Con than with Reclass, for example you can have continuous output value with Con. You can also use some map algebra within your statement, and you can have multiple inputs. ...
user avatar
  • 48.5k
12 votes
Accepted

Reclassifying raster using GDAL?

gdal_calc can be used for a reclassification of many classes. For example, you can change values below (and equal) 12 to 10, values of 20, 30, 40, 50 stays the same, and values between above 50 and ...
user avatar
  • 826
11 votes

Performing Raster Reclassification in QGIS

QGIS now has two native raster reclassify algorithms Reclassify by layer - allows you to use a vector layer to dictate your ranges Reclassify by table - works much like ArcGIS raster reclassify ...
user avatar
10 votes

Reclassifying rasters using GDAL and Python?

Yes another way exists. Just use gdal_calc.py For example, below will convert the values below 3 to 0 and above 3 to 1. You can use equals as well. gdal_calc.py -A C:temp\raster.tif --outfile=...
user avatar
10 votes

Reclassifying raster values in Google Earth Engine?

The accepted solution addresses the very specific case at hand, and while admirably clever (kudos for that), does not answer the question, which is "How to reclass ranges in GEE". A more ...
user avatar
9 votes

Raster reclassify using python, gdal and numpy

Here's a basic example using rasterio and numpy: import rasterio as rio import numpy as np with rio.open('~/rasterio/tests/data/rgb1.tif') as src: # Read the raster into a (rows, cols, depth) ...
user avatar
  • 91
9 votes
Accepted

Reclassifying raster values in Google Earth Engine?

ee.Image.remap() operates on individual values, not ranges of numbers like your example shows. Given that you are trying to convert the slope values to a set of bins with equal spacing, you can just ...
user avatar
8 votes

Performing Raster Reclassification in QGIS

With the Advanced Interface option of the toolbox, I use the Reclassify Grid Values from the SAGA GIS, It a really intuitive tool with options of reclassification by single value, range and using a ...
user avatar
8 votes

Reclassifying raster using GDAL?

gdal_reclassify is an unofficial Python tool, based on Python GDAL bindings, able to reclassify according to several classes of values. Requirements: python numpy gdal binaries python-gdal bindings ...
user avatar
8 votes
Accepted

Raster calculator reclass 0 as 0 QGIS

Simply write "raster_name@1" != 0 AND "raster_name@1" <= 15 in order to set all values between 1 and 15 to 1, and everything else to 0.
user avatar
  • 5,401
8 votes
Accepted

Calculating statistics per area for categorical raster using R?

In R, you can extract the raster data for each polygon and then summarize it. First, lets create some data (FYI, you can read in a shapefile using raster::shapefile or rgdal::readOGR and a raster ...
user avatar
7 votes
Accepted

Raster reclassify using python, gdal and numpy

Here you have a simple python script for reclassification, I wrote it and it works for me: from osgeo import gdal driver = gdal.GetDriverByName('GTiff') file = gdal.Open('/home/user/workspace/raster....
user avatar
  • 6,376
7 votes
Accepted

Reclassify a raster value to -9999 and set it to the nodata value using python and or gdal

If you are looking for an easy way to change specific pixels to NoData (Nan) or -9999 please take a look at this alternative script I wrote: # -*- coding: utf-8 -*- """ Created on Wed Aug 12 21:33:...
user avatar
  • 2,965
7 votes

Reclassify a raster file with quantiles

If it is just for visualisation, then you can adjust how the raster is displayed in QGIS, by choosing single band pseudo colour with discrete colour interpretation - you can then adjust the boundaries ...
user avatar
  • 1,372
6 votes

IF-Statement in Field Calculator

In Python: def function(field): if field>4: return "0.5" else: return "A" And below: function(!choose from Fields!)
user avatar
  • 6,376
6 votes

Reclassifying float raster using QGIS

You can do this with the raster calculator in QGIS. The example @Fezter refers to, is unfortunately extremely simplified. Lets say you have values from 1 to 360 that you want to reclassify into 3 ...
user avatar
  • 61
6 votes

Classifying DEM according to elevation in R?

You can use the reclassify function in the raster package to reclassify the DEM. The general idea is to generate a reclass matrix which provides the instructions on how to reclassify the continuous ...
user avatar
  • 50.2k
6 votes
Accepted

Reclass to decimals

Multiply everything by orders of magnitude until you are working with integers rather than decimals. In other words, if your raster has values of 1-10, and you want to reclassify some of those values ...
user avatar
  • 12k
6 votes
Accepted

Lapply function on raster iterating through SPDF polygons in R

You can try crop and mask instead of only masking over the Raster Layers. Try the reproducible and commented code below. In this example, using crop reduced ~ 92% the size of the objects in the R ...
user avatar
  • 2,976
6 votes
Accepted

Create presence/absence (0/1) rasters for every value in categorical raster in R?

The raster package has a function to do this for you in one line. Use layerize(): library(raster) # make an example raster r <- raster(nrow=100, ncol=100) r[] <- round(runif(ncell(r),1,4),0) # ...
user avatar
  • 340
6 votes
Accepted

Remap with number-limits and not individual values in GEE

I think what you need is something like this: var random = ee.Image.random() var customRemap = function(image, lowerLimit, upperLimit, newValue) { var mask = image.gte(lowerLimit).and(image.lt(...
user avatar
6 votes
Accepted

Reclassifying rasterstack in R?

Your reclassification matrix isn't right - I suspect the 0.990 on rows 3 and 4 should be 0.099 - as it is the rows make up overlapping classes so the function throws an error: > reclmat [,1]...
user avatar
  • 51k
6 votes

Arcpy reclassify with function

This is how I would do it (it requires the Spatial Analyst extension which I think you have): import arcpy from arcpy.sa import * arcpy.CheckOutExtension = "Spatial" ndvi_raster = Raster("...
user avatar
  • 3,497
5 votes
Accepted

Reclassifying a polygon using ArcGIS field calculator?

OK the syntax is incorrect, the example code using fields from my dataset will help you set up the correct VB script structure. if [NAID] = 23 or [NAID] = 38 then x = 5 elseif [NAID] = 34 or [NAID]= ...
user avatar
  • 38.3k
5 votes

Raster reclassify using python, gdal and numpy

Just to complete the answer from @Mattijn, I think that will lead into a problem if the input classes overlap with the output classes. I don't want my new value to be changed by the next rule. I don'...
user avatar
  • 5,665
5 votes
Accepted

Reclassify a Vector Landuse file using QGIS

This is an example (please modify as necessary). "landuse" should be your actual field name of original class. CASE WHEN "landuse" = 1 THEN 5 WHEN "landuse" = 2 THEN 0 WHEN "landuse" = 3 THEN 10 ...
user avatar
  • 29k
5 votes
Accepted

PyQGIS GRASS r.reclass from Processing without result

There are some syntax errors. If you run this code from the Python Console: import processing processing.alghelp("grass7:r.reclass") you will get: ALGORITHM: r.reclass - Creates a new map layer ...
user avatar
  • 15.5k
5 votes
Accepted

Algorithm r.reclass in QGIS gives same results with different reclass rules

The problem, as you can see from the log, is that r.reclass rounds up your raster values to either 0 or 1, depending on the value. That is because r.reclass only works with integer input values. In ...
user avatar
  • 1,211

Only top scored, non community-wiki answers of a minimum length are eligible