Discussion:
How to spatial subset files by ENVI vector file (EVF) or other shapefile ?
(too old to reply)
Lucia
2007-12-17 12:58:24 UTC
Permalink
I can spatial subset files by EVF in ENVI, but I need to do it by IDL.
d***@gmail.com
2007-12-17 13:22:56 UTC
Permalink
Post by Lucia
I can spatial subset files by EVF in ENVI, but I need to do it by IDL.
i did not understand exatly you'r problem but just:
1- save your EVF file to .shp file ( it si easy in ENVI)
2-see this article from David: http://www.dfanning.com/map_tips/shapefile.html
chears
Dav
Allard de Wit
2007-12-17 14:01:37 UTC
Permalink
Post by Lucia
I can spatial subset files by EVF in ENVI, but I need to do it by IDL.
Dear Lucia,

I have never tested this, but it seems to me that you need to use
ENVI_GET_ROI_DIMS_PTR to get the dimensions pointer for the ROI.
So you basically carry out the following steps:
roi_ids = envi_get_roi_ids(fid = fid)
dims = [envi_get_roi_dims_ptr(roi_ids[0]), 0, 0, 0, 0]
data = envi_get_data(fid=fid, dims=dims)

then you can write the data to a file and set up an ENVI header file
for it. I haven't figured out how to find the map coordinates for the
selected subset but I guess the ENVI manual will give a clue
somewhere.

with best regards,

Allard
Jean H
2007-12-17 16:52:06 UTC
Permalink
Post by Lucia
I can spatial subset files by EVF in ENVI, but I need to do it by IDL.
Hi,
You can start with this..
Jean.

-------------

;open the evf file
vectID = ENVI_EVF_OPEN(VectorToOpen)
;get the numbers of records (polygons) in the vector file
ENVI_EVF_INFO, vectID, num_recs = numRecs
;Open the image. We will get the pixel locations of the polygons out of it.
envi_open_file,ImageFilename,r_fid=fid
;get the X and Y dimensions of the image
ENVI_FILE_QUERY, fid, nl=nl, ns=ns

; Loop through each record
for record=0,numRecs-1 do begin ;
;get the coord of each nodes of the current polygon; Coords are
projected.
pts_polygon_proj = envi_evf_read_record(vectID, record)

;convert the projected coordinates of the nodes to a line/column
coordinate

envi_convert_file_coordinates,fid,pts_X_polygon_pixel,pts_Y_polygon_pixel,pts_polygon_proj[0,*],pts_polygon_proj[1,*]

;Get the 1D cell indices of the cells lying under the current polygon.
polygonIndices =
polyfillv(round(pts_X_polygon_pixel),round(pts_Y_polygon_pixel), ns, nl)


endfor

Loading...