Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read directly from tar archive in pre-processing functions #55

Open
loicdtx opened this issue Jul 22, 2015 · 8 comments
Open

Read directly from tar archive in pre-processing functions #55

loicdtx opened this issue Jul 22, 2015 · 8 comments
Assignees

Comments

@loicdtx
Copy link
Owner

loicdtx commented Jul 22, 2015

library(rgdal)
library(raster)
raster('/vsitar//full/path/to/archive.tar.gz/bandName.tif')

Works on linux, don't know about windows

@loicdtx loicdtx self-assigned this Jul 22, 2015
@loicdtx
Copy link
Owner Author

loicdtx commented Dec 6, 2015

@bendv @johanez , can you check whether this works on Windows & Macs

library(bfastSpatial)
tarPath <- list.files(system.file('external', package='bfastSpatial'), full.names = TRUE)[1]
raster(sprintf('/vsizip/%s/%s', tarPath, 'LE70230282011250EDC00_sr_band1.tif'))

Thanks

@bendv
Copy link
Collaborator

bendv commented Dec 6, 2015

This doesn't work on Windows. It reads the string in literally and returns a not recognised as a supported file format error. I can't check on my Mac, because I left it back in Canada, but perhaps @verbe039 could give it a try?

@loicdtx
Copy link
Owner Author

loicdtx commented Dec 6, 2015

Okay, I was sort of expecting that... What does the string look like? Could you try replacing the forward slashes of tarPath by double backslashes?

@bendv
Copy link
Collaborator

bendv commented Dec 7, 2015

It appends C:\vsizip to the full path of the filename, so in my case it looks something like C:\vsizip\D:\...\bfastSpatial\external\LE70230282011250EDC00_sub.zip\LE70230282011250EDC00_sr_band1.tif. So the problem is not with the slashes, because they are automatically replaced.

@loicdtx
Copy link
Owner Author

loicdtx commented Dec 7, 2015

I see. Then you probably have to escape the two first slashes, surrounding vsizip. \/vsizip\/ or something like that should work.

@janverbesselt
Copy link
Collaborator

on mac it does not complain (no error) but the string/path does not make sense:

> tarPath <- list.files(system.file('external', package='bfastSpatial'), full.names = TRUE)[1]
> raster(sprintf('/vsizip/%s/%s', tarPath, 'LE70230282011250EDC00_sr_band1.tif'))
class       : RasterLayer 
dimensions  : 243, 258, 62694  (nrow, ncol, ncell)
resolution  : 30, 30  (x, y)
extent      : 498765, 506505, 5081145, 5088435  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=16 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
data source : /vsizip//Users/verbe039/Library/R/3.2/library/bfastSpatial/external/LE70230282011250EDC00_sub.zip/LE70230282011250EDC00_sr_band1.tif 
names       : LE70230282011250EDC00_sr_band1 

What is your objective with : ?

> sprintf('/vsizip/%s/%s', tarPath, 'LE70230282011250EDC00_sr_band1.tif')
[1] "/vsizip//Users/verbe039/Library/R/3.2/library/bfastSpatial/external/LE70230282011250EDC00_sub.zip/LE70230282011250EDC00_sr_band1.tif"

@bendv
Copy link
Collaborator

bendv commented Dec 7, 2015

You can read in directly as a virtual file system. See https://trac.osgeo.org/gdal/wiki/UserDocs/ReadInZip

But it's not clear to me yet how this works in windows.

@loicdtx
Copy link
Owner Author

loicdtx commented Dec 7, 2015

Did you try this Ben?

library(bfastSpatial)
tarPath <- list.files(system.file('external', package='bfastSpatial'), full.names = TRUE)[1]
raster(sprintf('\/vsizip\/%s/%s', tarPath, 'LE70230282011250EDC00_sr_band1.tif'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants