How can I create a new raster based on cell values of an existing one using R? [closed]












0















I have a very large raster file that includes cells which have values ranging from 1 to 25. I want to create 25 separate rasters which only include the cells from the original with the same values.



I have looked into the 'raster' package for r and thought that RasterFromCells might be my answer but it requires cell numbers and as my original raster has 171,681,006 cells providing cell numbers for each of the cells with each value would be extremely time consuming.



Is there a function in r that I can use to automate creating a new raster that includes all the cells with a value of 1?



Thanks.










share|improve this question















closed as off-topic by Sotos, Ronak Shah, Roman Luštrik, Jaap, Cath Jan 3 at 12:49


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – Sotos, Ronak Shah, Roman Luštrik, Jaap, Cath

If this question can be reworded to fit the rules in the help center, please edit the question.

















  • Seems a legit r-raster question to me, and a more generalized answer can be provided. Edited title and voted to reopen.

    – lbusett
    Jan 3 at 14:04






  • 1





    It's definitely a legitimate question and it has an answer (full disclosure: from me) which has been accepted.

    – awchisholm
    Jan 3 at 17:17
















0















I have a very large raster file that includes cells which have values ranging from 1 to 25. I want to create 25 separate rasters which only include the cells from the original with the same values.



I have looked into the 'raster' package for r and thought that RasterFromCells might be my answer but it requires cell numbers and as my original raster has 171,681,006 cells providing cell numbers for each of the cells with each value would be extremely time consuming.



Is there a function in r that I can use to automate creating a new raster that includes all the cells with a value of 1?



Thanks.










share|improve this question















closed as off-topic by Sotos, Ronak Shah, Roman Luštrik, Jaap, Cath Jan 3 at 12:49


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – Sotos, Ronak Shah, Roman Luštrik, Jaap, Cath

If this question can be reworded to fit the rules in the help center, please edit the question.

















  • Seems a legit r-raster question to me, and a more generalized answer can be provided. Edited title and voted to reopen.

    – lbusett
    Jan 3 at 14:04






  • 1





    It's definitely a legitimate question and it has an answer (full disclosure: from me) which has been accepted.

    – awchisholm
    Jan 3 at 17:17














0












0








0








I have a very large raster file that includes cells which have values ranging from 1 to 25. I want to create 25 separate rasters which only include the cells from the original with the same values.



I have looked into the 'raster' package for r and thought that RasterFromCells might be my answer but it requires cell numbers and as my original raster has 171,681,006 cells providing cell numbers for each of the cells with each value would be extremely time consuming.



Is there a function in r that I can use to automate creating a new raster that includes all the cells with a value of 1?



Thanks.










share|improve this question
















I have a very large raster file that includes cells which have values ranging from 1 to 25. I want to create 25 separate rasters which only include the cells from the original with the same values.



I have looked into the 'raster' package for r and thought that RasterFromCells might be my answer but it requires cell numbers and as my original raster has 171,681,006 cells providing cell numbers for each of the cells with each value would be extremely time consuming.



Is there a function in r that I can use to automate creating a new raster that includes all the cells with a value of 1?



Thanks.







r gdal r-raster






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 14:00









lbusett

3,63921434




3,63921434










asked Jan 3 at 10:16









tom91tom91

17612




17612




closed as off-topic by Sotos, Ronak Shah, Roman Luštrik, Jaap, Cath Jan 3 at 12:49


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – Sotos, Ronak Shah, Roman Luštrik, Jaap, Cath

If this question can be reworded to fit the rules in the help center, please edit the question.







closed as off-topic by Sotos, Ronak Shah, Roman Luštrik, Jaap, Cath Jan 3 at 12:49


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – Sotos, Ronak Shah, Roman Luštrik, Jaap, Cath

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Seems a legit r-raster question to me, and a more generalized answer can be provided. Edited title and voted to reopen.

    – lbusett
    Jan 3 at 14:04






  • 1





    It's definitely a legitimate question and it has an answer (full disclosure: from me) which has been accepted.

    – awchisholm
    Jan 3 at 17:17



















  • Seems a legit r-raster question to me, and a more generalized answer can be provided. Edited title and voted to reopen.

    – lbusett
    Jan 3 at 14:04






  • 1





    It's definitely a legitimate question and it has an answer (full disclosure: from me) which has been accepted.

    – awchisholm
    Jan 3 at 17:17

















Seems a legit r-raster question to me, and a more generalized answer can be provided. Edited title and voted to reopen.

– lbusett
Jan 3 at 14:04





Seems a legit r-raster question to me, and a more generalized answer can be provided. Edited title and voted to reopen.

– lbusett
Jan 3 at 14:04




1




1





It's definitely a legitimate question and it has an answer (full disclosure: from me) which has been accepted.

– awchisholm
Jan 3 at 17:17





It's definitely a legitimate question and it has an answer (full disclosure: from me) which has been accepted.

– awchisholm
Jan 3 at 17:17












1 Answer
1






active

oldest

votes


















2














Without a reproducible example this might not be what you want, but does this help?



library(raster)
logo <- raster(system.file("external/rlogo.grd", package="raster"))
logo.1 <- (logo == 1)
plot(logo.1)


Raster with 1 only






share|improve this answer


























  • Yes that is exactly it! I had previously tried values(logo) ==1 and that just returned a list, I was annoyingly close! Thanks for helping!

    – tom91
    Jan 3 at 10:49


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Without a reproducible example this might not be what you want, but does this help?



library(raster)
logo <- raster(system.file("external/rlogo.grd", package="raster"))
logo.1 <- (logo == 1)
plot(logo.1)


Raster with 1 only






share|improve this answer


























  • Yes that is exactly it! I had previously tried values(logo) ==1 and that just returned a list, I was annoyingly close! Thanks for helping!

    – tom91
    Jan 3 at 10:49
















2














Without a reproducible example this might not be what you want, but does this help?



library(raster)
logo <- raster(system.file("external/rlogo.grd", package="raster"))
logo.1 <- (logo == 1)
plot(logo.1)


Raster with 1 only






share|improve this answer


























  • Yes that is exactly it! I had previously tried values(logo) ==1 and that just returned a list, I was annoyingly close! Thanks for helping!

    – tom91
    Jan 3 at 10:49














2












2








2







Without a reproducible example this might not be what you want, but does this help?



library(raster)
logo <- raster(system.file("external/rlogo.grd", package="raster"))
logo.1 <- (logo == 1)
plot(logo.1)


Raster with 1 only






share|improve this answer















Without a reproducible example this might not be what you want, but does this help?



library(raster)
logo <- raster(system.file("external/rlogo.grd", package="raster"))
logo.1 <- (logo == 1)
plot(logo.1)


Raster with 1 only







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 3 at 10:39

























answered Jan 3 at 10:32









awchisholmawchisholm

3,07421727




3,07421727













  • Yes that is exactly it! I had previously tried values(logo) ==1 and that just returned a list, I was annoyingly close! Thanks for helping!

    – tom91
    Jan 3 at 10:49



















  • Yes that is exactly it! I had previously tried values(logo) ==1 and that just returned a list, I was annoyingly close! Thanks for helping!

    – tom91
    Jan 3 at 10:49

















Yes that is exactly it! I had previously tried values(logo) ==1 and that just returned a list, I was annoyingly close! Thanks for helping!

– tom91
Jan 3 at 10:49





Yes that is exactly it! I had previously tried values(logo) ==1 and that just returned a list, I was annoyingly close! Thanks for helping!

– tom91
Jan 3 at 10:49





Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas