TransGPS_Details

TransGPS: Toward a better analysis of GPS data

This package is developed to ease the tedious procedure of GPS data cleaning and map matching. The functions provided here focus from the very basic regularization and coordinates conversion of the GPS data toward creating bounding boxes and accessing the well-known OpenStreetMap(OSM) data for the purpose of map matching.

Creating bounding boxes allows the users to access OSM data without any challenges of developing a data server. This package also provides an interactive platform for the users to find the desired bounding boxes on the map. Finally, the user can find the best link match for each GPS coordinate.

Installation

devtools::install_github("farinoushsharifi/TransGPS")

Usage

library(TransGPS)

### Load Sample Data
data("SampleTransGPS")

The first 10 rows of the data can be seen here:

#>    Latitude Longitude First.Time
#> 1  31.67514 -106.3265 3:09:56 PM
#> 2  31.67519 -106.3264 3:09:57 PM
#> 3  31.67525 -106.3262 3:09:58 PM
#> 4  31.67530 -106.3261 3:09:59 PM
#> 5  31.67536 -106.3259 3:10:00 PM
#> 6  31.67541 -106.3257 3:10:01 PM
#> 7  31.67547 -106.3256 3:10:02 PM
#> 8  31.67552 -106.3254 3:10:03 PM
#> 9  31.67557 -106.3252 3:10:04 PM
#> 10 31.67562 -106.3251 3:10:05 PM

1. Coordinates Conversion to New CRS

Conversion of the GPS coordinates into a new CRS is the base to initiate any GPS analysis studies. convert_crs takes the initial latitude and longitude of a list of points and convert to any new CRS. The default value for the final projection is "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0", which the CRS corresponding to OSM data (and the CRS for the SampleTransGPS data).

The first 10 rows of the converted data can be seen here:

#>    convlist.Latitude convlist.Longitude
#> 1            6439795           -8105449
#> 2            6439771           -8105439
#> 3            6439747           -8105430
#> 4            6439723           -8105420
#> 5            6439698           -8105410
#> 6            6439673           -8105401
#> 7            6439647           -8105390
#> 8            6439622           -8105381
#> 9            6439597           -8105372
#> 10           6439573           -8105362

2. Coordinates Interpolation

Intepolation of coordinates over a desired time sequence is so useful in case of irregular time sequence or better visualization of data on contour maps. Function interpolate_coords takes the lists of latitudes and longitudes over an irregular time sequence and interpolates coordinates.

There is no need to sort the data before using the interpolation_coords function. The first 10 rows can be seen here:

#>      Latitude Longitude First.Time
#> 1139 31.82894 -106.3016 3:24:22 PM
#> 403  31.73506 -106.2673 3:16:38 PM
#> 1129 31.82849 -106.3630 3:32:20 PM
#> 574  31.77750 -106.2678 3:19:29 PM
#> 877  31.81893 -106.3653 3:35:20 PM
#> 15   31.67587 -106.3242 3:10:10 PM
#> 298  31.71324 -106.2735 3:14:53 PM
#> 1524 31.84117 -106.3285 3:27:40 PM
#> 1244 31.83198 -106.3624 3:30:18 PM
#> 234  31.70294 -106.2829 3:13:49 PM

This data can be interpolated using function interpolate_coord

The first 10 rows of this interpolated datacan be seen here:

#>               DateTime Latitude Longitude
#> 1  2019-05-08 15:09:59 31.67530 -106.3261
#> 2  2019-05-08 15:10:01 31.67541 -106.3257
#> 3  2019-05-08 15:10:03 31.67551 -106.3254
#> 4  2019-05-08 15:10:05 31.67561 -106.3251
#> 5  2019-05-08 15:10:07 31.67572 -106.3247
#> 6  2019-05-08 15:10:09 31.67582 -106.3244
#> 7  2019-05-08 15:10:11 31.67592 -106.3241
#> 8  2019-05-08 15:10:13 31.67602 -106.3237
#> 9  2019-05-08 15:10:15 31.67612 -106.3234
#> 10 2019-05-08 15:10:17 31.67622 -106.3230

3. Generate Bounding Boxes

While working with specific few roads rather than the whole network, generating regions and boxes around the corridors helps to better focus on the route, instead of the whole area, and remove unnecessary areas or roads from the data. So, accessing the OSM data can be easier, less challenging, and can be done in small chunks. get_boxes function splits the corridors in smaller regions by considering a maximum route distance of resolution within each box. offLong and offLatare the margins of each box from the closest coordinate point. The output gives the ID of box (boxcuts) for each point as well as the coordinates of each box (boxlists).

Details

For more information on TransGPS Package, please access the package documentations. Please feel free to contact the author.