Reclassifying rasterstack in R?Reclassifying Rasters Error 001100 Failed because no statistics are availableReclassifying rasters using GDAL and Python?Getting aspect and reclassifying raster files using Python in a loopReclassifying rasters to two values (1 and NODATA)?R: Error when stacking multiple raster filesUsing spei() function on time series from rasterstack in R?Rasterize shapefile according to another big raster using gdal_rasterizeExtract values from large rasterstack, RConditional mean of rasterstackCalculating Median/Quantile of Rasterstack and converting Results to Data Frame in R
Cross compiling for RPi - error while loading shared libraries
A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?
Do I have a twin with permutated remainders?
Paid for article while in US on F-1 visa?
How to format long polynomial?
Did Shadowfax go to Valinor?
What is the word for reserving something for yourself before others do?
Is it possible to run Internet Explorer on OS X El Capitan?
Has there ever been an airliner design involving reducing generator load by installing solar panels?
What does "Puller Prush Person" mean?
What defenses are there against being summoned by the Gate spell?
How much RAM could one put in a typical 80386 setup?
Unable to deploy metadata from Partner Developer scratch org because of extra fields
Is it unprofessional to ask if a job posting on GlassDoor is real?
Codimension of non-flat locus
How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?
Can a Cauchy sequence converge for one metric while not converging for another?
Theorems that impeded progress
Approximately how much travel time was saved by the opening of the Suez Canal in 1869?
meaning of に in 本当に?
Do infinite dimensional systems make sense?
What does it mean to describe someone as a butt steak?
Is it possible to do 50 km distance without any previous training?
dbcc cleantable batch size explanation
Reclassifying rasterstack in R?
Reclassifying Rasters Error 001100 Failed because no statistics are availableReclassifying rasters using GDAL and Python?Getting aspect and reclassifying raster files using Python in a loopReclassifying rasters to two values (1 and NODATA)?R: Error when stacking multiple raster filesUsing spei() function on time series from rasterstack in R?Rasterize shapefile according to another big raster using gdal_rasterizeExtract values from large rasterstack, RConditional mean of rasterstackCalculating Median/Quantile of Rasterstack and converting Results to Data Frame in R
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a very large raster stack of 6253 raster layers and I want to reclassify it.
For the reclass, I have tried the following but with no success:
my_rules <- c(-0.500, -0.251, 1, -0.251, -0.101, 2, -0.101,0.99,3, 0.99,0.269,4, 0.269,0.439,5, 0.439,0.659,6, 0.659,1.300,7, 1.300,2,NA)
reclmat <- matrix(my_rules, ncol=3, byrow=TRUE)
my_stack<- reclassify(my_stack, reclmat,right=FALSE)
Error in .local(x, rcl, ...) : all(rcl[, 2] >= rcl[, 1]) is not TRUE
Is this the wrong way to approach this?
r reclassify rasterstack
add a comment |
I have a very large raster stack of 6253 raster layers and I want to reclassify it.
For the reclass, I have tried the following but with no success:
my_rules <- c(-0.500, -0.251, 1, -0.251, -0.101, 2, -0.101,0.99,3, 0.99,0.269,4, 0.269,0.439,5, 0.439,0.659,6, 0.659,1.300,7, 1.300,2,NA)
reclmat <- matrix(my_rules, ncol=3, byrow=TRUE)
my_stack<- reclassify(my_stack, reclmat,right=FALSE)
Error in .local(x, rcl, ...) : all(rcl[, 2] >= rcl[, 1]) is not TRUE
Is this the wrong way to approach this?
r reclassify rasterstack
add a comment |
I have a very large raster stack of 6253 raster layers and I want to reclassify it.
For the reclass, I have tried the following but with no success:
my_rules <- c(-0.500, -0.251, 1, -0.251, -0.101, 2, -0.101,0.99,3, 0.99,0.269,4, 0.269,0.439,5, 0.439,0.659,6, 0.659,1.300,7, 1.300,2,NA)
reclmat <- matrix(my_rules, ncol=3, byrow=TRUE)
my_stack<- reclassify(my_stack, reclmat,right=FALSE)
Error in .local(x, rcl, ...) : all(rcl[, 2] >= rcl[, 1]) is not TRUE
Is this the wrong way to approach this?
r reclassify rasterstack
I have a very large raster stack of 6253 raster layers and I want to reclassify it.
For the reclass, I have tried the following but with no success:
my_rules <- c(-0.500, -0.251, 1, -0.251, -0.101, 2, -0.101,0.99,3, 0.99,0.269,4, 0.269,0.439,5, 0.439,0.659,6, 0.659,1.300,7, 1.300,2,NA)
reclmat <- matrix(my_rules, ncol=3, byrow=TRUE)
my_stack<- reclassify(my_stack, reclmat,right=FALSE)
Error in .local(x, rcl, ...) : all(rcl[, 2] >= rcl[, 1]) is not TRUE
Is this the wrong way to approach this?
r reclassify rasterstack
r reclassify rasterstack
edited Apr 2 at 11:24
PolyGeo♦
53.9k1781245
53.9k1781245
asked Apr 2 at 6:49
foofoo
555
555
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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] [,2] [,3]
[1,] -0.500 -0.251 1
[2,] -0.251 -0.101 2
[3,] -0.101 0.990 3
[4,] 0.990 0.269 4
[5,] 0.269 0.439 5
[6,] 0.439 0.659 6
[7,] 0.659 1.300 7
[8,] 1.300 2.000 NA
Its nothing to do with the size of the stack - you should always test things first on small examples. I duplicated your error with:
> r = raster()
> r[] = runif(ncell(r),-0.5,2)
> reclassify(r,reclmat)
Error: all(rcl[, 2] >= rcl[, 1]) is not TRUE
Change the 0.990
to 0.099
and it works:
> my_rules <- c(-0.500, -0.251, 1, -0.251, -0.101, 2, -0.101,0.099,3, 0.099,0.269,4, 0.269,0.439,5, 0.439,0.659,6, 0.659,1.300,7, 1.300,2,NA)
> reclmat <- matrix(my_rules, ncol=3, byrow=TRUE)
> reclassify(r,reclmat)
class : RasterLayer
dimensions : 180, 360, 64800 (nrow, ncol, ncell)
resolution : 1, 1 (x, y)
Such a stupid mistake from me. Thank you for the notice @Spacedman!
– foo
Apr 2 at 7:31
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f317445%2freclassifying-rasterstack-in-r%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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] [,2] [,3]
[1,] -0.500 -0.251 1
[2,] -0.251 -0.101 2
[3,] -0.101 0.990 3
[4,] 0.990 0.269 4
[5,] 0.269 0.439 5
[6,] 0.439 0.659 6
[7,] 0.659 1.300 7
[8,] 1.300 2.000 NA
Its nothing to do with the size of the stack - you should always test things first on small examples. I duplicated your error with:
> r = raster()
> r[] = runif(ncell(r),-0.5,2)
> reclassify(r,reclmat)
Error: all(rcl[, 2] >= rcl[, 1]) is not TRUE
Change the 0.990
to 0.099
and it works:
> my_rules <- c(-0.500, -0.251, 1, -0.251, -0.101, 2, -0.101,0.099,3, 0.099,0.269,4, 0.269,0.439,5, 0.439,0.659,6, 0.659,1.300,7, 1.300,2,NA)
> reclmat <- matrix(my_rules, ncol=3, byrow=TRUE)
> reclassify(r,reclmat)
class : RasterLayer
dimensions : 180, 360, 64800 (nrow, ncol, ncell)
resolution : 1, 1 (x, y)
Such a stupid mistake from me. Thank you for the notice @Spacedman!
– foo
Apr 2 at 7:31
add a comment |
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] [,2] [,3]
[1,] -0.500 -0.251 1
[2,] -0.251 -0.101 2
[3,] -0.101 0.990 3
[4,] 0.990 0.269 4
[5,] 0.269 0.439 5
[6,] 0.439 0.659 6
[7,] 0.659 1.300 7
[8,] 1.300 2.000 NA
Its nothing to do with the size of the stack - you should always test things first on small examples. I duplicated your error with:
> r = raster()
> r[] = runif(ncell(r),-0.5,2)
> reclassify(r,reclmat)
Error: all(rcl[, 2] >= rcl[, 1]) is not TRUE
Change the 0.990
to 0.099
and it works:
> my_rules <- c(-0.500, -0.251, 1, -0.251, -0.101, 2, -0.101,0.099,3, 0.099,0.269,4, 0.269,0.439,5, 0.439,0.659,6, 0.659,1.300,7, 1.300,2,NA)
> reclmat <- matrix(my_rules, ncol=3, byrow=TRUE)
> reclassify(r,reclmat)
class : RasterLayer
dimensions : 180, 360, 64800 (nrow, ncol, ncell)
resolution : 1, 1 (x, y)
Such a stupid mistake from me. Thank you for the notice @Spacedman!
– foo
Apr 2 at 7:31
add a comment |
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] [,2] [,3]
[1,] -0.500 -0.251 1
[2,] -0.251 -0.101 2
[3,] -0.101 0.990 3
[4,] 0.990 0.269 4
[5,] 0.269 0.439 5
[6,] 0.439 0.659 6
[7,] 0.659 1.300 7
[8,] 1.300 2.000 NA
Its nothing to do with the size of the stack - you should always test things first on small examples. I duplicated your error with:
> r = raster()
> r[] = runif(ncell(r),-0.5,2)
> reclassify(r,reclmat)
Error: all(rcl[, 2] >= rcl[, 1]) is not TRUE
Change the 0.990
to 0.099
and it works:
> my_rules <- c(-0.500, -0.251, 1, -0.251, -0.101, 2, -0.101,0.099,3, 0.099,0.269,4, 0.269,0.439,5, 0.439,0.659,6, 0.659,1.300,7, 1.300,2,NA)
> reclmat <- matrix(my_rules, ncol=3, byrow=TRUE)
> reclassify(r,reclmat)
class : RasterLayer
dimensions : 180, 360, 64800 (nrow, ncol, ncell)
resolution : 1, 1 (x, y)
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] [,2] [,3]
[1,] -0.500 -0.251 1
[2,] -0.251 -0.101 2
[3,] -0.101 0.990 3
[4,] 0.990 0.269 4
[5,] 0.269 0.439 5
[6,] 0.439 0.659 6
[7,] 0.659 1.300 7
[8,] 1.300 2.000 NA
Its nothing to do with the size of the stack - you should always test things first on small examples. I duplicated your error with:
> r = raster()
> r[] = runif(ncell(r),-0.5,2)
> reclassify(r,reclmat)
Error: all(rcl[, 2] >= rcl[, 1]) is not TRUE
Change the 0.990
to 0.099
and it works:
> my_rules <- c(-0.500, -0.251, 1, -0.251, -0.101, 2, -0.101,0.099,3, 0.099,0.269,4, 0.269,0.439,5, 0.439,0.659,6, 0.659,1.300,7, 1.300,2,NA)
> reclmat <- matrix(my_rules, ncol=3, byrow=TRUE)
> reclassify(r,reclmat)
class : RasterLayer
dimensions : 180, 360, 64800 (nrow, ncol, ncell)
resolution : 1, 1 (x, y)
answered Apr 2 at 7:24
SpacedmanSpacedman
24.8k23551
24.8k23551
Such a stupid mistake from me. Thank you for the notice @Spacedman!
– foo
Apr 2 at 7:31
add a comment |
Such a stupid mistake from me. Thank you for the notice @Spacedman!
– foo
Apr 2 at 7:31
Such a stupid mistake from me. Thank you for the notice @Spacedman!
– foo
Apr 2 at 7:31
Such a stupid mistake from me. Thank you for the notice @Spacedman!
– foo
Apr 2 at 7:31
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f317445%2freclassifying-rasterstack-in-r%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown