1

All - this is likely an idiotic question, but, I've been working on developing some GIS code in R that interacts with an online source. So, sprinkled in various places, I have

myBrick <- brick("http://somesite.com/image.jpg", crs=proj)

This works well and good. And then...I moved to a PC. And chaos ensued. The issue is that brick() on a PC appends additional text to the filename. So, I get

Error in .local(.Object, ...): `C:\path\to\my\working\director\http://somesite.com/image.jpg` does not exist in the file system

This is.... odd. Same identical code. Entering strings. Never referencing working directory.

What is going on here? What is brick() doing differently? How can I stop the madness?

  • Please provide a reproducible example. – Jeffrey Evans Jul 5 '16 at 19:29
  • Try brick("https://raw.githubusercontent.com/Robinlovelace/Creating-maps-in-R/master/vignettes/clipping-with-bounding-box_files/figure-markdown_github/Westminster.png") – jebyrnes Jul 6 '16 at 14:46
3

This error comes from rgdal, I believe, specifically as it calls normalizePath, which probably should be avoided for filenames starting with http or ftp.

normalizePath("http://somesite.com/image.jpg", mustWork=FALSE)

on windows leads to:

#[1] "E:\\home\\http:\\somesite.com\\image.jpg"

but on linux I see:

#[1] "http://somesite.com/image.jpg"

So on windows you may need to do something like:

url <- "http://somesite.com/image.jpg"
download.file(url, basename(url))
b <- brick( basename(url) )
  • This sounds like the problem...now to figure out a fix... – jebyrnes Jul 6 '16 at 14:45
  • just added one option – Robert Hijmans Jul 6 '16 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.