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@...
knussear's user avatar
  • 331
21 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) &...
Mattijn's user avatar
  • 956
17 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 ...
Jot eN's user avatar
  • 952
15 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 ...
Djaner Emin's user avatar
12 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 ...
Phil Barlow's user avatar
11 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) ...
Damon's user avatar
  • 111
10 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 ...
Tyler Erickson's user avatar
9 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'...
etrimaille's user avatar
  • 7,050
9 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 ...
Jeffrey Evans's user avatar
8 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....
dmh126's user avatar
  • 6,622
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 ...
Antonio Falciano's 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.
ArMoraer's user avatar
  • 5,569
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:...
RutgerH's user avatar
  • 3,245
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 ...
user6072577's user avatar
  • 1,502
7 votes

Save and load the classes definition table in the QGIS reclassify by table tool

This is a workaround using Reclassify by layer tool (so it is not a direct answer to your query). (1) Prepare a classification table by a spreadsheet software ( I used MS-Excel). (2) Drag and Drop ...
Kazuhito's user avatar
  • 30.4k
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 ...
Dan C's user avatar
  • 12.1k
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 ...
Guz's user avatar
  • 3,156
6 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 ...
Kazuhito's user avatar
  • 30.4k
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) # ...
Katie's user avatar
  • 350
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(...
Rodrigo E. Principe's 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]...
Spacedman's user avatar
  • 61.5k
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("...
umbe1987's user avatar
  • 3,737
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]= ...
Hornbydd's user avatar
  • 42.6k
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 ...
mgri's user avatar
  • 16.1k
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 ...
Miron's user avatar
  • 1,231
5 votes
Accepted

Reclassifying NDWI using Google Earth Engine?

What about values equal to 0.4? .gt(): greater than .gte(): greater or equal than Then: // Reclassify each image in NDWI collection and calculate yearly composite var reclassified = NDWI.map(...
Rodrigo E. Principe's user avatar
5 votes

Reclassify values of the land use land cover class of Copernicus Global Land Cover Layers in Google Earth Engine

The variable lulc1 is an image collection with 5 elements (images between years 2015 and 2019). If you want to reclassify it, it is preferable to map entire collection with a function. Following code ...
xunilk's user avatar
  • 29.4k
4 votes
Accepted

Reclassify in QGIS using Raster Calculator?

Assuming that these values between 76 and 150 exist at the map, the correct expression to do that is: ("ea06063_ea3606mod@1" >= 76 AND "ea06063_ea3606mod@1" <= 150)*("ea06063_ea3606mod@1") ...
xunilk's user avatar
  • 29.4k
4 votes
Accepted

How can I reclassify a raster by zone?

Reclass the lake layer to (0) lake, and (1) Everywhere else that covers the entire river layer (union). Multiply (times) this output by your rivers.
If you do not know- just GIS's user avatar
4 votes

Reclassify a raster file with quantiles

You can do in QGIS processing toolbox. Use the model builder and build a model with r.quantile followed by r.recode. Something like this:
lcoandrade's user avatar

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