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

optimize compressed storage of downloaded data into GTIFF #1

Open
ivanhanigan opened this issue Apr 26, 2016 · 5 comments
Open

optimize compressed storage of downloaded data into GTIFF #1

ivanhanigan opened this issue Apr 26, 2016 · 5 comments

Comments

@ivanhanigan
Copy link
Member

from @ahsparks

writeRaster(raster, file = "out location", format = "GTiff", dataType = "INT2S",

options = c("COMPRESS=LZW"))

to save space with GTiffs. Check all the options with dataType to see what works best. http://artax.karlin.mff.cuni.cz/r-help/library/raster/html/dataType.html

@ivanhanigan
Copy link
Member Author

@ahsparks
I added your code as function compress_gtifs to the develop branch, and added you as author to package.

Started demo of the workflow in development
https://github.com/swish-climate-impact-assessment/awaptools/blob/develop/README.md

Cheers!

@adamhsparks
Copy link
Member

I completely missed this, @ivanhanigan.

Thanks! 👍

@ivanhanigan
Copy link
Member Author

ivanhanigan commented Aug 28, 2016

@adamhsparks I wonder what you think about

  1. not creating Gtifs subdir
  2. removing the .grid file after

Today this was what I wanted to do so I hacked the following, my thought though is it is better to make your compress_gtifs function do the unzip, compress and clean up.
swish-climate-impact-assessment/AWAP_GRIDS@6411403

require(devtools)
install_github("swish-climate-impact-assessment/awaptools", ref = "develop")
require(awaptools)
require(rgdal)
workdir <- "data"
setwd(workdir)
startdate <- "2014-01-01"
enddate <- "2014-02-28"
load_monthly(start_date = startdate, end_date = enddate)
filelist <- dir(pattern = "grid.Z$")
for(fname in filelist){unzip_monthly(fname, aggregation_factor = 1)}
compress_gtifs(indir = getwd())
system("rm *.grid")
system("mv GTif/* ./")

@adamhsparks
Copy link
Member

adamhsparks commented Aug 28, 2016

@ivanhanigan is there any reason to add the extra step to generate the GTiff files rather than just going straight to that step during the download? You're not giving the user an option to keep the .grid file if the first step only downloads and the second step/function does the unzipping and writes the GTiff file onto disk.

If you do that we could download the .Z files to a tempdirectory , ?tempdir, unzip them in that tempdirectory, import them using the raster package and then write a GTiff file out to disk. Once the session is done, the .grid.Z and .grid file disappear, no need to unlink them.

@ivanhanigan
Copy link
Member Author

@adamhsparks Thanks, yes - no need to keep grid file so I'll try to
implement tempdir as you suggest. Cheers.
On 28/08/2016 6:34 PM, "Adam H. Sparks" [email protected] wrote:

@ivanhanigan https://github.com/ivanhanigan is there any reason to keep
the .grid files around and add the extra step to generate the GTiff files
rather than just going straight to that step during the download? You're
not giving the user an option to keep the .grid file if the first step only
downloads and the second step/function does the unzipping and writes the
GTiff file onto disk.

If you do that we could download the .Z files to a tempdirectory ,
?tempdir, unzip them in that tempdirectory, import them using the raster
package and then write a GTiff file out to disk. Once the session is done,
the .grid.Z and .grid file disappear, no need to unlink them.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABPsp6dqOFXQC7Idk4rlhawEbqna8vvUks5qkUgvgaJpZM4IP5Vu
.

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

No branches or pull requests

2 participants