Re: [R-sig-Geo] Plot spatial time series

2012-06-09 Thread Chris English

Thiago,

With uncertainty, as this is beyond my pay grade, might I suggest looking at 
spacetime,

http://cran.r-project.org/web/packages/spacetime/index.html ,

using Matt's method to extract the dates from file names to become your xts 
date object.

As all the spacetime objects derive from ST (and xts), spatial pixels data 
frame would be available.

There are additionally overlay and aggregation methods available in spacetime 
for your data,

but I have not explored these as yet.  I hope this is useful rather than a 
distraction.

Chris English
  
[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Plot spatial time series

2012-06-09 Thread Thiago Veloso
  Chris,

  Thanks for the tip. For now, Matthew's suggestion is enough. But I am glad to 
know about spacetime package. It might be useful for other analysis.

  Best,
  Thiago.

From: Chris English sgl...@hotmail.com
To: Help R-Sig_Geo r-sig-geo@r-project.org 
Cc: lan...@isciences.com; thi_vel...@yahoo.com.br 
Sent: Saturday, June 9, 2012 1:47 PM
Subject: Re: [R-sig-Geo] Plot spatial time series



Thiago,

With uncertainty, as this is beyond my pay grade, might I suggest looking at 
spacetime,

http://cran.r-project.org/web/packages/spacetime/index.html ,

using Matt's method to extract the dates from file names to become your xts 
date object.

As all the spacetime objects derive from ST (and xts), spatial pixels data 
frame would be available.

There are additionally overlay and aggregation methods available in spacetime 
for your data,

but I have not explored these as yet.  I hope this is useful rather than a 
distraction.

Chris English  

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Plot spatial time series

2012-06-09 Thread Thiago Veloso
  Matthew,

  Thank you very much for the suggestion. You assumed correctly: I wanted to 
plot an average of the whole raster.

  I managed to plot the data (please see 
http://img137.imageshack.us/img137/601/screenshotan.png), but it's still 
precarious. Right now I am tying to improve the plot with ggplot2 package!

  Cheers,
  Thiago.


- Original Message -
From: Matt Landis lan...@isciences.com
To: Thiago Veloso thi_vel...@yahoo.com.br
Cc: R-SIG list r-sig-geo@r-project.org
Sent: Friday, June 8, 2012 3:45 PM
Subject: Re: [R-sig-Geo] Plot spatial time series

Fixing typos:
tmp.df - data.frame(date = rep(NA, length(files)), lai = NA)
for ( i in 1:length(files) ){
     f - files[i]
   cat('Reading file: ', f, '\n')
   tmp.df$date[i] - regmatches(f, regexpr('[0-9]{7}', f))
   tmp.df$lai[i] - mean(getValues(r), na.rm = TRUE)
}

Hopefully that makes more sense...

2012/6/8 Matthew Landis lan...@isciences.com:
 Thiago,

 It's not clear to me exactly what your plot would represent.  Is it the
 average of the whole scene? One pixel?

 Assuming you're plotting 1 value per raster, I wouldn't try to stack all 506
 files.  I would read one at a time, summarize the values and put them into a
 dataframe.  Here's an idea of what I would try:

 temp.df - data.frame(date = rep(NA, length(files)), lai = NA)
 for ( f in files ){
    cat('Reading file: ', f, '\n')
    tmp.df$date - regmatches(f, regexpr('[0-9]{7}', f))
    tmp.df$lai - mean(getValues(r), na.rm = TRUE)
 }

 You could convert date to a Date object, but I don't know off the top of my
 head how to deal with Julian days.

 More simply, you could say tmp.df$date - as.numeric(tmp.df$date), and plot
 would treat it approximately correctly.

 Finish up with:

 with(tmp.df, plot(date, lai))

 Matt


 On 6/8/2012 2:10 PM, Thiago Veloso wrote:

   Dear all,

   I have 506 netcdf files representing a time series of leaf index area
 estimated by MODIS, starting from 01jan/2001 and with increment of 8 days.
 Dates are in the name of the file and are presented in julian format.
 Together, files reach 35GB. Please see below how I load the files:

 library (raster)
 files- list.files(pattern='lai*')
 files

   [1] lai2001001.nc lai2001009.nc lai2001017.nc lai2001025.nc
   [5] lai2001033.nc lai2001041.nc lai2001049.nc lai2001057.nc
   [9] lai2001065.nc lai2001073.nc lai2001081.nc lai2001089.nc
  [13] lai2001097.nc lai2001105.nc lai2001113.nc lai2001121.nc
  [17] lai2001129.nc lai2001137.nc lai2001145.nc lai2001153.nc
  [21] lai2001161.nc lai2001169.nc lai2001177.nc lai2001185.nc
  [25] lai2001193.nc lai2001201.nc lai2001209.nc lai2001217.nc
  [29] lai2001225.nc lai2001233.nc lai2001241.nc lai2001249.nc
  [33] lai2001257.nc lai2001265.nc lai2001273.nc lai2001281.nc
  [37] lai2001289.nc lai2001297.nc lai2001305.nc lai2001313.nc
  [41] lai2001321.nc lai2001329.nc lai2001337.nc lai2001345.nc
  [45] lai2001353.nc lai2001361.nc lai2002001.nc lai2002009.nc
  [49] lai2002017.nc lai2002025.nc lai2002033.nc lai2002041.nc
  [53] lai2002049.nc lai2002057.nc lai2002065.nc lai2002073.nc
  [57] lai2002081.nc lai2002089.nc lai2002097.nc lai2002105.nc
  [61] lai2002113.nc lai2002121.nc lai2002129.nc lai2002137.nc
  [65] lai2002145.nc lai2002153.nc lai2002161.nc lai2002169.nc
  [69] lai2002177.nc lai2002185.nc lai2002193.nc lai2002201.nc
  [73] lai2002209.nc lai2002217.nc lai2002225.nc lai2002233.nc
  [77] lai2002241.nc lai2002249.nc lai2002257.nc lai2002265.nc
  [81] lai2002273.nc lai2002281.nc lai2002289.nc lai2002297.nc
  [85] lai2002305.nc lai2002313.nc lai2002321.nc lai2002329.nc
  [89] lai2002337.nc lai2002345.nc lai2002353.nc lai2002361.nc
  [93] lai2003001.nc lai2003009.nc lai2003017.nc lai2003025.nc
  [97] lai2003033.nc lai2003041.nc lai2003049.nc lai2003057.nc
 [101] lai2003065.nc lai2003073.nc lai2003081.nc lai2003089.nc
 [105] lai2003097.nc lai2003105.nc lai2003113.nc lai2003121.nc
 [109] lai2003129.nc lai2003137.nc lai2003145.nc lai2003153.nc
 [113] lai2003161.nc lai2003169.nc lai2003177.nc lai2003185.nc
 [117] lai2003193.nc lai2003201.nc lai2003209.nc lai2003217.nc
 [121] lai2003225.nc lai2003233.nc lai2003241.nc lai2003249.nc
 [125] lai2003257.nc lai2003265.nc lai2003273.nc lai2003281.nc
 [129] lai2003289.nc lai2003297.nc lai2003305.nc lai2003313.nc
 [133] lai2003321.nc lai2003329.nc lai2003337.nc lai2003345.nc
 [137] lai2003353.nc lai2003361.nc lai2004001.nc lai2004009.nc
 [141] lai2004017.nc lai2004025.nc lai2004033.nc lai2004041.nc
 [145] lai2004049.nc lai2004057.nc lai2004065.nc lai2004073.nc
 [149] lai2004081.nc lai2004089.nc lai2004097.nc lai2004105.nc
 [153] lai2004113.nc lai2004121.nc lai2004129.nc lai2004137.nc
 [157] lai2004145.nc lai2004153.nc lai2004161.nc lai2004169.nc
 [161] lai2004177.nc lai2004185.nc lai2004193.nc lai2004201.nc
 [165] lai2004209.nc lai2004217.nc lai2004225.nc lai2004233.nc
 [169] lai2004241.nc lai2004249.nc lai2004257.nc lai2004265.nc
 [173] lai2004273.nc lai2004281.nc lai2004289.nc lai2004297.nc
 [177] lai2004305.nc lai2004313.nc 

[R-sig-Geo] Spatial modeling

2012-06-09 Thread Mitra Devkota

Dear all, When I run the SAR model, I get the error like this. Can u suggest me 
how can I solve this issue? or what could be the cause of this problem? 
sar-spautolm(yield~Temp+precept, data=data, listw=SD_queenW)Error in t(IlW) :  
 error in evaluating the argument 'x' in selecting a method for function 't': 
Error in get(I, envir = env) - lambda * get(W, envir = env) :   
non-conformable arraysCan anybody help me how to fix this issue.?
If you need to see the entire code, is is 
here:##SDdata-read.csv(SD.csv,header=TRUE)head(data)tail(data)attach(data)#MAP
 
plottinglibrary(maps)library(spdep)library(rgdal)library(alr3)SD-map(county, 
SOUTH DAKOTA, fill=TRUE, 
plot=FALSE)county.names-as.character(SD$names)SD.sp-map2SpatialPolygons(SD, 
IDs=county.names, proj4string=CRS(+proj=longlat))SD_queen-poly2nb(SD.sp, 
queen=TRUE)SD_rook-poly2nb(SD.sp, queen=FALSE)SD_queenW-nb2listw(SD_queen, 
style=B)SD_queenWsummary(SD_queenW)SD_queenWC-nb2listw(SD_queen, 
style=C)SD_rookW-nb2listw(SD_rook, 
style=B)SD_rookWsummary(SD_rookW)#SARsar-spautolm(yield~Temp+precept, 
data=data, listw=SD_queenW)summary(sar)#CARcar-spautolm(yield~Temp+precept, 
data=data, family=CAR, listw=SD_queenW)summary(car)

Thanks,Mitra DevkotaBrookings, SD 57006571 242 6140A person who never made a 
mistake never tried anything new. -Albert Einstein


 



  
[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo