ENVI data and R

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

ENVI data and R

Guy Serbin
Hi,

I was wondering if anyone knows how to either call up R functions from
within IDL, or conversely read ENVI image data into R.  If you have
any advice I'd greatly appreciate it.

Thanks,
Guy Serbin

--
Guy Serbin, Ph.D.
Research Soil Scientist
Hydrology and Remote Sensing Lab
Bldg 007 Rm 104 BARC-West
10300 Baltimore Blvd
Beltsville, MD 20705-2350 USA
+1(301)504-5250 guy.serbin at gmail.com



Reply | Threaded
Open this post in threaded view
|

ENVI data and R

Thomas Adams
Guy,

I don't know the answer to your question. However, depending on what you
are trying to do, might it be possible to use GRASS GIS in place of what
you are doing with IDL in ENVI? GRASS plays quite nicely with R. You
probably can read ENVI image data into R, but you may need to go through
a file conversion process to do it.

Regards,
Tom

Guy Serbin wrote:

> Hi,
>
> I was wondering if anyone knows how to either call up R functions from
> within IDL, or conversely read ENVI image data into R.  If you have
> any advice I'd greatly appreciate it.
>
> Thanks,
> Guy Serbin
>
>  


--
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL: thomas.adams at noaa.gov

VOICE: 937-383-0528
FAX: 937-383-0033



Reply | Threaded
Open this post in threaded view
|

ENVI data and R

Andrew Niccolai
In reply to this post by Guy Serbin
This code might help:

############################################################################
####
############################################################################
####
## Read in envi file
cir.image <- "C:/YOUR_ENVI_FILE"
CIR.envi = read.ENVI(cir.image, headerfile=paste(cir.image,".hdr", sep=""))

############################################################################
####
############################################################################
####
## Show image
CIR.envi.band1 <- CIR.envi[,,1]
image(CIR.envi.band1, main="")
mtext("Raw Matrix ENVI Image for Band 1", side=3,line = 2, font=3, cex=1.25)

############################################################################
####
############################################################################
####

Andrew Niccolai
Doctoral Candidate
Yale School of Forestry


 
-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Guy Serbin
Sent: Tuesday, July 29, 2008 12:55 PM
To: R-sig-Geo at stat.math.ethz.ch
Subject: [R-sig-Geo] ENVI data and R

Hi,

I was wondering if anyone knows how to either call up R functions from
within IDL, or conversely read ENVI image data into R.  If you have
any advice I'd greatly appreciate it.

Thanks,
Guy Serbin

--
Guy Serbin, Ph.D.
Research Soil Scientist
Hydrology and Remote Sensing Lab
Bldg 007 Rm 104 BARC-West
10300 Baltimore Blvd
Beltsville, MD 20705-2350 USA
+1(301)504-5250 guy.serbin at gmail.com

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo



Reply | Threaded
Open this post in threaded view
|

ENVI data and R

PUJAN RAJ REGMI
An embedded and charset-unspecified text was scrubbed...
Name: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20080729/f1f6b4e0/attachment.pl>

Reply | Threaded
Open this post in threaded view
|

ENVI data and R

Guy Serbin
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.

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
> ________________________________
>> From: andrew.niccolai at yale.edu
>> To: guy.serbin at gmail.com; R-sig-Geo at stat.math.ethz.ch
>> Date: Tue, 29 Jul 2008 14:24:04 -0400
>> Subject: Re: [R-sig-Geo] ENVI data and R
>>
>> This code might help:
>>
>>
>> ############################################################################
>> ####
>>
>> ############################################################################
>> ####
>> ## Read in envi file
>> cir.image <- "C:/YOUR_ENVI_FILE"
>> CIR.envi = read.ENVI(cir.image, headerfile=paste(cir.image,".hdr",
>> sep=""))
>>
>>
>> ############################################################################
>> ####
>>
>> ############################################################################
>> ####
>> ## Show image
>> CIR.envi.band1 <- CIR.envi[,,1]
>> image(CIR.envi.band1, main="")
>> mtext("Raw Matrix ENVI Image for Band 1", side=3,line = 2, font=3,
>> cex=1.25)
>>
>>
>> ############################################################################
>> ####
>>
>> ############################################################################
>> ####
>>
>> Andrew Niccolai
>> Doctoral Candidate
>> Yale School of Forestry
>>
>>
>>
>> -----Original Message-----
>> From: r-sig-geo-bounces at stat.math.ethz.ch
>> [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Guy Serbin
>> Sent: Tuesday, July 29, 2008 12:55 PM
>> To: R-sig-Geo at stat.math.ethz.ch
>> Subject: [R-sig-Geo] ENVI data and R
>>
>> Hi,
>>
>> I was wondering if anyone knows how to either call up R functions from
>> within IDL, or conversely read ENVI image data into R. If you have
>> any advice I'd greatly appreciate it.
>>
>> Thanks,
>> Guy Serbin
>>
>> --
>> Guy Serbin, Ph.D.
>> Research Soil Scientist
>> Hydrology and Remote Sensing Lab
>> Bldg 007 Rm 104 BARC-West
>> 10300 Baltimore Blvd
>> Beltsville, MD 20705-2350 USA
>> +1(301)504-5250 guy.serbin at gmail.com
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> ________________________________
> Stay in touch when you're away with Windows Live Messenger. IM anytime
> you're online.



--
Guy Serbin, Ph.D.
Research Soil Scientist
Hydrology and Remote Sensing Lab
Bldg 007 Rm 104 BARC-West
10300 Baltimore Blvd
Beltsville, MD 20705-2350 USA
+1(301)504-5250 guy.serbin at gmail.com



Reply | Threaded
Open this post in threaded view
|

ENVI data and R

Roger Bivand
Administrator
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
>> ________________________________
>>> From: andrew.niccolai at yale.edu
>>> To: guy.serbin at gmail.com; R-sig-Geo at stat.math.ethz.ch
>>> Date: Tue, 29 Jul 2008 14:24:04 -0400
>>> Subject: Re: [R-sig-Geo] ENVI data and R
>>>
>>> This code might help:
>>>
>>>
>>> ############################################################################
>>> ####
>>>
>>> ############################################################################
>>> ####
>>> ## Read in envi file
>>> cir.image <- "C:/YOUR_ENVI_FILE"
>>> CIR.envi = read.ENVI(cir.image, headerfile=paste(cir.image,".hdr",
>>> sep=""))
>>>
>>>
>>> ############################################################################
>>> ####
>>>
>>> ############################################################################
>>> ####
>>> ## Show image
>>> CIR.envi.band1 <- CIR.envi[,,1]
>>> image(CIR.envi.band1, main="")
>>> mtext("Raw Matrix ENVI Image for Band 1", side=3,line = 2, font=3,
>>> cex=1.25)
>>>
>>>
>>> ############################################################################
>>> ####
>>>
>>> ############################################################################
>>> ####
>>>
>>> Andrew Niccolai
>>> Doctoral Candidate
>>> Yale School of Forestry
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: r-sig-geo-bounces at stat.math.ethz.ch
>>> [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Guy Serbin
>>> Sent: Tuesday, July 29, 2008 12:55 PM
>>> To: R-sig-Geo at stat.math.ethz.ch
>>> Subject: [R-sig-Geo] ENVI data and R
>>>
>>> Hi,
>>>
>>> I was wondering if anyone knows how to either call up R functions from
>>> within IDL, or conversely read ENVI image data into R. If you have
>>> any advice I'd greatly appreciate it.
>>>
>>> Thanks,
>>> Guy Serbin
>>>
>>> --
>>> Guy Serbin, Ph.D.
>>> Research Soil Scientist
>>> Hydrology and Remote Sensing Lab
>>> Bldg 007 Rm 104 BARC-West
>>> 10300 Baltimore Blvd
>>> Beltsville, MD 20705-2350 USA
>>> +1(301)504-5250 guy.serbin at gmail.com
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at stat.math.ethz.ch
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at stat.math.ethz.ch
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>> ________________________________
>> Stay in touch when you're away with Windows Live Messenger. IM anytime
>> you're online.
>
>
>
>

--
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



Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

ENVI data and R

Guy Serbin
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?

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
>>> ________________________________
>>>>
>>>> From: andrew.niccolai at yale.edu
>>>> To: guy.serbin at gmail.com; R-sig-Geo at stat.math.ethz.ch
>>>> Date: Tue, 29 Jul 2008 14:24:04 -0400
>>>> Subject: Re: [R-sig-Geo] ENVI data and R
>>>>
>>>> This code might help:
>>>>
>>>>
>>>>
>>>> ############################################################################
>>>> ####
>>>>
>>>>
>>>> ############################################################################
>>>> ####
>>>> ## Read in envi file
>>>> cir.image <- "C:/YOUR_ENVI_FILE"
>>>> CIR.envi = read.ENVI(cir.image, headerfile=paste(cir.image,".hdr",
>>>> sep=""))
>>>>
>>>>
>>>>
>>>> ############################################################################
>>>> ####
>>>>
>>>>
>>>> ############################################################################
>>>> ####
>>>> ## Show image
>>>> CIR.envi.band1 <- CIR.envi[,,1]
>>>> image(CIR.envi.band1, main="")
>>>> mtext("Raw Matrix ENVI Image for Band 1", side=3,line = 2, font=3,
>>>> cex=1.25)
>>>>
>>>>
>>>>
>>>> ############################################################################
>>>> ####
>>>>
>>>>
>>>> ############################################################################
>>>> ####
>>>>
>>>> Andrew Niccolai
>>>> Doctoral Candidate
>>>> Yale School of Forestry
>>>>
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: r-sig-geo-bounces at stat.math.ethz.ch
>>>> [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Guy Serbin
>>>> Sent: Tuesday, July 29, 2008 12:55 PM
>>>> To: R-sig-Geo at stat.math.ethz.ch
>>>> Subject: [R-sig-Geo] ENVI data and R
>>>>
>>>> Hi,
>>>>
>>>> I was wondering if anyone knows how to either call up R functions from
>>>> within IDL, or conversely read ENVI image data into R. If you have
>>>> any advice I'd greatly appreciate it.
>>>>
>>>> Thanks,
>>>> Guy Serbin
>>>>
>>>> --
>>>> Guy Serbin, Ph.D.
>>>> Research Soil Scientist
>>>> Hydrology and Remote Sensing Lab
>>>> Bldg 007 Rm 104 BARC-West
>>>> 10300 Baltimore Blvd
>>>> Beltsville, MD 20705-2350 USA
>>>> +1(301)504-5250 guy.serbin at gmail.com
>>>>
>>>> _______________________________________________
>>>> R-sig-Geo mailing list
>>>> R-sig-Geo at stat.math.ethz.ch
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>>
>>>> _______________________________________________
>>>> R-sig-Geo mailing list
>>>> R-sig-Geo at stat.math.ethz.ch
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>> ________________________________
>>> Stay in touch when you're away with Windows Live Messenger. IM anytime
>>> you're online.
>>
>>
>>
>>
>
> --
> 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
>
>



--
Guy Serbin, Ph.D.
Research Soil Scientist
Hydrology and Remote Sensing Lab
Bldg 007 Rm 104 BARC-West
10300 Baltimore Blvd
Beltsville, MD 20705-2350 USA
+1(301)504-5250 guy.serbin at gmail.com



Reply | Threaded
Open this post in threaded view
|

ENVI data and R

Matt Oliver
An embedded and charset-unspecified text was scrubbed...
Name: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20080729/5057d816/attachment.pl>

Reply | Threaded
Open this post in threaded view
|

ENVI data and R

Matt Oliver
In reply to this post by Guy Serbin
An embedded and charset-unspecified text was scrubbed...
Name: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20080729/0756b205/attachment.pl>

Reply | Threaded
Open this post in threaded view
|

ENVI data and R

alobo
In reply to this post by Guy Serbin
R is not intended for the analysis of large hyperspectral images.
If you are interested on spectra of selected pixels, just
import the envi spectra, I recall they are stored as if
they were envi images: a raw file + a text header file in which
you have all the info you need to import into R provided you have an
elementary knowledge of R.

In general, the approach is using RS and/or GIS software to
select from the images the information that you really have to process
in R, which is,
as stated by Roger, a tool for statistics.

Agus

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?
>
> 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
>>>> ________________________________
>>>>> From: andrew.niccolai at yale.edu
>>>>> To: guy.serbin at gmail.com; R-sig-Geo at stat.math.ethz.ch
>>>>> Date: Tue, 29 Jul 2008 14:24:04 -0400
>>>>> Subject: Re: [R-sig-Geo] ENVI data and R
>>>>>
>>>>> This code might help:
>>>>>
>>>>>
>>>>>
>>>>> ############################################################################
>>>>> ####
>>>>>
>>>>>
>>>>> ############################################################################
>>>>> ####
>>>>> ## Read in envi file
>>>>> cir.image <- "C:/YOUR_ENVI_FILE"
>>>>> CIR.envi = read.ENVI(cir.image, headerfile=paste(cir.image,".hdr",
>>>>> sep=""))
>>>>>
>>>>>
>>>>>
>>>>> ############################################################################
>>>>> ####
>>>>>
>>>>>
>>>>> ############################################################################
>>>>> ####
>>>>> ## Show image
>>>>> CIR.envi.band1 <- CIR.envi[,,1]
>>>>> image(CIR.envi.band1, main="")
>>>>> mtext("Raw Matrix ENVI Image for Band 1", side=3,line = 2, font=3,
>>>>> cex=1.25)
>>>>>
>>>>>
>>>>>
>>>>> ############################################################################
>>>>> ####
>>>>>
>>>>>
>>>>> ############################################################################
>>>>> ####
>>>>>
>>>>> Andrew Niccolai
>>>>> Doctoral Candidate
>>>>> Yale School of Forestry
>>>>>
>>>>>
>>>>>
>>>>> -----Original Message-----
>>>>> From: r-sig-geo-bounces at stat.math.ethz.ch
>>>>> [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Guy Serbin
>>>>> Sent: Tuesday, July 29, 2008 12:55 PM
>>>>> To: R-sig-Geo at stat.math.ethz.ch
>>>>> Subject: [R-sig-Geo] ENVI data and R
>>>>>
>>>>> Hi,
>>>>>
>>>>> I was wondering if anyone knows how to either call up R functions from
>>>>> within IDL, or conversely read ENVI image data into R. If you have
>>>>> any advice I'd greatly appreciate it.
>>>>>
>>>>> Thanks,
>>>>> Guy Serbin
>>>>>
>>>>> --
>>>>> Guy Serbin, Ph.D.
>>>>> Research Soil Scientist
>>>>> Hydrology and Remote Sensing Lab
>>>>> Bldg 007 Rm 104 BARC-West
>>>>> 10300 Baltimore Blvd
>>>>> Beltsville, MD 20705-2350 USA
>>>>> +1(301)504-5250 guy.serbin at gmail.com
>>>>>
>>>>> _______________________________________________
>>>>> R-sig-Geo mailing list
>>>>> R-sig-Geo at stat.math.ethz.ch
>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>>>
>>>>> _______________________________________________
>>>>> R-sig-Geo mailing list
>>>>> R-sig-Geo at stat.math.ethz.ch
>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>> ________________________________
>>>> Stay in touch when you're away with Windows Live Messenger. IM anytime
>>>> you're online.
>>>
>>>
>>>
>> --
>> 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
>>
>>
>
>
>

--
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es
http://www.ija.csic.es/gt/obster



Reply | Threaded
Open this post in threaded view
|

ENVI data and R

Roger Bivand
Administrator
In reply to this post by Guy Serbin
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
>>>> ________________________________
>>>>>
>>>>> From: andrew.niccolai at yale.edu
>>>>> To: guy.serbin at gmail.com; R-sig-Geo at stat.math.ethz.ch
>>>>> Date: Tue, 29 Jul 2008 14:24:04 -0400
>>>>> Subject: Re: [R-sig-Geo] ENVI data and R
>>>>>
>>>>> This code might help:
>>>>>
>>>>>
>>>>>
>>>>> ############################################################################
>>>>> ####
>>>>>
>>>>>
>>>>> ############################################################################
>>>>> ####
>>>>> ## Read in envi file
>>>>> cir.image <- "C:/YOUR_ENVI_FILE"
>>>>> CIR.envi = read.ENVI(cir.image, headerfile=paste(cir.image,".hdr",
>>>>> sep=""))
>>>>>
>>>>>
>>>>>
>>>>> ############################################################################
>>>>> ####
>>>>>
>>>>>
>>>>> ############################################################################
>>>>> ####
>>>>> ## Show image
>>>>> CIR.envi.band1 <- CIR.envi[,,1]
>>>>> image(CIR.envi.band1, main="")
>>>>> mtext("Raw Matrix ENVI Image for Band 1", side=3,line = 2, font=3,
>>>>> cex=1.25)
>>>>>
>>>>>
>>>>>
>>>>> ############################################################################
>>>>> ####
>>>>>
>>>>>
>>>>> ############################################################################
>>>>> ####
>>>>>
>>>>> Andrew Niccolai
>>>>> Doctoral Candidate
>>>>> Yale School of Forestry
>>>>>
>>>>>
>>>>>
>>>>> -----Original Message-----
>>>>> From: r-sig-geo-bounces at stat.math.ethz.ch
>>>>> [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Guy Serbin
>>>>> Sent: Tuesday, July 29, 2008 12:55 PM
>>>>> To: R-sig-Geo at stat.math.ethz.ch
>>>>> Subject: [R-sig-Geo] ENVI data and R
>>>>>
>>>>> Hi,
>>>>>
>>>>> I was wondering if anyone knows how to either call up R functions from
>>>>> within IDL, or conversely read ENVI image data into R. If you have
>>>>> any advice I'd greatly appreciate it.
>>>>>
>>>>> Thanks,
>>>>> Guy Serbin
>>>>>
>>>>> --
>>>>> Guy Serbin, Ph.D.
>>>>> Research Soil Scientist
>>>>> Hydrology and Remote Sensing Lab
>>>>> Bldg 007 Rm 104 BARC-West
>>>>> 10300 Baltimore Blvd
>>>>> Beltsville, MD 20705-2350 USA
>>>>> +1(301)504-5250 guy.serbin at gmail.com
>>>>>
>>>>> _______________________________________________
>>>>> R-sig-Geo mailing list
>>>>> R-sig-Geo at stat.math.ethz.ch
>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>>>
>>>>> _______________________________________________
>>>>> R-sig-Geo mailing list
>>>>> R-sig-Geo at stat.math.ethz.ch
>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>>
>>>> ________________________________
>>>> Stay in touch when you're away with Windows Live Messenger. IM anytime
>>>> you're online.
>>>
>>>
>>>
>>>
>>
>> --
>> 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
>>
>>
>
>
>
>

--
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



Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

ENVI data and R

Guy Serbin
Thank you for the information- I'll try that approach out.  The new
version of ENVI (4.5) is optimized to work with ArcGIS, so there may
be a way to pass spectra from ENVI to ArcGIS and then on to R if I
can't set up a direct ENVI/IDL to R connection.

I agree with you that R isn't for image processing (I certainly
enjoyed the two-three minute wait I had to endure to show a single
band ENVI image in R, something which would have been rendered
instantly in ENVI)- what we're interested in is using R for
statistical capabilities currently not available in either ENVI or
IDL.

Thanks for all your help,
Guy

On Wed, Jul 30, 2008 at 4:49 AM, Roger Bivand <Roger.Bivand at nhh.no> wrote:

> 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
>>>>> ________________________________
>>>>>>
>>>>>> From: andrew.niccolai at yale.edu
>>>>>> To: guy.serbin at gmail.com; R-sig-Geo at stat.math.ethz.ch
>>>>>> Date: Tue, 29 Jul 2008 14:24:04 -0400
>>>>>> Subject: Re: [R-sig-Geo] ENVI data and R
>>>>>>
>>>>>> This code might help:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ############################################################################
>>>>>> ####
>>>>>>
>>>>>>
>>>>>>
>>>>>> ############################################################################
>>>>>> ####
>>>>>> ## Read in envi file
>>>>>> cir.image <- "C:/YOUR_ENVI_FILE"
>>>>>> CIR.envi = read.ENVI(cir.image, headerfile=paste(cir.image,".hdr",
>>>>>> sep=""))
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ############################################################################
>>>>>> ####
>>>>>>
>>>>>>
>>>>>>
>>>>>> ############################################################################
>>>>>> ####
>>>>>> ## Show image
>>>>>> CIR.envi.band1 <- CIR.envi[,,1]
>>>>>> image(CIR.envi.band1, main="")
>>>>>> mtext("Raw Matrix ENVI Image for Band 1", side=3,line = 2, font=3,
>>>>>> cex=1.25)
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ############################################################################
>>>>>> ####
>>>>>>
>>>>>>
>>>>>>
>>>>>> ############################################################################
>>>>>> ####
>>>>>>
>>>>>> Andrew Niccolai
>>>>>> Doctoral Candidate
>>>>>> Yale School of Forestry
>>>>>>
>>>>>>
>>>>>>
>>>>>> -----Original Message-----
>>>>>> From: r-sig-geo-bounces at stat.math.ethz.ch
>>>>>> [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Guy Serbin
>>>>>> Sent: Tuesday, July 29, 2008 12:55 PM
>>>>>> To: R-sig-Geo at stat.math.ethz.ch
>>>>>> Subject: [R-sig-Geo] ENVI data and R
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I was wondering if anyone knows how to either call up R functions from
>>>>>> within IDL, or conversely read ENVI image data into R. If you have
>>>>>> any advice I'd greatly appreciate it.
>>>>>>
>>>>>> Thanks,
>>>>>> Guy Serbin
>>>>>>
>>>>>> --
>>>>>> Guy Serbin, Ph.D.
>>>>>> Research Soil Scientist
>>>>>> Hydrology and Remote Sensing Lab
>>>>>> Bldg 007 Rm 104 BARC-West
>>>>>> 10300 Baltimore Blvd
>>>>>> Beltsville, MD 20705-2350 USA
>>>>>> +1(301)504-5250 guy.serbin at gmail.com
>>>>>>
>>>>>> _______________________________________________
>>>>>> R-sig-Geo mailing list
>>>>>> R-sig-Geo at stat.math.ethz.ch
>>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>>>>
>>>>>> _______________________________________________
>>>>>> R-sig-Geo mailing list
>>>>>> R-sig-Geo at stat.math.ethz.ch
>>>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>>>
>>>>> ________________________________
>>>>> Stay in touch when you're away with Windows Live Messenger. IM anytime
>>>>> you're online.
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> 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
>>>
>>>
>>
>>
>>
>>
>
> --
> 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
>
>



--
Guy Serbin, Ph.D.
Research Soil Scientist
Hydrology and Remote Sensing Lab
Bldg 007 Rm 104 BARC-West
10300 Baltimore Blvd
Beltsville, MD 20705-2350 USA
+1(301)504-5250 guy.serbin at gmail.com