Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7584657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:58:32+00:00 2026-05-30T18:58:32+00:00

I have been trying to create a new raster object that contains only a

  • 0

I have been trying to create a new raster object that contains only a couple of values from an existing raster.
I am using the class raster found here: https://www.ga.gov.au/products/servlet/controller?event=FILE_SELECTION&catno=71071.

class       : RasterLayer  dimensions  : 14902, 19161, 285537222 (nrow, ncol, ncell) 
resolution  : 0.002349, 0.002349  (x, y) 
extent      : 110, 155.0092, -45.0048, -9.999999  (xmin, xmax, ymin, ymax) 
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0  
values      : G:\Spatial data\environmental_layers\Australian data\Land cover\Class\DLCDv1_Class.tif  
min value   : 1  
max value   : 34

I have tried:

pr <- rasterToPoints(r) # but the file is to big

and

s <- r[r>30 & r<33] # but the file is to big

and

rc <- reclass(r, c(-Inf,30,NA, 31,32, 1, 33,Inf,NA))

which produces a raster with properties:

class       : RasterLayer 
dimensions  : 14902, 19161, 285537222  (nrow, ncol, ncell)
resolution  : 0.002349, 0.002349  (x, y)
extent      : 110, 155.0092, -45.0048, -9.999999  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
values      : C:\Users\Adam\AppData\Local\Temp\R_raster_tmp\raster_tmp_61931056968.grd 
min value   : 1 
max value   : 33

I thought this would produced a raster layer with values of NA and 1, but it has 33 values. I have been struggling to find a way to ‘extract by attribute’ using R on such a large file. Does anyone have suggestions of how I could do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:58:33+00:00Added an answer on May 30, 2026 at 6:58 pm

    reclassify() may work for you with a very large raster, but you need to specify the “is” “becomes” matrix correctly. Though I am not exactly sure from your question whether this is in fact your goal when you say “raster extract.”

    However, here is how to do the reclassification:

    For example:

    ## Create sample raster with values from 0 to 9
    r <- raster(nrow=100, ncol=100)
    r[] <- trunc(runif(ncell(r))*10)
    
    ## Create reclassification table
    ## Set values 0 to 4 equal to 1
    ## Set values 5 to 9 equal to NA
    
    isBecomes <- cbind(c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9),
                       c(1, 1, 1, 1, 1, NA, NA, NA, NA, NA))
    
    r2 <- reclassify(r, rcl=isBecomes)
    

    I have not tested this in a raster too large to fit in memory, however I believe that reclassify() may be able to handle this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new here. I have been trying to create a video capture app using
I have been trying to create a red black tree that only implements an
I have been trying to create a new google custom search engine, but when
I have been trying to create a Ruby program that will be running online
I have been trying to create a menu panel with jQuery that can be
I have been trying to create a new content type for Plone based on
I have been trying to create a Spring project that uses MyBatis for the
I am new to WiX and I have been trying to create a installer
Im quite new at Javascript however I have been trying to create a currency
I have been trying to create an array of a class containing two values,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.