I am trying to download and gunzip
grid files in ascii
format, compressed to .gz
files from an URL like this. I tried to get to the files via y <- gzon(url("name-of-url")
and then gunzip(y)
, but for gunzip
that is an invalid file. If I can decompress the file, I would like to read the .asc
file with raster()
Any ideas how to solve this?
CodePudding user response:
I don't know why unzip does not work on these files, but you can get at the contents as follows:
URL = "https://opendata.dwd.de/climate_environment/CDC/grids_germany/annual/summer_days/grids_germany_annual_summer_days_1951_17.asc.gz"
download.file(URL, "grids_germany_annual_summer_days_1951_17.asc.gz")
GZ = gzfile("grids_germany_annual_summer_days_1951_17.asc.gz")
Lines = readLines(GZ, 10)
writeLines(Lines, "grids_germany_annual_summer_days_1951_17.asc")
Now you have an ascii text file.