1

I'm using the CRAN version of slideview but the minimal example (below) only returns blank output on my machine. I've verified that img2000 and img2013 both plot, they just don't work within slideView().

### example taken from
### http://www.news.com.au/technology/environment/nasa-images-reveal-
### aral-sea-is-shrinking-before-our-eyes/story-e6frflp0-1227074133835
library(jpeg)
library(raster)
library(slideview)

# 2000
web_img2000 <- "http://cdn.newsapi.com.au/image/v1/68565a36c0fccb1bc43c09d96e8fb029"
jpg2000 <- readJPEG(readBin(web_img2000, "raw", 1e6))

# Convert imagedata to raster
rst_blue2000 <- raster(jpg2000[, , 1])
rst_green2000 <- raster(jpg2000[, , 2])
rst_red2000 <- raster(jpg2000[, , 3])

img2000 <- brick(rst_red2000, rst_green2000, rst_blue2000)

# 2013
web_img2013 <- "http://cdn.newsapi.com.au/image/v1/5707499d769db4b8ec76e8df61933f2a"
jpg2013 <- readJPEG(readBin(web_img2013, "raw", 1e6))

# Convert imagedata to raster
rst_blue2013 <- raster(jpg2013[, , 1])
rst_green2013 <- raster(jpg2013[, , 2])
rst_red2013 <- raster(jpg2013[, , 3])

img2013 <- brick(rst_red2013, rst_green2013, rst_blue2013)

slideView(img2000, img2013, label1 = "before", label2 = "after")
Rich Pauloo
  • 7,734
  • 4
  • 37
  • 69

1 Answers1

1

This function used to belong to the package mapview. The authors left some of the dependent files in mapview in the coding.

I have a fix, though. To see if I was on the right track I forked the repo in Github and made my changes there, installed the package from my repo, and wallah! It works.

In Github, I copied the missing CSS file over from mapview and changed the dependencies to slideview. You could bring these files into your library manually or install the package from my repo.

devtools::install_github('fraupflaume/slideview')

By the way, you can call the function with slideview() or slideView(). Both work the same way. (That's from the original package, not me!)

enter image description here

If you want to see what's missing in the CRAN version, you can get to the directory with system.file(package = "slideview"). Within the slideview library folders, there's a folder called htmlwidgets. The YAML file in that folder points to the CSS file. (You'll notice it calls for a file that doesn't exist.)

To see the dependencies on mapview, use htmlwidgets::get_dependency("slideview", "slideview").

Kat
  • 15,669
  • 3
  • 18
  • 51
  • I've heard back from tim-salabim, who manages (wrote?) the `slideview` package. The changes have been made in Github. I would imagine there will be an update soon (if not already) for the R package. Installing it directly from the main repositories in Github will probably work right now. – Kat Apr 13 '22 at 18:36