Sampling: In the middle of nowhere

The Parameter

Our goal is to estimate the percentage of all locations within the continential United States that are within 1 mile of a road AND to determine the uncertainty in this estimate.

To do this we will make use of R's mosaic package, Google Maps and code provided by Sara Stoudt*, Yue Cao, Dana Udwin and Nicholas Horton.

*A fellow Kaggle Madness competitor

Mosaic Package

First install the mosaic package (you can pick any CRAN mirror) and load it.

require(mosaic)

Sample 20 locations within a range of Latitudes and Longitudes

nsamp = 20
samples = rgeo(n=nsamp, latlim = c(25, 50), lonlim=c(-65, -125))
myroadless = data.frame(sample=1:nsamp, latitude=round(samples$lat, 4),longitude=round(samples$lon, 4),
                        withinContinent=c(rep(NA, nsamp)),within1mile=c(rep(NA, nsamp)),
                        location=character(nsamp))
rm(samples, nsamp)
myroadless

Now take a look at your sample

print(myroadless)

Now create a function to look at one location at a time using Google Maps...

getLocation <- function(counter, radi=1) {
  googleMap(myroadless[counter,"latitude"], myroadless[counter,"longitude"], 
            mark=TRUE, maptype="terrain", radius=radi, browse=TRUE)
}

... and now investigate these locations

getLocation(1) #default 1 mile radius
# or to change the size of the circle
getLocation(1, radi=5) # a five mile radius
getLocation(2) # to look at the 2nd location

Try zooming out to see where you are. Complete your data sheet noting whether each location is within the continental US, whether it is within 1 mile of a road and including a quick note about the location.