Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mollietaylor/tracking-app
base: 8533b5fdfc
...
head fork: mollietaylor/tracking-app
compare: 8d0fecc3e2
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 31 additions and 22 deletions.
  1. +31 −22 map.R
View
53 map.R
@@ -5,21 +5,11 @@
# All rights reserved
#
+source("functions.R")
+
allTracks <- read.csv("allTracks.csv",
header = TRUE)
-rangeConst <- 0.05
-meanLon <- mean(allTracks$Longitude)
-meanLat <- mean(allTracks$Latitude)
-lonHiRange <- quantile(allTracks$Longitude, probs = c(1 - rangeConst))
-lonLoRange <- quantile(allTracks$Longitude, probs = c(rangeConst))
-lonRange <- lonHiRange - lonLoRange
-latHiRange <- quantile(allTracks$Latitude, probs = c(1 - rangeConst))
-latLoRange <- quantile(allTracks$Latitude, probs = c(rangeConst))
-latRange <- latHiRange - latLoRange
-# lonRange <- range(allTracks$Longitude)[2] - range(allTracks$Longitude)[1]
-# latRange <- range(allTracks$Latitude)[2] - range(allTracks$Latitude)[1]
-
allTracks$Latitude <- ifelse(is.na(allTracks$Seg), NA, allTracks$Latitude)
allTracks$Longitude <- ifelse(is.na(allTracks$Seg), NA, allTracks$Longitude)
@@ -27,11 +17,16 @@ library(ggmap)
# let user choose directory to save in:
library(tcltk)
+<<<<<<< HEAD
+mapDir <- tk_choose.dir(caption = "Choose directory to store maps")
+=======
mapDir <- tk_choose.dir()
+>>>>>>> 8533b5fdfc22ce3f62308f4d45169b3b76a78e77
+specs <- mapSpecs(allTracks, 0)
# default map:
- mapImageData <- get_map(location = c(lon = meanLon,
- lat = meanLat),
+ mapImageData <- get_map(location = c(lon = specs$meanLon,
+ lat = specs$meanLat),
zoom = 11,
# size = c(500, 500),
maptype = c("toner"), #toner, watercolor
@@ -54,15 +49,11 @@ mapDir <- tk_choose.dir()
dev.copy(png, paste(mapDir, "/default.png", sep = ""))
dev.off()
-
-mapWidth <- max(lonRange, latRange)
-
-mapZoom <- floor(13 - log2(10 * mapWidth))
-
# auto map:
- mapImageData <- get_map(location = c(lon = mean(c(lonLoRange, lonHiRange)),
- lat = mean(c(latLoRange, latHiRange))), # maybe use 20th/80th percentile or something instead of min/max
- zoom = mapZoom,
+ specs <- mapSpecs(allTracks, 0.05) # percentile
+ mapImageData <- get_map(location = c(lon = mean(c(specs$lonLoRange, specs$lonHiRange)),
+ lat = mean(c(specs$latLoRange, specs$latHiRange))), # maybe use 20th/80th percentile or something instead of min/max
+ zoom = specs$mapZoom,
# size = c(500, 500),
maptype = c("toner"), #toner, watercolor
source = c("stamen"))
@@ -84,12 +75,22 @@ mapZoom <- floor(13 - log2(10 * mapWidth))
dev.copy(png, paste(mapDir, "/auto.png", sep = ""))
dev.off()
+<<<<<<< HEAD
+# the past month:
+allTracks$Date <- as.Date(allTracks$Date, "%Y/%m/%d")
+lastMonth <- allTracks[which(allTracks$Date >= Sys.Date() - 30),]
+specs <- mapSpecs(lastMonth, 0)
+ mapImageData <- get_map(location = c(lon = mean(c(specs$lonLoRange, specs$lonHiRange)),
+ lat = mean(c(specs$latLoRange, specs$latHiRange))), # maybe use 20th/80th percentile or something instead of min/max
+ zoom = specs$mapZoom,
+=======
# last month:
allTracks$Date <- as.Date(allTracks$Date, "%Y/%m/%d")
lastMonth <- allTracks[which(allTracks$Date >= Sys.Date() - 30),]
mapImageData <- get_map(location = c(lon = mean(c(lonLoRange, lonHiRange)),
lat = mean(c(latLoRange, latHiRange))), # maybe use 20th/80th percentile or something instead of min/max
zoom = mapZoom,
+>>>>>>> 8533b5fdfc22ce3f62308f4d45169b3b76a78e77
# size = c(500, 500),
maptype = c("toner"), #toner, watercolor
source = c("stamen"))
@@ -98,13 +99,21 @@ lastMonth <- allTracks[which(allTracks$Date >= Sys.Date() - 30),]
darken = c(0.6, "white")) + # makes basemap lighter
geom_path(aes(x = Longitude,
y = Latitude),
+<<<<<<< HEAD
+ data = lastMonth,
+=======
data = allTracks,
+>>>>>>> 8533b5fdfc22ce3f62308f4d45169b3b76a78e77
colour = "black", #F8971F F4640D
size = 1.2,
pch = 20) +
geom_path(aes(x = Longitude,
y = Latitude),
+<<<<<<< HEAD
+ data = lastMonth,
+=======
data = allTracks,
+>>>>>>> 8533b5fdfc22ce3f62308f4d45169b3b76a78e77
colour = "#F8971F", #F8971F F4640D
size = 0.8,
pch = 20)

No commit comments for this range

Something went wrong with that request. Please try again.