Using GRASS and the r.reclass module, yes. However, you actually need to use the keyword "thru".
For a raster elevation grid, to be reclassified into values based on 100m-intervals:
500 thru 599.99 = 500
600 thru 699.99 = 600
700 thru 799.99 = 700
Etc.. And you save that into a notepad text document(with no spaces between lines). Then when ...
beside @R.K. answer, you can use r.null in grass too.
r.null - Manages NULL-values of given raster map.
Set specific values of a classified map to NULL:
r.null map=landcover.30m setnull=21,22
Set NULL-values of a map to a specific value:
r.null map=fields null=99
i hope it helps you...
yes, r.reclass is for reclassing thematic rasters, like the Corine Land Cover. It will work for your data, but the routine will cast the float numbers to integers before doing the reclass, so it might lead to unexpected results.
What you are looking for is r.recode
The rules are defined in many formats, one of those is the following:
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.
However, if you need an output with a large number of classes, reclass is easier to use because you can use the built-in partitioning methods based on the histogram. ...
you can do this with arcpy, if you want. In this code, any input cell with a value 9999 will be set to NoData in the output raster, and the remaining cells will retain their original value.
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outSetNull = SetNull("elevation", "elevation", "VALUE = 9999")
I think the RasterCalc plugin should be able to solve your problem. Once you've installed it, you can use the following query (assuming that NULL values corresponds to -9999; you can check this value in Transparency tab of the Layer Properties):
eq( [your_raster]@1, -9999, 0 )
eq means equal to. This tells RasterCalc that all pixels in your raster with ...
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 table.
I prefer this over the r.reclass because you do not have to create additional files.
The first attached script successfully reclassified your AK NLCD data in about 15 minutes (i7, 12GB RAM machine). Since the original dataset is almost 7GB you may be encountering memory issues. If you cannot process the entire dataset in one chunk, try splitting it up with the second script prior to reclassification. My recommendation is to take a small ...
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=result.tiff --calc="0*(A<3)" --calc="1*(A>3)"
This is a Job for the Field Calculator.
See this Python example at Calculate Field examples
if (WellYield >= 0 and WellYield <= 10):
elif (WellYield > 10 and WellYield <= 20):
elif (WellYield > 20 and WellYield <= 30):
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@1" >= 0.3) AND ("Habitat@1" < 0.6)) *2 + ("Habitat@1" >=0.6)* 3
You could use the Raster Calculator to do this. Square the pixel values to ensure all values are positive, and then extract the square roots to get back original number. Something like this:
sqrt ( myraster@1 * myraster@1 )
Because the Raster Calculator is a spatial analyst tool, you can utilize the Mask environment.
From there, you can use a variety of commands to perform the reclassification: common ones include Con, Pick, Is Null and Set Null, based on your needs.
To check if a specific spatial analyst tool honors the Mask environment, simply scroll down to the bottom ...
gdal_reclassify is an unofficial Python tool, based on Python GDAL bindings, able to reclassify according to several classes of values.
python gdal_reclassify.py source_dataset.tif destination_dataset.tif -c "<30, <50, <80, ==130, <210" -r "1, 2, 3, 4, 5" -d 0 -n true -p "...
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 62 are changed to 60:
python gdal_calc.py -A input.tif --outfile=output.file --calc="10*(A<=12)+20*(A==20)+30*(A==30)+40*(A==40)+50*(A==50)+60*((A>50)*(...
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 DEM elevation values.
# Read DEM and convert to raster layer object
dem = raster("C:/temp/dem.tif")
# Generate a reclass ...
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.tif')
band = file.GetRasterBand(1)
lista = band.ReadAsArray()
for j in range(file.RasterXSize):
for i in range(file.RasterYSize):
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) array,
# dstack this into a (depth, rows, cols) array,
# the sum along the last axis (~= grayscale)
grey = np.mean(np.dstack(src.read()), axis=2)
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 between each colour yourself.
If you actually need to produce an output raster classified by percentile, then it may or may not be possible to do so with the ...
Depending on how complex your raster is, you could run Region Group over the raster (assuming Spatial Analyst here). Then reclassify any region with a Count <= 30 as the black value. Unforunately though Region Group is limited in the number of groups to the size of a table entry an ArcInfo Raster can have.
Alternately you can try the same thing in Python ...
The easier way is to use GRASS (also using the QGIS/GRASS plugin) and the r.reclass module.
You will need to create a reclassification rule file, where you can use the keyword "through" or the wildcard "*" to reclassify multiple values in one rule.
If I understand well, you have one class that needs to be changed only if it is located off the coast
So what you need to do is convert your ZIP code boundaries to raster (feature to raster): this will produce a raster that is Null (NoData) where you are not on inland.
Then apply a conditional statement in order to change your wetland values. In the ...
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 to 0.003, multiply your integer raster by 1000 so that its values range between 1000 and 10000. Then instead of reclassifying to 0.003, reclassify to 3. After ...
This is an example (please modify as necessary). "landuse" should be your actual field name of original class.
WHEN "landuse" = 1 THEN 5
WHEN "landuse" = 2 THEN 0
WHEN "landuse" = 3 THEN 10
WHEN "landuse" = 4 THEN 3
WHEN "landuse" = 5 THEN 9
WHEN "landuse" = 6 THEN 4
WHEN "landuse" = 7 THEN 0
There are some syntax errors.
If you run this code from the Python Console:
you will get:
ALGORITHM: r.reclass - Creates a new map layer whose category values are based upon a reclassification of the categories in an existing raster map layer.