Part 1: Using a GPS
1. First, explore the GPS unit. Use the “Page” button to cycle from page to page.
On the map page, you can zoom in and out with the “in” and “out” buttons.
Cycle through to the Main Menu page. Explore the different menus (use the “quit” button to go back).
2. Go to the “Setup” page on the Main Menu (press “Menu” twice) and then go to “Units” or “Location”.
What coordinate system is your GPS using? Make sure it is set to WGS 84, and that the position format is hddd.ddddd (this is very important!)
Now go to the “time” page. What time zone is your unit in? Make sure it is set to our time zone.
3. Look at the Acquiring Satellites page.
How many satellites is your GPS unit communicating with? It will take several minutes to connect with satellites.
It is important that the GPS is able to triangulate its position – with several satellites in different locations
and at different angles (right above, and several at angles on all sides).
If you have an Android phone, you can also use your phone!
Download the free app “GPSLogger”. (for an iPhone, you can use GPS & Maps, or other similar apps)
After installing, you may need to allow the app to access certain parts of your phone.
As with any free app, make sure the accesses you are agreeing to make sense.
Both a GPS unit or the GPSLogger app on your phone will tell you the approximate error at which you can take a point (on a GPS unit this is on the acquiring satellites page). Before you take your first point, make a note of the error:
What is the current error/accuracy? ____________________
As you move around, notice how the error changes as the number and location of satellites changes.
Go into a building. How does the error change? ___________________________________________
Go under a tree. How does the error change? _____________________________________________
In general, you want to only record a point with less than 10m error – or perhaps even less if possible. Based on the conditions of the day ##### – decide what level of error you will accept around each point you collect in today’s lab: ___________________
4. Now, you will choose three features outside from which to collect data.
Choose a point, a line, and a polygon feature (e.g. a flagpole, a sidewalk, and a fountain). For the line and the polygon, you will be collecting point data that you will later turn into a line and a polygon in R. To create the line and polygon using points, you have to decide on the resolution of point samples you will use to construct your line or polygon. Will you take a point every 10m along your line? Every 3m? Record here the sampling resolution of your line and polygon features: ______________________________________
To record a point in your GPS unit, press and hold the “Mark” button (sometimes the “Enter” button). The waypoint menu appears. Record the information in the table (next page) and then hit (OK). To edit or take a second look at the waypoint you recorded, go to Menu-Points-Waypoints (or for the 62sc press the “Find” button and then go to “Waypoints”).
Part 2: Importing GPS data into R
5. You can either manually input your points using Excel (or any other spreadsheet software), or, much easier, you can import data directly into R for visualization and analysis.
5a. Using your smart phone:
Make sure to send yourself (via email or other way) the .csv file from your phone so that you can access it on your computer, and move it into your working directory.
5b. Directly importing data from a GPS unit using a USB cable:
Plug in the GPS Unit with a USB cable. Find the device folder and navigate to “GPX” and “Current” – move the Current.gpx file into your working directory.
Load required packages
require(raster);require(sp);require(rgdal); require(ggmap)
## Loading required package: raster
## Loading required package: sp
## Loading required package: rgdal
## rgdal: version: 1.2-18, (SVN revision 718)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 1.11.3, released 2015/09/16
## Path to GDAL shared files: /usr/share/gdal/1.11
## GDAL binary built with GEOS: TRUE
## Loaded PROJ.4 runtime: Rel. 4.9.2, 08 September 2015, [PJ_VERSION: 492]
## Path to PROJ.4 shared files: (autodetected)
## Linking to sp version: 1.2-7
## Loading required package: ggmap
## Loading required package: ggplot2
Housekeeping
# Set your working directory
setwd('/home/pjg/GIS')
# Create a directory folder and move into it
dir.create('AdvancedGIS_R')
setwd('AdvancedGIS_R')
If you are using data from a Garmin GPS
If you are using GPS data from Cellphone
Visualizing waypoints on satellite imagery
As a check, plot the waypoints on Google Earth imagery
###############################################################
############ Visualizing and creating features ##############
###############################################################
## Visualizing your waypoints with satellite data
# Find the bounding box of your waypoints
loc = cbind(c(min(wps$lon), max(wps$lon)), c(min(wps$lat), max(wps$lat)))
# Name the columns
loc = as.data.frame(loc)
colnames(loc) = c('lon', 'lat')
# Get the images from Google Earth Engine
manbox <- make_bbox(lon = loc$lon, lat = loc$lat, f = .1)
manmap <- get_map(location = manbox, maptype = "satellite", source = "google", zoom =18)
# Plot
ggmap(manmap) +
geom_point(data = wps,
color = "red",
size =1) # for better resolution, change size to smaller

Creating Shapefile Features from localities
## Transform the waypoints and save as a shapefile
wpsShp<-SpatialPointsDataFrame(coords = wps[,1:2], data = wps)
writeOGR(obj = wpsShp, dsn = paste(getwd()), layer = "Allwaypoints", driver = "ESRI Shapefile")
Separate the data into the appropriate features from which waypoints were taken outside
The first step is to take another look at the data and find the rownumber of the corresponding feature
print(wps)
## lon lat time elevation accuracy
## 1 -74.29108 41.22050 2018-04-13T15:01:31.966Z NA 20.274
## 2 -74.29101 41.22051 2018-04-13T15:03:20.109Z NA 20.249
## 3 -74.29101 41.22051 2018-04-13T15:03:20.110Z NA 20.249
## 4 -74.29116 41.22035 2018-04-13T15:04:47.000Z 263 37.000
## 5 -74.29070 41.22019 2018-04-13T15:05:08.000Z 254 39.000
## 6 -74.29095 41.22050 2018-04-13T15:05:36.119Z NA 20.460
## 7 -74.29109 41.22045 2018-04-13T15:06:36.470Z NA 23.969
## 8 -74.29080 41.22039 2018-04-13T15:07:19.000Z 216 38.000
## 9 -74.29077 41.22048 2018-04-13T15:06:54.837Z NA 21.048
## 10 -74.29083 41.22043 2018-04-13T15:07:36.000Z 204 37.000
## 11 -74.29064 41.22059 2018-04-13T19:06:07.000Z 180 21.000
## 12 -74.29064 41.22055 2018-04-13T19:07:38.000Z 186 40.000
## 13 -74.29066 41.22055 2018-04-13T19:08:47.000Z 188 34.000
## 14 -74.29067 41.22056 2018-04-13T19:10:09.000Z 186 31.000
## 15 -74.29068 41.22057 2018-04-13T19:10:13.000Z 185 16.000
## 16 -74.29068 41.22057 2018-04-13T19:10:16.000Z 185 18.000
## 17 -74.29120 41.22047 2018-04-13T19:09:43.811Z NA 19.906
## 18 -74.29120 41.22047 2018-04-13T19:09:43.811Z NA 19.906
## 19 -74.29069 41.22057 2018-04-13T19:10:25.000Z 185 23.000
## 20 -74.29070 41.22057 2018-04-13T19:10:28.000Z 184 16.000
## 21 -74.29071 41.22058 2018-04-13T19:10:30.000Z 183 15.000
## 22 -74.29115 41.22049 2018-04-13T19:10:07.017Z NA 22.561
## 23 -74.29082 41.22050 2018-04-13T19:20:28.000Z 173 32.000
## 24 -74.29077 41.22047 2018-04-13T19:20:11.969Z NA 21.443
## 25 -74.29078 41.22048 2018-04-13T19:20:26.408Z NA 22.295
# Enter the row number of the point feature below
PointFeat<- 1
# Enter the row numbers of the line features below, separated with a colon
LineFeat<- 2:10
# As above, enter the row numbers of the polygon features below, separated with a colon
PolyFeat<- 11:22
# Now, use these row numbers to create individual 'spatial' objects for each of the features
# Point features
PointShape <- SpatialPointsDataFrame(wps[,1:2][PointFeat,], data = wps[PointFeat,])
# Line features
PointLine <- SpatialLinesDataFrame(sl = SpatialLines(list(Lines(list(Line(coords = wps[,1:2][LineFeat,])), ID='a'))), match.ID = F, data = as.data.frame("Line"))
# Polygon features
PointPoly <- SpatialPolygonsDataFrame(Sr = SpatialPolygons(list(Polygons(list(Polygon(wps[PolyFeat,][,1:2])),"Poly"))), data = data.frame("Poly"), match.ID = F)
Saving as ESRI shapefiles
writeOGR(obj = PointShape, dsn = paste(getwd()), layer = "PointFeature", driver = "ESRI Shapefile")
writeOGR(obj = PointLine, dsn = paste(getwd()), layer = "LineFeature", driver = "ESRI Shapefile")
writeOGR(obj = PointPoly, dsn = paste(getwd()), layer = "PolyFeature", driver = "ESRI Shapefile")
Test for accuracy
PointShape
ggmap(manmap) +
geom_point(data = data.frame(PointShape@coords),
color = "red",
size =1) # for better resolution, change size to smaller

# LineShape
ggmap(manmap) +
geom_polygon(data = PointLine,
aes(x = long, y = lat),
color = "red",
size =1) # for better resolution, change size to smaller

# PolyShape
ggmap(manmap) +
geom_polygon(data = PointPoly,
aes(x = long, y = lat),
color = "red",
size =1) # for better resolution, change size to smaller
## Regions defined for each Polygons
