Re: Apply a shapefile to raster images in IDL [message #41346 is a reply to message #41289] |
Tue, 05 October 2004 09:18  |
c_jengo
Messages: 5 Registered: May 2004
|
Junior Member |
|
|
Jenny,
This suggestion is based on three assumptions:
1. You have ENVI+IDL (sounds like it)
2. There is only one shapefile for all the files (also sounds like it)
3. Your image files are georeferenced or the lat/lon files give a
lat/lon point for every pixel in the image (known as an Internal
Geometry Model (IGM) file), or you can otherwise georeference them.
While not trivial (especially for a novice), there is a way to do this
using ENVI routines.
First, convert your shapefile to an ENVI vector file (EVF) by clicking
Vector > Open Vector File > Shapefile (I don't think there is a
documented way to do this programmatically).
Next, write an IDL program that iterates through your files and does
the following:
-Open your image and IGM files (ENVI_OPEN_FILE)
-Create a Geographic Lookup Table (GLT) file (ENVI_GLT_DOIT)
-Apply the GLT to create a georeferenced image
(ENVI_GEOREF_FROM_GLT_DOIT)
-Open the vector file (ENVI_EVF_OPEN)
-Loop through the records and extract the vector coordinates
(ENVI_EVF_READ_RECORD)
-Close the vector file (ENVI_EVF_CLOSE)
-Convert these lat/lon points to file coordinates referenced to your
georeferenced image (ENVI_CONVERT_FILE_COORDINATES)
-Create a region of interest (ENVI_CREATE_ROI)
-Populate the ROI with your points (ENVI_DEFINE_ROI)
-Get the address of every pixel within the ROI (ENVI_GET_ROI)
-Create an array with the same dimensions as your georeferenced image
(BYTARR)
-Set pixels within ROIs equal to 1 (ex: myImage[roi_addr] = 1)
-Save the mask to a temp file or memory (ENVI_WRITE_ENVI_FILE
ENVI_ENTER_DATA)
-Apply the mask to your image (ENVI_MASK_APPLY_DOIT)
-Be sure to clean up your files (ENVI_FILE_MNG)
And that's it! Nothing to it, eh? ;-) Sorry if I missed a step or
two, I was going off the top of my head. Hope this at least gets you
started...
Chris
envi35@yahoo.ca (Jenny) wrote in message news:<c371324e.0410021329.26d3e286@posting.google.com>...
> Dear Listers,
> I'm a novice in IDL, not sure if my questions are totally improper. I
> want to use an Arcview format shapefile as a mask, to a huge number of
> raster images, which are in a polar stereographic grid format with
> separate image data files and lat/lon files. I would really appreciate
> if you could give me any hint about the following questions:
>
> 1. How to read the shapefile into an IDL variable?
> 2. How to tailor the shapefile to my raster image grid?
> 3. If the above questions are not proper or impossible in IDL, would
> you give me some suggestions to do the work?
>
> Thank you in advance,
> Jenny
|
|
|