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@...
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) &...
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 ...
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 ...
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 ...
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) ...
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 ...
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'...
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 ...
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....
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
...
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.
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:...
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 ...
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 ...
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 ...
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 ...
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
...
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)
# ...
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(...
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]...
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("...
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]= ...
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 ...
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 ...
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(...
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 ...
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")
...
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.
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:
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
reclassify × 306raster × 109
arcgis-desktop × 85
qgis × 70
arcpy × 46
spatial-analyst × 40
arcmap × 29
raster-calculator × 28
google-earth-engine × 22
modelbuilder × 22
r × 21
grass-gis × 20
python × 15
arcgis-10.1 × 14
dem × 12
gdal × 11
arcgis-10.0 × 11
arcgis-pro × 11
arcgis-10.2 × 10
qgis-processing × 10
numpy × 9
error-999999 × 8
vector × 7
classification × 7
pyqgis × 6