[R-sig-Geo] Help for STFDF Object Creation

Edzer Pebesma edzer.pebesma at uni-muenster.de
Sun Apr 23 23:24:59 CEST 2017


Please provide a script of an example that we can reproduce, preferably
using data that is loaded from a package (to safe other people's time),
otherwise it is impossible for anyone to help you, or unlikely somebody
will. Your script does not create count data but assumes it is there;
you don't show which package you loaded; it is unclear what your problem is.

Your second post on this list came through completely scrambled, and
within 24 hours. Don't expect that reposting, or scrambling, helps.

On 23/04/17 06:02, Ankur Sarker via R-sig-Geo wrote:
> Hi,
> I am trying to create a STFDF object and draw variogram. However, I am getting several errors. Here is my r code:
> #create count data
> c0157ts <- as.numeric(c(t(c0157)))
> c0001ts <- as.numeric(c(t(c0001)))
> 
> #create coordinates
>   lat <- 0
>   lon <- 0
>   lat[1] <- 34.0793684
>   lon[1] <- -81.1301722
>   lat[2] <- 33.979127
>   lon[2] <- -81.321166398
>   sp <- data.frame(lat,lon)
>   coordinates(sp)=~lon+lat
>   projection(sp)=CRS("+init=epsg:4326")
> 
> #create time object
> time_index <- seq(from = as.POSIXct("2017-01-02 01:00", tz = 'UTC'), to = as.POSIXct("2017-03-22 00:00", tz = 'UTC'), by = "hour")
> 
> #combine the data
> mydata <- data.frame("count"=c(c0157ts,c0001ts)) 
> 
> #create STFDF object
> stfdf = STFDF(ozoneSP, time_index, mydata)
> #trying to create variogram
>     var <- variogramST(count~1,data=stfdf,tunit="hours",assumeRegular=F,na.omit=T)which gives me following error:0%Error in apply(do.call(cbind, lapply(ret, function(x) x$np)), 1, sum,  : 
>       dim(X) must have a positive length
> I guess my STFDF object creation is not correct. Can anyone give us any hint? Which elements in STFDF object is not correct.Here is the description of STFDF object:> str(stfdf)
> Formal class 'STFDF' [package "spacetime"] with 4 slots
>   ..@ data   :'data.frame':     3792 obs. of  1 variable:
>   .. ..$ count: num [1:3792] 40 32 64 40 55 89 71 43 69 44 ...
>   ..@ sp     :Formal class 'SpatialPoints' [package "sp"] with 3 slots
>   .. .. ..@ coords     : num [1:2, 1:2] -9031369 -9052631 4015522 4002120
>   .. .. .. ..- attr(*, "dimnames")=List of 2
>   .. .. .. .. ..$ : NULL
>   .. .. .. .. ..$ : chr [1:2] "lon" "lat"
>   .. .. ..@ bbox       : num [1:2, 1:2] -9052631 4002120 -9031369 4015522
>   .. .. .. ..- attr(*, "dimnames")=List of 2
>   .. .. .. .. ..$ : chr [1:2] "lon" "lat"
>   .. .. .. .. ..$ : chr [1:2] "min" "max"
>   .. .. ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
>   .. .. .. .. ..@ projargs: chr "+init=epsg:3395 +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0"
>   ..@ time   :An ‘xts’ object on 2017-01-02 01:00:00/2017-03-22 containing:
>   Data: int [1:1896, 1] 1 2 3 4 5 6 7 8 9 10 ...
>  - attr(*, "dimnames")=List of 2
>   ..$ : NULL
>   ..$ : chr "timeIndex"
>   Indexed by objects of class: [POSIXct,POSIXt] TZ: UTC
>   xts Attributes:  
>  NULL
> Thanks for your help!
> With Regards,Rukna
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Edzer Pebesma
Institute for Geoinformatics  (ifgi),  University of Münster
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software:   http://www.jstatsoft.org/
Computers & Geosciences:   http://elsevier.com/locate/cageo/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20170423/6762ae88/attachment.sig>


More information about the R-sig-Geo mailing list