Description Usage Arguments Value Author(s) Examples
View source: R/calculate_PPA.R
Function for calculating the Potetial Path Area(PPA) of a STP_track. This function can calculate the PPA for the entire trajectory, a specfic moment in time, or a time range. The PPA for a specific moment in time is always based on the two points that before and after the time parameter. If time is outside time range of the STP_Track but within time uncertainty limits, the method will return the PPA based on the two closest points in time.
1 2 |
STP_track |
The STP_track for which the PPA needs to be calculated |
time |
Time("POSIXct" or"POSIXt") for which the PPA needs to be calculated. Use time = c(time1,time2) to calculate PPA for a time range. Default is NULL: calculate PPA for entire STP_track |
points |
The points used for the PPA calculation given as a vector of integers. Default is NULL: calculate PPA for entire STP_track |
x_density |
Paramter used for calculating the PPA of entire STPs. The amount of x coordinates for which the corresponding y coordinate(s) will be calculated. Only relevant if the PPA for at least 1 complete STP needs to be calculated. |
time_interval |
The time interval in minutes used for calculating the PPA. Only used for calculating the PPA for a specfic moment in time and if only a part of the PPA of a STP needs to be calculated. Default is every minute |
quadsegs |
Passed to buffer. Number of line segments to use to approximate a quarter circle. Only used where paramter time_interval is relavant. |
The Potential Path Area as SpatialPolygons. If time is equal to time of a space-time point and rough_sets (time and location uncertainty points) are 0, method returns NA because there is no PPA
Mark ten Vregelaar
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | library(spacetime)
library(sp)
#--------------------------create a STP_Track--------------------------
# set time
t1 <- strptime("01/01/2017 00:00:00", "%m/%d/%Y %H:%M:%S")
t2 <- t1+5*60*60
time<-seq(t1,t2,30*60)
# set coordinates
x=c(seq(0,25,5),seq(27.5,37.5,2.5))
y=sample(-2:2, 11,replace = TRUE)
n = length(x)
crs_NL = CRS("+init=epsg:28992")
# create class STIDF
stidf1 = STIDF(SpatialPoints(cbind(x,y),crs_NL), time, data.frame(co2 = rnorm(n),O2=rnorm(n)))
# Track-class {trajectories}
my_track1<-Track(stidf1)
# set maximum speed
v1<-getVmaxtrack(my_track1)+0.00015
# STP_track class
STP_track1<-STP_Track(my_track1,v1)
#------------------------------example 1------------------------------
## PPA entire track
#calculate PPA
PPA1<-PPA(STP_track1)
# plot results
plot(STP_track1,type='b')
plot(PPA1,add=TRUE)
#------------------------------example 2------------------------------
## PPA only using every second point
# calculate PPA
PPA2<-PPA(STP_track1,points = seq(1,11,2))
# plot results
plot(STP_track1,type='b')
plot(PPA2,add=TRUE)
#------------------------------example 3------------------------------
## PPA of a specfic moment in time
# calculate PPA
time <- strptime("01/01/2017 01:15:00", "%m/%d/%Y %H:%M:%S")
PPA3<-PPA(STP_track1,time = time)
# plot results
plot(STP_track1,type='b')
plot(PPA3,add=TRUE)
#------------------------------example 4------------------------------
## PPA for a time range
# calculate PPA
timerange1 <- c(t1,strptime("01/01/2017 02:15:00", "%m/%d/%Y %H:%M:%S"))
PPA4<-PPA(STP_track1,time = timerange1)
# plot results
plot(STP_track1,type='b')
plot(PPA4,add=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.