Skip to content

Commit

Permalink
Merge pull request #32 from neilcharles/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
neilcharles committed May 3, 2019
2 parents 9e1bcf9 + a40b76d commit ee79ebd
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 34 deletions.
2 changes: 0 additions & 2 deletions CRAN-RELEASE

This file was deleted.

3 changes: 2 additions & 1 deletion DESCRIPTION
@@ -1,10 +1,11 @@
Package: geoviz
Type: Package
Title: Elevation and GPS Data Visualisation
Version: 0.2.1.9000
Version: 0.2.1
Author: Neil Charles
Maintainer: Neil Charles <neil.d.charles@gmail.com>
Description: Simpler processing of digital elevation model and GPS trace data for use with the 'rayshader' package.
URL: https://github.com/neilcharles/geoviz/
License: GPL-3
Encoding: UTF-8
LazyData: true
Expand Down
2 changes: 1 addition & 1 deletion R/add_gps_to_rayshader.R
Expand Up @@ -23,7 +23,7 @@
#' flight$lat,
#' flight$long,
#' flight$altitude,
#' zscale = raster_zscale(example_raster()))
#' zscale = 25)
#'
#' @export
add_gps_to_rayshader <- function(raster_input, lat, long, alt, zscale, line_width = 1, colour = "red", alpha = 0.8, lightsaber = TRUE, clamp_to_ground = FALSE, raise_agl = 0, ground_shadow = FALSE, as_line = TRUE, point_size = 20){
Expand Down
4 changes: 2 additions & 2 deletions R/elevation_shade.R
Expand Up @@ -13,8 +13,8 @@
elevation_shade <- function(raster_dem, elevation_palette = c("#54843f", "#808080", "#FFFFFF"), return_png = TRUE, png_opacity = 0.9){

if(length(is.na(raster_dem)) > 0){
warning("There are NA values in raster_dem. Assuming they are min(raster_dem@data@values, na.rm = TRUE) for shading.")
raster_dem[is.na(raster_dem)] <- min(raster_dem@data@values, na.rm = TRUE)
message("There are NA values in raster_dem. Assuming they are min(raster_dem[], na.rm = TRUE) for shading.")
raster_dem[is.na(raster_dem)] <- min(raster_dem[], na.rm = TRUE)
}

rasterValues <- raster::values(raster_dem)
Expand Down
4 changes: 2 additions & 2 deletions R/elevation_transparency.R
Expand Up @@ -39,8 +39,8 @@ elevation_transparency <- function(overlay_image, raster_dem, alpha_max = 0.4, a
}

if(length(is.na(raster_dem)) > 0){
warning("There are NA values in raster_dem. Assuming they are min(raster_dem@data@values, na.rm = TRUE) for shading.")
raster_dem[is.na(raster_dem)] <- min(raster_dem@data@values, na.rm = TRUE)
message("There are NA values in raster_dem. Assuming they are min(raster_dem[], na.rm = TRUE) for shading.")
raster_dem[is.na(raster_dem)] <- min(raster_dem[], na.rm = TRUE)
}

pct_max_height <- (raster::as.array(raster_dem) - min(raster::as.array(raster_dem))) / (max(raster::as.array(raster_dem)) - min(raster::as.array(raster_dem)))
Expand Down
2 changes: 1 addition & 1 deletion R/get_slippy_map.R
@@ -1,6 +1,6 @@
#' Obtains and merges map tiles from various sources using the 'slippymath' package
#'
#' @param bounding_box Any object for which raster::extent() can be calculated. Your object must use WGS84 coordinates.
#' @param bounding_box Any object for which raster::extent() can be calculated.
#' @param image_source Source for the overlay image. Valid entries are "mapbox", "mapzen", "stamen".
#' @param image_type The type of overlay to request. "satellite", "mapbox-streets-v8", "mapbox-terrain-v2", "mapbox-traffic-v1", "terrain-rgb", "mapbox-incidents-v1" (mapbox), "dem" (mapzen) or "watercolor", "toner", "toner-background", "toner-lite" (stamen). You can also request a custom Mapbox style by specifying \code{image_source = "mapbox", image_type = "username/mapid"}
#' @param max_tiles Maximum number of tiles to be requested by 'slippymath'
Expand Down
2 changes: 1 addition & 1 deletion R/mapzen_dem.R
Expand Up @@ -13,7 +13,7 @@
#' long = -3.1767946
#' square_km = 2
#'
#' dem <- mapzen_dem(lat, long, square_km, max_tiles = 5)
#' dem <- mapzen_dem(lat, long, square_km, max_tiles = 2)
#' @export
mapzen_dem <- function(lat, long, square_km, width_buffer = 1, max_tiles = 10){

Expand Down
5 changes: 1 addition & 4 deletions R/utils.R
Expand Up @@ -16,9 +16,6 @@ square_bounding_box <- function(lat, long, square_km){
#create buffer square
bounding_shape <- rgeos::gBuffer(bounding_box, width = bounding_box$square_km * 1000, quadsegs=1, capStyle="SQUARE")

#reproject (skipping to try to work with laea)
#bounding_shape <- sp::spTransform(bounding_shape, sp::CRS("+proj=longlat +datum=WGS84 +no_defs"))

return(bounding_shape)
}

Expand Down Expand Up @@ -75,7 +72,7 @@ compose_tile_grid <- function (tile_grid, images)

#Apply the raster's colortable to create a 3 layer rgb version
raster_img <- raster::setValues(raster::brick(raster_img, raster_img, raster_img),
t(col2rgb(raster_img@legend@colortable))[raster::values(raster_img) + 1,])
t(grDevices::col2rgb(raster_img@legend@colortable))[raster::values(raster_img) + 1,])
}
#-------------------------------

Expand Down
13 changes: 5 additions & 8 deletions cran-comments.md
@@ -1,14 +1,11 @@
## Resubmission
Thank you for your feedback, this is a resubmission. Changes made:

* Commented unexecutable line in mapbox_dem() documentation

## Test environments
* local Windows 10, R 3.5.2
* Ubuntu 16.04.2 LTS, R 3.5.3
* local Windows 10, R 3.6.0
* Windows Server 2008 R-devel
* Fedora Linux R-devel
* win-builder (devel and release)

## R CMD check results
0 errors v | 0 warnings v | 0 notes v

## First Submission
## Downstream dependencies
None
2 changes: 1 addition & 1 deletion man/add_gps_to_rayshader.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/get_slippy_map.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/mapzen_dem.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion news.md
Expand Up @@ -17,7 +17,7 @@ Bug fixes:
Changes:
- mapbox_dem() and mapzen_dem() return a raster with the number of cells defined by 'max_tiles', rather than superimposing a resolution over the top, that had previously defaulted to 1000x1000. This allows you to more easily draw high resolution Rayshader scenes and doesn't arbitrarily drop the resolution of your scene if you forgot to increase resolution from the default.
- resolution option in slippy_raster() is deprecated
- Dropped max_tiles defaults from 30 to 20 as a better compromise between speed and rayshader scene resolution.
- Dropped max_tiles defaults from 30 to 10 as a better compromise between speed and rayshader scene resolution.


## 0.2.0
Expand Down
10 changes: 6 additions & 4 deletions tests/testthat/test_imagery.R
Expand Up @@ -7,26 +7,28 @@ DEM <- example_raster()
lat = 54.4502651
long = -3.1767946
square_km = 1

test_that("slippy_overlay() has correct dimensions", {
slippy_overlay_result <- slippy_overlay(DEM, max_tiles = 5)
slippy_overlay_result <- expect_warning(slippy_overlay(DEM, max_tiles = 5))

expect_is(slippy_overlay_result, "array")
expect_equal(ncol(slippy_overlay_result), ncol(DEM))
expect_equal(nrow(slippy_overlay_result), nrow(DEM))
})

test_that("slippy_raster() returns data", {
expect_is(
slippy_rater_result <- expect_warning(
slippy_raster(
lat,
long,
square_km,
image_source = "stamen",
image_type = "watercolor",
max_tiles = 5
),
"RasterBrick"
)
)

expect_is(slippy_rater_result, "RasterBrick")
})

test_that("elevation_shade() has correct dimensions", {
Expand Down
6 changes: 2 additions & 4 deletions vignettes/hawaii_mapzen_dem.Rmd
Expand Up @@ -4,14 +4,12 @@ author: "Neil Charles"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Scene With GPS trace}
%\VignetteIndexEntry{Hawaii Elevation and Bathymetry Using 'Mapzen'}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

Get elevation and bathymetry data for Hawaii from 'mapzen', add a 'stamen' overlay and render this scene.

![](figures/hawaii.jpg)
Get elevation and bathymetry data for Hawaii from 'mapzen', add a 'stamen' overlay and render the scene.

```R
library(geoviz)
Expand Down

0 comments on commit ee79ebd

Please sign in to comment.