Eugeniusz Kałuża <eugeniusz.kal...@polsl.pl> [Fri, May 21, 2010 at 04:47:21PM 
CEST]:
> Dear R users,
> #----------------------------------------------------------------------------------------------------------------------------
> #There is table containing 1000 (lat, lon, time) GPS positions, wchich should 
> be recognized and labeled in every row of that #recognized position by label 
> from defined POI vector
> 
>  GPS$Lat    =c(9,2.2,2,3,4,5,6,7,2,9,2.1,10,3.3,0 , 6, 8, 9)
>  GPS$Lon    =c(0,1  ,1,4,4,5,6,7,2,9,1.1,10,4.2,0 , 6, 1, 9)
>  GPS$time   =c(0,1  ,2,3,4,5,6,7,8,9,10 ,11,12 ,13,14,15,16)
> 
> # and definition of points of interest:
>  POIdef$Lat =c( 2   ,3.2)
>  POIdef$Lon =c( 1.1 ,4  )
>  POIdef$Lab =c("A"  ,"B") 
> 
> 
> # but if there are two recognitized points in the small time difference,

First of all, you need a concept of "recognize", which means in most
cases "being within the distance of at most ... from POI". If your
field of reference is local, you may want to define the distance
without changing the projection. If your GPX traces span more than,
say, 100 km, you may want to project your data to a different
coordinate system, in which case a specialized package like geoR migt
come handy.

> # (within time window of tw=3)
> # there should be choosen only one point from POIdef  
> 
> #Result expected:
> 
> #like in these vectors: 
> (GPSfindings$Lat     =c(2.2, 2.1, 3.3    )  )
> (GPSfindings$Lon     =c(1  , 1.1, 4.2    )  )
> (GPSfindings$time    =c(2  ,10  , 12     )  )
> (GPSfindings$Lab     =c("A","A" , "B"    )  )
> (GPSfindings$POI_lat =c(2  ,2   , 3.2    )  )
> (GPSfindings$POI_lon =c(1.1,1.1 , 4.1    )  )
> 
> #and as result obtain marked vector:  
> (GPS$Lab=c(NA,"A",NA,NA,NA,NA,NA,NA,NA,"B",NA,NA,NA,NA,NA,NA))
> 
> 
> #1) Is that possible without using specialized package?
> #2) Any specialized package function realize that?
> 

Everything else is a matter of relatively simple algorithms. 
You may want to start with 
coords <- rbind(GPS[, c("Lon", "Lat")], POIdef[, c("Lon", "Lat")])
d <- dist(coords)
which(as.matrix(d) < .1, arr.ind=TRUE)
and proceed from there.


-- 
Johannes Hüsing               There is something fascinating about science. 
                              One gets such wholesale returns of conjecture 
mailto:johan...@huesing.name  from such a trifling investment of fact.          
      
http://derwisch.wikidot.com         (Mark Twain, "Life on the Mississippi")

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to