X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



9335 Rate this article:
2.4

How to programmatically create a multipart vector file in ENVI Classic

ENVI's EVF routines allow you to define a multipart polygon programmatically using the PARTS_PTR and TYPE keywords. The code example in this Help Article provides an example of creating a single, large polygon with three 'holes' within the polygon.

The following example code shows how to create a multipart polygon using ENVI's EVF routines. The code uses the documented routines, ENVI_EVF_DEFINE_INIT, ENVI_EVF_DEFINE_ADD_RECORD, and ENVI_EVF_DEFINE_CLOSE. When adding points to the record, you can specify the PARTS_PTR and TYPE keywords to denote the polygon is a multipart polygon. The key is that when you specify the points for the polygon, the main polygon points are specified first, then the points for the holes. The PARTS_PTR keyword tells ENVI how to order them in the file.

In the following code example, there is a total of 33 points defining the polygon and 3 holes within the polygon. 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. The PARTS_PTR keyword is set up as:

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

where the negative sign denotes those nodes are multipart.

Multipart polygons are of the vector type '5' in ENVI.
------------------------------------------------------------------------
pro create_multipart_vector
 
; Create a projection for the points 
;the points in this example are in UTM easting/northing
proj = envi_proj_create(/utm, zone=13)  
; 
; define a polygon in easting/northing coordinates 
; note first and last coords are identical for each polygon 
; first 7 nodes are main polygon, next 10 are first donut, 
; next 8 are second donut, last 7 are third donut
polygon = [ $
       276165.00, 4903605.0, $
       276825.00, 4896075.0, $
       276855.00, 4896075.0, $
       283815.00, 4896675.0, $
       284205.00, 4905135.0, $
       276195.00, 4903635.0, $
       276165.00, 4903605.0, $
       278685.00, 4900035.0, $
       278715.00, 4900035.0, $
       278715.00, 4900155.0, $
       278745.00, 4900155.0, $
       279345.00, 4900065.0, $
       279345.00, 4899705.0, $
       279345.00, 4899675.0, $
       279075.00, 4899405.0, $
       278775.00, 4899465.0, $
       278685.00, 4900035.0, $
       281685.00, 4898115.0, $
       281895.00, 4898145.0, $
       282855.00, 4897965.0, $
       282675.00, 4897365.0, $
       282045.00, 4897035.0, $
       281775.00, 4897395.0, $
       281775.00, 4897425.0, $
       281685.00, 4898115.0, $
       281595.00, 4903395.0, $
       281805.00, 4903395.0, $
       282825.00, 4903395.0, $
       282855.00, 4902645.0, $
       282855.00, 4902585.0, $
       282075.00, 4902075.0, $
       281595.00, 4903395.0]  

polygon = reform(polygon, 2, 32)  
  
; Initialize the new EVF file 
evf_ptr = envi_evf_define_init('sample.evf', $  
  projection=proj, $  
  layer_name='Sample EVF File')  
if (ptr_valid(evf_ptr) eq 0) then return  

; define parts_ptr as first: main polygon nodes (0-7),
; then first hole (next 10 points specified as negative)
; second hole (next 8 points specified as negative)
; third hole (last 7 points specified as negative) 
parts_ptr = [0L, 7, -17, -25, -32]

;add polygon and parts to record - multipart is type 5
envi_evf_define_add_record, evf_ptr, polygon, parts_ptr=parts_ptr, type=5  

; Finish defining the new EVF file and close
evf_id = envi_evf_define_close(evf_ptr, /return_id)  
envi_evf_close, evf_id  
  
end 
Review on 12/31/2013 MM

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »