-
Notifications
You must be signed in to change notification settings - Fork 1
13_VMS_get_recs
May 2, 2018 - Mike McMahon (mike.mcmahon@dfo-mpo.gc.ca)
This function extracts VMS data for a given timespan and area. A time buffer can be added returns other points that are not within the area of interest, but give context to the path.
Interestingly, for the example extraction, almost 100 records had bad positions, so wrapping the VMS in a df_qc_spatial() allows us to plot them.
vms = VMS_get_recs(dateStart = '2010-06-15 00:00:00',dateEnd = '2010-06-15 12:00:00',vrnList = NULL )
> nrow(vms)
# make_segments() is ideal for plotting this kind of data (or turning it into shapefiles)
> vmsSegs = make_segments(df_qc_spatial(vms), objField = "VR_NUMBER", seqField = "POSITION_UTC_DATE", lat.field = "LATITUDE", lon.field="LONGITUDE")
To get fancier, you can even ask it to only return VMS data that lies within a certain spatial area, and in such cases, it's useful to add an hrBuffer, which adds data from the surrounding hours. This gives some context to what the vessel was doing around the time it was crossing the area of interest. If your area shapefile has multiple polygons, the value for shp.field will be tacked onto your returned data so you know which polygon a particular vessel was in.
In the example below, we'll extract data that existed within the 5Z9 strata on a particular day with a variety of hrBuffer values.
vms5Z9 = VMS_get_recs(dateStart = '2010-06-15 00:00:00',dateEnd = '2010-06-17 00:00:00',shp = "/home/mike/sf_Documents/5Z9.shp",shp.field = "StrataID",hrBuffer = 2)
vms5Z9Segs = make_segments(vms5Z9, objField = "VR_NUMBER", seqField = "POSITION_UTC_DATE", lat.field = "LATITUDE", lon.field="LONGITUDE")| No hour buffer (hrBuffer = 0) | No hour buffer (hrBuffer = 2) | No hour buffer (hrBuffer = 10) |
|---|---|---|
![]() |
![]() |
![]() |
Additionally, a vector or VRNs can be provided to limit the results to certain vessels. In the interest of privacy, I'm not putting up an example of that, but the if you wanted the tracks of a particular fleet as it related to particular polygons, you might do:
test = VMS_get_recs(dateStart = '2010-06-15 00:00:00',dateEnd = '2010-06-17 00:00:00',shp = "C:/specialAreas.shp",shp.field = "FULL_DESCR",hrBuffer = 2, vrnList =c(11111,11112,11113))
head(test)
VR_NUMBER LATITUDE LONGITUDE POSITION_UTC_DATE SPEED_KNOTS UPDATE_DATE FULL_DESCR SEGMID
11111 42.340000 -63.13150 2010-06-15 00:07:00 NA 2012-03-23 16:47:18 <NA> 1525361819_11111_1
11111 42.340000 -63.13150 2010-06-15 00:07:00 NA 2012-03-23 16:47:18 Special Area 1 1525361819_11111_1
11112 41.350000 -63.13833 2010-06-15 00:17:36 NA 2012-03-23 16:47:21 <NA> 1525361819_11112_1
11112 41.350000 -63.13833 2010-06-15 00:17:36 NA 2012-03-23 16:47:21 Special Area 1 1525361819_11112_1
11112 41.340000 -65.13583 2010-06-15 00:47:53 NA 2012-03-23 16:47:24 Special Area 1 1525361819_11112_1
11113 42.920000 -65.13950 2010-06-15 01:00:00 NA 2012-03-23 16:48:07 <NA> 1525361819_11113_1
# the VR_NUMBERS and positions have all been changed to silly values

