Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
use zipfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Feb 14, 2019
1 parent 8c81dc9 commit e8c6010
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ DataFrames
RDatasets
BinaryProvider
StatsMakie
ZipFile
16 changes: 12 additions & 4 deletions examples/bigdata.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@cell "WorldClim visualization" [visualization, dataset, bigdata] begin
# fixes for GDAL messing with LD library path and therefore using wrong curl
# for downloads
using FileIO, GeometryTypes, Colors, GDAL, BinaryProvider
using FileIO, GeometryTypes, Colors, GDAL, ZipFile
env = ENV["LD_LIBRARY_PATH"]
#=
This example requires the GDAL package, from https://github.com/JuliaGeo/GDAL.jl
Expand All @@ -16,9 +16,17 @@


# set up 7zip
exe7z = BinaryProvider.gen_unpack_cmd("bla.zip", "dest").a[1]

unzip(in, out) = run(`$exe7z x -y $in -o$out`)
function unzip(input, out)
dir = ZipFile.Reader(input)
mkpath(out)
for file in dir.files
open(joinpath(out, file.name), "w") do io
Base.write(io, read(file))
end
end
close(dir)
end

# function to read the raster data from the GeoTIFF
function loadf0(x)
Expand Down Expand Up @@ -48,14 +56,14 @@
download("http://biogeo.ucdavis.edu/data/worldclim/v2.0/tif/base/wc2.0_10m_$name.zip", "$name.zip")
end
if !isdir(name)
#BinaryProvider.unpack("$name.zip", name) doesn't work -.-
unzip("$name.zip", name)
end
ENV["LD_LIBRARY_PATH"] = env
loadf0.(filter(istiff, joinpath.(name, readdir(name))))
end

# load the actual datasets!

water = load_dataset("prec")
temperature = load_dataset("tmax")

Expand Down
1 change: 1 addition & 0 deletions test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Makie
GLMakie
ZipFile

0 comments on commit e8c6010

Please sign in to comment.