Hello everyone,
I'm trying to plot a basemap downloaded by dismo
package together with a shapefile. However after knitting the PDF file, there is a big space in between these two lines:
plot(base.map)
plot(reproj.boundary, add = TRUE, border = "red", col = "transparent")
Is this a bug in rmarkdown or I am doing something wrong?
Thank you!
My Rmd file:
---
title: "Mapping with R"
date: "February, 2018"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
# install.packages(c("hydroMap", "dataRetrieval", "rgdal", "dismo"),
# dependencies = TRUE,
# repos = "http://cran.us.r-project.org")
suppressMessages(library(hydroMap))
suppressMessages(library(dataRetrieval))
suppressMessages(library(rgdal))
sites <- "12488500"
siteInfo <- readNWISsite(sites)
# Download boundary
hydroMap::getBasin(sites, filePath = "./download")
boundary <- readOGR(dsn = "./download", layer = "epa_basins")
watershed_extent <- c(boundary@bbox[1], boundary@bbox[3],
boundary@bbox[2], boundary@bbox[4])
# Pass object to plot as first argument and map-type as second
base.map <- dismo::gmap(boundary, type = "terrain")
# Reproject watershed boundary to be the same as Google Map base.map
reproj.boundary <- spTransform(boundary, base.map@crs)
# Plot
plot(base.map)
plot(reproj.boundary, add = TRUE, border = "red", col = "transparent")