Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Jul 11, 2018
1 parent b66823f commit 32f36bd
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 77 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Expand Up @@ -4,9 +4,6 @@ language: R
sudo: false
cache: packages

r_github_packages:
- tidyverse/ggplot2

addons:
apt:
sources:
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Expand Up @@ -12,9 +12,9 @@ Description: Spatial data plus the power of the ggplot2 framework means easier m
License: GPL-3
Depends:
R (>= 2.10),
ggplot2 (>= 2.0),
sf
ggplot2 (>= 2.2.1.9000)
Imports:
sf,
rosm (>= 0.2),
abind,
reshape2,
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-annotation-scale.R
Expand Up @@ -2,7 +2,7 @@ context("test-annotation-scale.R")

test_that("scale bar parameters are generated correctly", {
load_longlake_data()
nc <- read_sf(system.file("shape/nc.shp", package="sf"))
nc <- sf::read_sf(system.file("shape/nc.shp", package="sf"))

expect_equal(
scalebar_params(
Expand Down Expand Up @@ -42,7 +42,7 @@ test_that("scale bar parameters are generated correctly", {

test_that("annotation scale works as intended", {
load_longlake_data()
nc <- read_sf(system.file("shape/nc.shp", package="sf"))
nc <- sf::read_sf(system.file("shape/nc.shp", package="sf"))

# defaults are ok
print(
Expand Down
142 changes: 72 additions & 70 deletions tests/testthat/test-df_spatial.R
Expand Up @@ -28,76 +28,78 @@ test_that("Spatial* objects are fortified correctly", {
# load the long lake test data
load_longlake_data()

# SpatialPoints
spoints_df <- as(longlake_depthdf, "Spatial")
spoints <- sp::SpatialPoints(spoints_df, proj4string = spoints_df@proj4string)
expect_df_spatial(spoints)
expect_equal(nrow(df_spatial(spoints)), length(spoints))
expect_df_spatial(spoints_df, c("NOTES", "DEPTH.M"))

# SpatialMultiPoints
spmultipoints_sf <- dplyr::summarise(dplyr::group_by(longlake_depthdf, NOTES), one = 1)
spmultipoints_df <- as(spmultipoints_sf, "Spatial")
spmultipoints <- as(spmultipoints_df, "SpatialMultiPoints")

expect_df_spatial(spmultipoints)
expect_df_spatial(spmultipoints_df, c("NOTES", "one"))
expect_true(setequal(df_spatial(spmultipoints_df)$NOTES, c("mouth of inlet", "reeds", NA)))

# SpatialLines
splines_df <- as(sf::st_zm(longlake_roadsdf), "Spatial")
splines <- sp::SpatialLines(splines_df@lines, proj4string = splines_df@proj4string)
line <- splines@lines[[1]]@Lines[[1]]
lines <- splines@lines[[1]]

expect_df_spatial(line)

expect_df_spatial(lines, c("coordinate_id", "piece_id"))
expect_is(df_spatial(lines)$coordinate_id, "integer")
expect_is(df_spatial(lines)$piece_id, "factor")

expect_df_spatial(splines, c("coordinate_id", "piece_id"))
expect_is(df_spatial(splines)$coordinate_id, "integer")
expect_is(df_spatial(splines)$piece_id, "factor")

expect_df_spatial(splines_df, c("coordinate_id", "piece_id", "FEAT_CODE"))
expect_is(df_spatial(splines_df)$coordinate_id, "integer")
expect_is(df_spatial(splines_df)$piece_id, "factor")

# manual check of success
# ggplot(df_spatial(splines)) + geom_path(aes(x, y, group = piece_id))
# ggplot(df_spatial(splines_df)) + geom_path(aes(x, y, group = piece_id))

# SpatialPolygons
spoly_df <- as(sf::st_zm(longlake_waterdf), "Spatial")
spoly <- as(spoly_df, "SpatialPolygons")
polygon <- spoly@polygons[[1]]@Polygons[[1]]
polygons <- spoly@polygons[[1]]

expect_df_spatial(polygon, c("is_hole", "ring_direction"))

expect_df_spatial(polygons, c("coordinate_id", "piece_id"))
expect_is(df_spatial(polygons)$coordinate_id, "integer")
expect_is(df_spatial(polygons)$piece_id, "factor")

expect_df_spatial(spoly, c("coordinate_id", "piece_id"))
expect_is(df_spatial(spoly)$coordinate_id, "integer")
expect_is(df_spatial(spoly)$piece_id, "factor")

expect_df_spatial(spoly_df, c("coordinate_id", "piece_id"))
expect_is(df_spatial(spoly_df)$coordinate_id, "integer")
expect_is(df_spatial(spoly_df)$piece_id, "factor")

# manual check of success
# ggplot(df_spatial(spoly)) + geom_polypath(aes(x, y, group = piece_id))
# ggplot(df_spatial(spoly_df)) + geom_polypath(aes(x, y, group = piece_id))

# sf points, multipoints, lines, polygons, and sfc
expect_identical(df_spatial(longlake_depthdf), df_spatial(spoints_df))
expect_identical(df_spatial(spmultipoints_sf), df_spatial(spmultipoints_df))
expect_identical(df_spatial(longlake_roadsdf), df_spatial(splines_df))
expect_identical(df_spatial(longlake_waterdf), df_spatial(spoly_df))
expect_df_spatial(longlake_depthdf$geometry)
withr::with_package("sf", {
# SpatialPoints
spoints_df <- as(longlake_depthdf, "Spatial")
spoints <- sp::SpatialPoints(spoints_df, proj4string = spoints_df@proj4string)
expect_df_spatial(spoints)
expect_equal(nrow(df_spatial(spoints)), length(spoints))
expect_df_spatial(spoints_df, c("NOTES", "DEPTH.M"))

# SpatialMultiPoints
spmultipoints_sf <- dplyr::summarise(dplyr::group_by(longlake_depthdf, NOTES), one = 1)
spmultipoints_df <- as(spmultipoints_sf, "Spatial")
spmultipoints <- as(spmultipoints_df, "SpatialMultiPoints")

expect_df_spatial(spmultipoints)
expect_df_spatial(spmultipoints_df, c("NOTES", "one"))
expect_true(setequal(df_spatial(spmultipoints_df)$NOTES, c("mouth of inlet", "reeds", NA)))

# SpatialLines
splines_df <- as(sf::st_zm(longlake_roadsdf), "Spatial")
splines <- sp::SpatialLines(splines_df@lines, proj4string = splines_df@proj4string)
line <- splines@lines[[1]]@Lines[[1]]
lines <- splines@lines[[1]]

expect_df_spatial(line)

expect_df_spatial(lines, c("coordinate_id", "piece_id"))
expect_is(df_spatial(lines)$coordinate_id, "integer")
expect_is(df_spatial(lines)$piece_id, "factor")

expect_df_spatial(splines, c("coordinate_id", "piece_id"))
expect_is(df_spatial(splines)$coordinate_id, "integer")
expect_is(df_spatial(splines)$piece_id, "factor")

expect_df_spatial(splines_df, c("coordinate_id", "piece_id", "FEAT_CODE"))
expect_is(df_spatial(splines_df)$coordinate_id, "integer")
expect_is(df_spatial(splines_df)$piece_id, "factor")

# manual check of success
# ggplot(df_spatial(splines)) + geom_path(aes(x, y, group = piece_id))
# ggplot(df_spatial(splines_df)) + geom_path(aes(x, y, group = piece_id))

# SpatialPolygons
spoly_df <- as(sf::st_zm(longlake_waterdf), "Spatial")
spoly <- as(spoly_df, "SpatialPolygons")
polygon <- spoly@polygons[[1]]@Polygons[[1]]
polygons <- spoly@polygons[[1]]

expect_df_spatial(polygon, c("is_hole", "ring_direction"))

expect_df_spatial(polygons, c("coordinate_id", "piece_id"))
expect_is(df_spatial(polygons)$coordinate_id, "integer")
expect_is(df_spatial(polygons)$piece_id, "factor")

expect_df_spatial(spoly, c("coordinate_id", "piece_id"))
expect_is(df_spatial(spoly)$coordinate_id, "integer")
expect_is(df_spatial(spoly)$piece_id, "factor")

expect_df_spatial(spoly_df, c("coordinate_id", "piece_id"))
expect_is(df_spatial(spoly_df)$coordinate_id, "integer")
expect_is(df_spatial(spoly_df)$piece_id, "factor")

# manual check of success
# ggplot(df_spatial(spoly)) + geom_polypath(aes(x, y, group = piece_id))
# ggplot(df_spatial(spoly_df)) + geom_polypath(aes(x, y, group = piece_id))

# sf points, multipoints, lines, polygons, and sfc
expect_identical(df_spatial(longlake_depthdf), df_spatial(spoints_df))
expect_identical(df_spatial(spmultipoints_sf), df_spatial(spmultipoints_df))
expect_identical(df_spatial(longlake_roadsdf), df_spatial(splines_df))
expect_identical(df_spatial(longlake_waterdf), df_spatial(spoly_df))
expect_df_spatial(longlake_depthdf$geometry)
})
})

test_that("Raster* objects are converted properly by df_spatial", {
Expand Down

0 comments on commit 32f36bd

Please sign in to comment.