[R-sig-Geo] Reading jpeg and tiff
Roger Bivand
Roger.Bivand at nhh.no
Fri Apr 27 12:31:46 CEST 2007
On Fri, 27 Apr 2007, ONKELINX, Thierry wrote:
> Dear useRs,
>
> I'm trying to read jpeg and GeoTiff with readGDAL() (rgdal package). The
> jpeg is about 5.6 MB in size, has 3063 rows and 4870 columns and has 3
> bands. The tiff is 3.7 MB, has 15750 rows and 12600 colums and 1 band. I
> can't import neither of them in R due to a lack of memory. Although I've
> set the memory limit to the max (memory.limit(size =
> round(memory.limit()/1048576.0, 2))). I'm running R 2.4.1 on a Win Xp
> machine with 2 GB RAM.
>
> So far I managed to read in the data but a lower resolution, which I
> don't want. Any suggestions on a more efficient way to import these
> files. Solutions based on Spatial-classes are prefered.
>
> Here is the code I'm using now.
>
> library(rgdal)
> memory.limit(size = round(memory.limit()/1048576.0, 2))
> info <- GDALinfo("d://ferraris0894.jpg")
> readGDAL("d://ferraris0894.jpg", output.dim = round(c(info[["rows"]],
> info[["columns"]]) / 2))
>
The usual way to handle things is in tiles, using GDALopen() and then
accessing subsets in turn from the handle. The same can be done with
readGDAL(). Remember that tiffs and jpegs are highly compressed, your tiff
will be 800MB for integer or 1.6GB for double mode, while the underlying
data are almost certainly 0-255 byte values. If you would like to look,
the code in gdal-bindings.cpp pre-dates R's raw classes, but since raw
doesn't really have operators, you'd end up casting at least to integer.
The real question is what you want to do with the data, and whether you
can tile it or adapt the flow of analysis.
Roger
>
> sessionInfo()
> R version 2.4.1 (2006-12-18)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=Dutch_Belgium.1252;LC_CTYPE=Dutch_Belgium.1252;LC_MONETARY=Du
> tch_Belgium.1252;LC_NUMERIC=C;LC_TIME=Dutch_Belgium.1252
>
> attached base packages:
> [1] "stats" "graphics" "grDevices" "utils" "datasets" "tcltk"
>
> [7] "methods" "base"
>
> other attached packages:
> rgdal sp svIO R2HTML svMisc svSocket svIDE
> "0.5-8" "0.9-13" "0.9-5" "1.58" "0.9-5" "0.9-5" "0.9-5"
>
>
> Thanks,
>
> Thierry
>
> ------------------------------------------------------------------------
> ----
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature
> and Forest
> Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
> methodology and quality assurance
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
> tel. + 32 54/436 185
> Thierry.Onkelinx at inbo.be
> www.inbo.be
>
> Do not put your faith in what statistics say until you have carefully
> considered what they do not say. ~William W. Watt
> A statistical analysis, properly conducted, is a delicate dissection of
> uncertainties, a surgery of suppositions. ~M.J.Moroney
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list