On Tue, 29 Jul 2008, Guy Serbin wrote:
My machine currently has 4 GB on it, but a lot of that's getting eaten
by video memory and the other programs I have in memory. Also, some
of my image cubes are 12 GB in size, so I'd need to find a workaround
anyways. However, since what my colleagues and I are interested in
are pixel-by-pixel spectral analyses, I assume the best approach would
be to pass the spectra either from ENVI/IDL (for which there is no
frontend, but I have logged a request with ITT Visual Solutions to
develop one) or conversely from ArcGIS (which can read ENVI data with
the ENVI Reader) into R for analysis.
Are you aware of ways to send arrays back and forth between R and ArcGIS?
You can use R as a back-end compute engine through (D)COM, see:
http://cran.r-project.org/contrib/extra/dcom/
and note the scripting sample for Python. Regular (D)COM does arrays easily
in VBA, going through usually Python means an extra copy, but may be more
convenient. One needs to watch error trapping and what the different systems
do with Inf, NaN, and NA values. I usually start from Python in front, and
both Arc and R via (D)COM, but the Duke University MGET site has lots of
code examples for interfacing R and Arc in different configurations:
http://code.env.duke.edu/projects/mget
MGET is under active development.
Roger
Guy
On Tue, Jul 29, 2008 at 4:24 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
On Tue, 29 Jul 2008, Guy Serbin wrote:
Thank you all for the help- I successfully read an image into R using
these methods.
I did, however, encounter some problems when loading a hyperspectral
image cube into R as it was unable to allocate the 2.9 GB of volatile
memory that it needed.
Buy more memory, 64-bit Linux works fine. Seriously, R is for statistics,
so
its memory management is designed for samples, even though very large
samples can be handled when used appropriately. If your data are in a
GeoTiff, you can read them by band using functions in the rgdal package,
or
equally well many bands in a window or tile of a larger scene. Note that
ArcGIS uses GDAL too for handling some raster formats. Using R does mean
thinking through your work flow.
Roger
Is there a way to improve memory management by R, so that it only
reads in the data when actually needed for processing, e.g., only read
in the bands I need, or conversely read in spectra on a per-pixel
basis?
Guy
On Tue, Jul 29, 2008 at 4:05 PM, PUJAN RAJ REGMI
<regmi_pujan at hotmail.com> wrote:
This might help to mange the orientation of image:
# To read ENVI format
cir.image<-("YOUR_ENVI_FILE")
CIR.envi<-read.ENVI(cir.image,headerfile=paste(cir.image,".hdr",sep=""))
# To Show image
CIR.envi.band1<-CIR.envi[,,1]
CIR.envi.band1.s<-CIR.envi.band1[order(nrow(CIR.envi.band1):1),]
CIR.envi.band1.t<-t(CIR.envi.band1.s)
image(CIR.envi.band1.t,main="")
mtext("Raw Matrix ENVI Image for Band1", side=3,line=2,
font=3,cex=1.25)
Pujan