[R-sig-Geo] Extract points from raster brick by both location and a matching attributes.

Kristin nessnjor at gmail.com
Mon Sep 8 10:55:10 CEST 2014


Hi

I have a raster brick of 464 layers, each layer representing time defined as
number from 1 to 464.
The numbers are stored here:
rasterbrick at z$days

and have values from 1 to 464

Then I have 2800 space time locations of field data sampling. These are both
irregular sampling locations and some irregular sampling dates at same
sampling locations. Dates are also defined as numbers from 1 to 464. Each
individual point is then identified by lat and lon at different times.
This is what my dataframe looks like:

Lat, Lon, days
64   -21    23
63   -19    52
63   -19    53
66   -25    23
....

So what I want to do is to extract values from the raster brick at a certain
location, but only where the date numbers from both the raster brick and the
locations match, but not for all times for all locations as the extract from
raster brick does.

And if it helps, then below is the structure of my raster brick: 
> str (rasterbrick)
Formal class 'RasterBrick' [package "raster"] with 12 slots
  ..@ file    :Formal class '.RasterFile' [package "raster"] with 13 slots
  .. .. ..@ name        : chr "C:\\Gudrun\\DINEOF_NIALL\\R\\chl.nc"
  .. .. ..@ datanotation: chr "FLT4S"
  .. .. ..@ byteorder   : chr "little"
  .. .. ..@ nodatavalue : num -9999
  .. .. ..@ NAchanged   : logi FALSE
  .. .. ..@ nbands      : int 464
  .. .. ..@ bandorder   : chr "BIL"
  .. .. ..@ offset      : int 0
  .. .. ..@ toptobottom : logi TRUE
  .. .. ..@ blockrows   : int 0
  .. .. ..@ blockcols   : int 0
  .. .. ..@ driver      : chr "netcdf"
  .. .. ..@ open        : logi FALSE
  ..@ data    :Formal class '.MultipleRasterData' [package "raster"] with 14
slots
  .. .. ..@ values    : logi[0 , 0 ] 
  .. .. ..@ offset    : num 0
  .. .. ..@ gain      : num 1
  .. .. ..@ inmemory  : logi FALSE
  .. .. ..@ fromdisk  : logi TRUE
  .. .. ..@ nlayers   : int 464
  .. .. ..@ dropped   : NULL
  .. .. ..@ isfactor  : logi FALSE
  .. .. ..@ attributes: list()
  .. .. ..@ haveminmax: logi FALSE
  .. .. ..@ min       : num [1:464] Inf Inf Inf Inf Inf ...
  .. .. ..@ max       : num [1:464] -Inf -Inf -Inf -Inf -Inf ...
  .. .. ..@ unit      : chr "units"
  .. .. ..@ names     : chr [1:464] "X341" "X41" "X169" "X281" ...
  ..@ legend  :Formal class '.RasterLegend' [package "raster"] with 5 slots
  .. .. ..@ type      : chr(0) 
  .. .. ..@ values    : logi(0) 
  .. .. ..@ color     : logi(0) 
  .. .. ..@ names     : logi(0) 
  .. .. ..@ colortable: logi(0) 
  ..@ title   : chr "var3d"
  ..@ extent  :Formal class 'Extent' [package "raster"] with 4 slots
  .. .. ..@ xmin: num -30
  .. .. ..@ xmax: num -8.01
  .. .. ..@ ymin: num 60
  .. .. ..@ ymax: num 68
  ..@ rotated : logi FALSE
  ..@ rotation:Formal class '.Rotation' [package "raster"] with 2 slots
  .. .. ..@ geotrans: num(0) 
  .. .. ..@ transfun:function ()  
  ..@ ncols   : int 440
  ..@ nrows   : int 160
  ..@ crs     :Formal class 'CRS' [package "sp"] with 1 slots
  .. .. ..@ projargs: chr "+proj=longlat +datum=WGS84"
  ..@ history : list()
  ..@ z       :List of 1
  .. ..$ days: int [1:464(1d)] 341 41 169 281 409 69 197 309 437 101 ...

atb,
Kristin



--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Extract-points-from-raster-brick-by-both-location-and-a-matching-attributes-tp7587083.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list