Difference between revisions of "Main Page/Research/MSB/processing model/20090607"

From phurvitz
Jump to: navigation, search
(New page: __FORCETOC__ Processing Steps with scripts named =Download= msb.get.data.R =Concatenate individual files= join_data.R * Establishes unique ID field ('...)
 
(Trip, stop, and dwell)
 
(2 intermediate revisions by the same user not shown)
Line 42: Line 42:
  
 
=Trip, stop, and dwell=
 
=Trip, stop, and dwell=
 +
* '''Potentially''' a method for getting stops: [[/line_edit_to_points.R|line_edit_to_points.R]]
 +
** It takes each trip's points and "straightens" them out to allow for measuring the focal count of points in a radius
 +
** It counts the number of points in the radii <tt>seq(50,150,25)</tt> for each measured point
 +
** There may be thresholds for what is a "stop" based on focal counts.
 +
** This graph may help.
 +
<pre>
 +
foo <- function(x, y) {
 +
    dat <- x[x$trip.id==y,]
 +
    start <- round(min(dat$seq.id), -2)
 +
    at <- seq(start, max(dat$seq.id), 100)
 +
   
 +
    mini <- with(dat, min(rcount.50, rcount.75, rcount.100, rcount.125, rcount.150))
 +
    maxi <- with(dat, max(rcount.50, rcount.75, rcount.100, rcount.125, rcount.150))
 +
       
 +
    with(dat,
 +
        plot(seq.id, rcount.150, ty="l", ylim=c(mini, maxi), xaxt="n")
 +
    )
 +
    abline(h=max(dat$rcount.150)/2, lty=3)
 +
 +
    axis(1, at=at)
 +
   
 +
    color.list <- c("red", "green", "magenta", "blue")
 +
    radius.list <- c(50,75,100,125)
 +
   
 +
    for (i in 1:length(color.list)) {
 +
        radius <- radius.list[i]
 +
        color <- color.list[i]
 +
        cmd.draw <- sprintf("lines(dat$seq.id, dat$rcount.%s, col=\"%s\")", radius, color)
 +
        eval(parse(text=cmd.draw))
 +
        cmd.draw.abline <- sprintf("abline(h=max(dat$rcount.%s)/2, lty=3, col=\"%s\")", radius, color)
 +
        eval(parse(text=cmd.draw.abline))
 +
    }
 +
           
 +
}
 +
</pre>

Latest revision as of 02:57, 17 July 2009

Processing Steps with scripts named

Download

msb.get.data.R

Concatenate individual files

join_data.R

  • Establishes unique ID field (seq_id) for each point in the subject's data

Create lines, perform initial activity parsing

actfilter.R

  • Encodes all geographic features as 3D, where the Z coordinate is inherited from the seq_id value for the coordinate
  • Creates PostGIS tables:
  1. sid_filtered_points
  2. sid_line
  • Creates 3 shapefiles:
  1. sid_filtered_points.shp (all initial points, classified)
  2. sid_stat{,unedited}.shp (stationary bouts)
  3. sid_move{,unedited}.shp (moving bouts)
  • Dumps XYZ data as sid_xyzmb.raw.dat.

Manual editing

Each data set (stat, move) needs to be manually reviewed and edited.

  1. Obviously erroneous vertices (waaaay out) should be deleted (using Ian-ko's tools http://www.ian-ko.com/)
  2. Ranges of incorrectly coded data should be flagged for recoding
    1. Vertices need to be identified, using vertex editor in ArcMap.
    2. Note range of vertices for recoding and place in file recode.txt, with pattern start, end, code, e.g. to specify a range for recoding to stationary:
      2197, 2480, 0

Apply manual edits

apply_edits.R

  1. Reads edited shapefiles (sid_move.shp and sid_stat.shp) into PostGIS as sid_move_intermediate and sid_stat_intermediate and joins them as sid_intermediate.
  2. Dumps Z coordinates (seq_id) from edited data
  3. Reads raw Z coordinates (from sid_xyzmb.raw.dat)
  4. Compares list of raw and edited coordinates, and deletes necessary coordinates
  5. Recodes activity by recode.txt
  6. Pushes data to PostGIS as sid_line_edit
  7. Dumps new versions of shapefiles from PostGIS
    • sid_move.shp
    • sid_stat.shp
  8. Allows repeted edit cycles.

Trip, stop, and dwell

  • Potentially a method for getting stops: line_edit_to_points.R
    • It takes each trip's points and "straightens" them out to allow for measuring the focal count of points in a radius
    • It counts the number of points in the radii seq(50,150,25) for each measured point
    • There may be thresholds for what is a "stop" based on focal counts.
    • This graph may help.
foo <- function(x, y) {
    dat <- x[x$trip.id==y,]
    start <- round(min(dat$seq.id), -2)
    at <- seq(start, max(dat$seq.id), 100)
    
    mini <- with(dat, min(rcount.50, rcount.75, rcount.100, rcount.125, rcount.150))
    maxi <- with(dat, max(rcount.50, rcount.75, rcount.100, rcount.125, rcount.150))
        
    with(dat,
        plot(seq.id, rcount.150, ty="l", ylim=c(mini, maxi), xaxt="n")
    )
    abline(h=max(dat$rcount.150)/2, lty=3)

    axis(1, at=at)
    
    color.list <- c("red", "green", "magenta", "blue")
    radius.list <- c(50,75,100,125)
    
    for (i in 1:length(color.list)) {
        radius <- radius.list[i]
        color <- color.list[i]
        cmd.draw <- sprintf("lines(dat$seq.id, dat$rcount.%s, col=\"%s\")", radius, color)
        eval(parse(text=cmd.draw))
        cmd.draw.abline <- sprintf("abline(h=max(dat$rcount.%s)/2, lty=3, col=\"%s\")", radius, color)
        eval(parse(text=cmd.draw.abline))
    }
            
}