Use this procedure to add a record to a new EVF. It accepts points, polylines, and polygon records.

Syntax


ENVI_EVF_DEFINE_ADD_RECORD, EVF_PTR, Points [, PARTS_PTR=value] [, TYPE=value]

Arguments


EVF_PTR

This is the pointer to the new EVF, and it is returned from ENVI_EVF_DEFINE_INIT.

This pointer is not the same as an ordinary EVF ID.

Points

This argument is a two-column array of x,y points that define the vector record added to the EVF. A point record consists of a single x,y pair, a polyline record consists of multiple x,y pairs, and a polygon record is a polyline with the same first and last points. Points is an array of [2, npts] where [0,*] are the x points and [1,*] are the y points. The data type of the x,y pairs (or nodes) that define the vector record will automatically be converted into the data type of the EVF defined in the call to ENVI_EVF_DEFINE_INIT.

Tip: For points in a Geographic projection, remember to arrange the points vector as [longitude, latitude] to conform to the x, y order.

Keywords


PARTS_PTR (optional)

Use this keyword along with the TYPE keyword when adding points to a vector record to indicate that the polygon is a multipart polygon. Multi-part polygons are commonly used to specify holes within polygons. The PARTS_PTR keyword tells ENVI Classic how to order the points in the file. You should specify the points of the main polygon first, followed by the points for the holes within the polygon.

Suppose you are defining a polygon with three internal holes. It has 33 points total; the first 7 points define the main polygon, the next 10 define the first hole, the next 8 define the second hole, and the last 7 define the third hole. Define PARTS_PTR as follows:

parts_ptr = [0L, 7, -17, -25, -32]

Where the negative sign denotes nodes that are multipart.

TYPE (optional)

Use this keyword along with the PARTS_PTR keyword to indicate the type of multipart vector data you are working with. Following are the possible values for TYPE:

  • 1: Point
  • 3: Polyline
  • 5: Polygon
  • 8: Multi-point

Set TYPE=5 when defining multipart polygon records.

Example


PRO CREATE_NEW_EVF_FILE
  compile_opt IDL2
  ;
  ; Create a Geographic projection
  ; with the default datum and units.
  ;
  proj = envi_proj_create(/geographic)
  ;
  ; Define a polyline vector in Lat/Lon coordinates
  ;
  polyline = [-106.904,      41.5887, $
              -106.821,      42.2302, $     
              -106.013,      42.2183, $     
              -105.206,      41.3749, $     
              -105.657,      40.5078, $     
              -105.835,      39.5574, $     
              -105.170,      38.8447, $     
              -104.125,      39.4862, $
              -103.269,      40.0563, $     
              -103.269,      40.0682, $     
              -102.913,      39.0585, $
              -102.901,      39.0585, $
              -102.901,      39.0348, $     
              -103.210,      38.4289, $
              -103.804,      38.3695]
  polyline = reform(polyline, 2, 15)
  ;
  ; define a polygon in Lat/Lon coordinates
  ; (note first and last coords are identical)
  ;
  polygon = [-104.113,      41.6956, $     
             -103.994,      42.1589, $
             -103.934,      41.6838, $     
             -103.471,      41.8738, $     
             -103.887,      41.5531, $
             -103.863,      41.0185, $
             -103.851,      41.0185, $     
             -104.041,      41.4818, $
             -104.041,      41.4937, $     
             -104.552,      41.2680, $     
             -104.220,      41.6006, $     
             -104.422,      42.0995, $     
             -104.113,      41.6956]
  polygon = reform(polygon, 2, 13)
  ;
  ; define a set of discrete points in Lat/Lon coordinates
  points = [-106.572,      39.6643, $
            -106.643,      39.5218, $     
            -106.453,      39.4386, $     
            -106.417,      39.6168, $     
            -106.595,      39.4386, $     
            -106.774,      39.2011, $
            -106.215,      39.4030, $
            -106.393,      39.2961, $
            -106.560,      39.1892, $
            -106.536,      38.9872, $
            -106.227,      39.1417, $
            -106.192,      39.1179, $
            -106.263,      38.9635, $
            -106.073,      39.1298, $
            -106.073,      39.2367]
  points = reform(points, 2, 15)
  ;
  ; Initialize the new EVF file
  ;
  evf_ptr = envi_evf_define_init('sample.evf', $
       projection=proj, data_type=4, $  
       layer_name='Sample EVF File')
  if (ptr_valid(evf_ptr) eq 0) then return
  ;
  ; add the discrete points as individual records
  ;
  for i=0,14 do $  
     envi_evf_define_add_record, evf_ptr, points[*,i]
  ;
  ; add the polyline record
  ;
  envi_evf_define_add_record, evf_ptr, polyline
  ;
  ; add the polygon record
  ;
  envi_evf_define_add_record, evf_ptr, polygon
  ;
  ; Finish defining the new EVF file and
  ; then close the EVF file
  ;
  evf_id = envi_evf_define_close(evf_ptr, /return_id)
  envi_evf_close, evf_id
  ;
  ; create an attribute file for this new EVF file
  ;
  ; records 1-15 are individual points
  ; record 16 is a polyline
  ; record 17 is a polygon
  ;
  attributes = replicate( {name:'', id:0L}, 17)
  for i=0,14 do begin  
     attributes[i].name = 'Sample Point ' + strtrim(i+1,2)
     attributes[i].id = i+1
  endfor
  attributes[15].name = 'Sample Polyline'
  attributes[15].id = 16
  attributes[16].name = 'Sample Polygon'
  attributes[16].id = 17
  envi_write_dbf_file, 'sample.dbf', attributes
END

API Version


4.2