Skip to content

trajectories vulnerable to forthcoming changes in sp and rgdal #25

@rsbivand

Description

@rsbivand

Running revdep checks for current rgdal on R-Forge - see:

https://stat.ethz.ch/pipermail/r-sig-geo/2019-November/027801.html

shows the errors in the attached test log, related to use of PROJ&/GDAL3
and required changes to sp and rgdal. If useful find a regerence to a docker
image in this thread:

r-spatial/discuss#28

Changes will occur quite fast, and packages need to be prepared.


R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> Sys.setenv(TZ = "Europe/Berlin")
> # Load required libraries.
> 
> library(sp)
> library(spacetime)
> library(trajectories)
> library(rgdal)
rgdal: version: 1.5-1, (SVN revision 889)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 3.0.2, released 2019/10/28
 Path to GDAL shared files: /usr/local/share/gdal
 GDAL binary built with GEOS: TRUE 
 Loaded PROJ.4 runtime: Rel. 6.2.1, November 1st, 2019, [PJ_VERSION: 621]
 Path to PROJ.4 shared files: /usr/local/share/proj
 Linking to sp version: 1.3-3 
> 
> # Create test objects. Do not change! Changes to the test objects are likely to
> # have an impact on the test results. It is primarily validated against class
> # and dimension. However, the test functions check for the first dimension only,
> # since, in the majority of cases, a deviation of the second is not necessarily
> # associated with a regression.
> 
> t0 = as.POSIXct(as.Date("2013-09-30", tz = "CET"))
> set.seed(13531) # make sure rbind generates identical sequences on reproduction
> 
> # Person A, track 1.
> 
> x = c(7, 6, 5, 5, 4, 3, 3)
> y = c(7, 7, 6, 5, 5, 6, 7)
> n = length(x)
> t = t0 + cumsum(runif(n) * 60)
> crs = CRS("+proj=longlat +ellps=WGS84")
Warning message:
In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
> stidf = STIDF(SpatialPoints(cbind(x, y), crs), t, data.frame(co2 = rnorm(n)))
> A1 = Track(stidf)
> 
> # Person A, track 2.
> 
> x = c(7, 6, 6, 7, 7)
> y = c(6, 5, 4, 4, 3)
> n = length(x)
> t = max(t) + cumsum(runif(n) * 60)
> stidf = STIDF(SpatialPoints(cbind(x, y), crs), t, data.frame(co2 = rnorm(n)))
> A2 = Track(stidf)
> 
> # Tracks for person A.
> 
> A = Tracks(list(A1 = A1, A2 = A2))
Warning messages:
1: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
2: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
> 
> # Person B, track 1.
> 
> x = c(2, 2, 1, 1, 2, 3)
> y = c(5, 4, 3, 2, 2, 3)
> n = length(x)
> t = max(t) + cumsum(runif(n) * 60)
> stidf = STIDF(SpatialPoints(cbind(x, y), crs), t, data.frame(co2 = rnorm(n)))
> B1 = Track(stidf)
> 
> # Person B, track 2.
> 
> x = c(3, 3, 4, 3, 3, 4)
> y = c(5, 4, 3, 2, 1, 1)
> n = length(x)
> t = max(t) + cumsum(runif(n) * 60)
> stidf = STIDF(SpatialPoints(cbind(x, y), crs), t, data.frame(co2 = rnorm(n)))
> B2 = Track(stidf)
> 
> # Tracks for person B.
> 
> B = Tracks(list(B1 = B1, B2 = B2))
Warning messages:
1: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
2: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
> 
> # Tracks collection.
> 
> Tr = TracksCollection(list(A = A, B = B))
Warning messages:
1: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
2: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
> 
> all = list(A1, A2, B1, B2, A, B, Tr)
> 
> # Test methods.
> 
> checkClass = function(list, class) {
+ 	stopifnot(all(sapply(list, function(x) class(x)[1] == class)))
+ }
> 
> checkDim = function(list, dim) {
+ 	for(i in seq_along(list)) {
+ 		element = list[[i]]
+ 		if(class(element)[1] %in% c("data.frame", "xts", "STIDF", "SpatialPointsDataFrame"))
+ 			stopifnot(dim(element)[1] == dim[i])
+ 		else if(class(element)[1] == "Line")
+ 			stopifnot(dim(element@coords)[1] == dim[i])
+ 		else if(class(element)[1] == "Lines")
+ 			# For simplification purposes, the number of Line elements (= number
+ 			# of Tracks) is validated.
+ 			stopifnot(length(element@Lines) == dim[i])
+ 		else if(class(element)[1] %in% c("SpatialLines", "SpatialLinesDataFrame"))
+ 			# For simplification purposes, the sum of the number of Line
+ 			# elements (= total number of Tracks) is validated.
+ 			stopifnot(sum(sapply(element@lines, function(x) length(x@Lines))) == dim[i])
+ 		else
+ 			warning(paste("Validation against dimension of class '", class(element)[1], "' is not yet supported.", sep = ""))	
+ 	}
+ }
> 
> # Check coercion to segments.
> 
> res = lapply(all, function(x) as(x, "segments"))
> checkClass(res, "data.frame")
> dim = c(6, 4, 5, 5, 10, 10, 20)
> checkDim(res, dim)
> 
> # Check coercion to data frame.
> 
> res = lapply(all, function(x) as(x, "data.frame"))
> checkClass(res, "data.frame")
> dim = c(7, 5, 6, 6, 14, 14, 28)
> checkDim(res, dim)
> 
> # Check coercion to Line, Lines, SpatialLines and SpatialLinesDataFrame.
> 
> res = lapply(all[1:4], function(x) as(x, "Line"))
> checkClass(res, "Line")
> dim = c(7, 5, 6, 6)
> checkDim(res, dim)
> 
> res = lapply(all[1:6], function(x) as(x, "Lines"))
> checkClass(res, "Lines")
> dim = c(1, 1, 1, 1, 2, 2)
> checkDim(res, dim)
> 
> res = lapply(all, function(x) as(x, "SpatialLines"))
Warning messages:
1: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
2: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
3: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
4: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
5: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
6: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
7: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
> checkClass(res, "SpatialLines")
> dim = c(1, 1, 1, 1, 2, 2, 4)
> checkDim(res, dim)
> 
> res = lapply(all[5:length(all)], function(x) as(x, "SpatialLinesDataFrame"))
Warning messages:
1: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
2: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
3: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
  Discarded datum Unknown_based_on_WGS84_ellipsoid in CRS definition
> checkClass(res, "SpatialLinesDataFrame")
> dim = c(2, 2, 4)
> checkDim(res, dim)
> 
> # Check coercion to xts.
> 
> res = lapply(all, function(x) as(x, "xts"))
> checkClass(res, "xts")
> dim = c(7, 5, 6, 6, 12, 12, 24)
> checkDim(res, dim)
> 
> # Check coercion to STIDF.
> 
> res = lapply(all, function(x) as(x, "STIDF"))
There were 15 warnings (use warnings() to see them)
> checkClass(res, "STIDF")
> dim = c(7, 5, 6, 6, 12, 12, 24)
> checkDim(res, dim)
> 
> # Check coercion to SpatialPointsDataFrame.
> 
> res = lapply(all, function(x) as(x, "SpatialPointsDataFrame"))
There were 15 warnings (use warnings() to see them)
> checkClass(res, "SpatialPointsDataFrame")
> dim = c(7, 5, 6, 6, 12, 12, 24)
> checkDim(res, dim)
> 
> # Check proj4string methods.
> 
> stopifnot(all(sapply(all, function(x) proj4string(x) == "+proj=longlat +ellps=WGS84")))
Error: all(sapply(all, function(x) proj4string(x) == "+proj=longlat +ellps=WGS84")) is not TRUE
Execution halted

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions