VectorToFeatureCount Task
This task converts vector records into a feature counting layer.
Example
This example opens a shapefile of U.S. cities. It groups the 3,500 records into 50 different features by state. It creates an ENVI feature counting file (.efc
) in the directory specified by the Temporary Directory ENVI preference. The default locations are as follows:
- Windows:
C:\Users\<username>\AppData\Local\Temp
- Linux:
/usr/local/tmp
After running this example, select File > Open from the ENVI main menu bar and select the output .efc
file. When the Data Selection dialog prompts you to choose the associated raster, select natural_earth_shaded_relief.jp2
and click OK. ENVI creates a feature counting layer and displays it over the shaded relief image. It opens the Feature Counting Tool so that you can view the attributes of the feature counting layer.
; Start the application
e = ENVI()
; Open an input raster
File = Filepath('natural_earth_shaded_relief.jp2', $
Subdir=['data'], Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
; Open a point shapefile of world cities
VectorFile = Filepath('cities.shp', $
Subdir=['classic','data','vector'], $
Root_Dir=e.Root_Dir)
Vector = e.OpenVector(VectorFile)
; Get the task from the catalog of ENVITasks
Task = ENVITask('VectorToFeatureCount')
; Define input properties
Task.INPUT_RASTER = Raster
Task.INPUT_VECTOR = Vector
Task.ATTRIBUTE_FEATURE_NAME = 'ST'
Task.ATTRIBUTE_DESCRIPTION_NAME = 'AREANAME'
; Run the task
Task.Execute
; Display the shaded relief image
View = e.GetView()
Layer = View.CreateLayer(Raster)
View.Zoom, 0.3
View.GoToLocation, 4901, 2845, DATA=Layer
; Get the location of the output feature
; count file
Print, 'Feature count file created. You can manually open it from ENVI now. File location:'
Print, Task.OUTPUT_FEATURE_COUNT_URI
See More Examples.
Syntax
Result = ENVITask('VectorToFeatureCount')
Input properties (Set, Get): ATTRIBUTE_ACQUISITION_NAME, ATTRIBUTE_DESCRIPTION_NAME, ATTRIBUTE_FEATURE_NAME, INPUT_RASTER, INPUT_VECTOR, OUTPUT_FEATURE_COUNT_URI
Output properties (Get only): OUTPUT_FEATURE_COUNT
Properties marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Properties marked as "Get" are those whose values you can retrieve but not set.
Methods
This task inherits the following methods from ENVITask:
Properties
This task inherits the following properties from ENVITask:
This task also contains the following properties:
ATTRIBUTE_ACQUISITION_NAME (optional)
Specify the attribute name of the column containing the acquisition time.
ATTRIBUTE_DESCRIPTION_NAME (optional)
Specify the attribute name of the column containing the description.
ATTRIBUTE_FEATURE_NAME (optional)
Specify the attribute name of the column containing the feature class.
INPUT_RASTER (required)
Specify the input raster.
INPUT_VECTOR (required)
Specify the input vector. This can be any vector format that ENVI supports. For polylines and polygons, the centroid is used to create the feature counting locations.
OUTPUT_FEATURE_COUNT
This is a reference to the output feature count file (.efc
).
OUTPUT_FEATURE_COUNT_URI (optional)
Specify a string with the fully-qualified path and filename for OUTPUT_FEATURE_COUNT.
More Examples
This example downloads OpenStreetMap® vectors of highways and roads that intersect with the geographic extent of a QuickBird image. It groups the shapefile records into features based on the type of road; for example, "residential" or "motorway."
; Start the application
e = ENVI()
; Open an input file
File = Filepath('qb_boulder_msi', Subdir=['data'], $
Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
; Download OpenStreetMap vectors of highways and roads
OSMTask = ENVITask('DownloadOSMVectors')
OSMTask.SUB_RECT=[-105.23, 39.98, -105.2, 40.01]
OSMTask.FEATURE_NAMES=['Highways and Roads']
OSMTask.VECTOR_TYPES=['Polyline']
OSMTask.Execute
; Convert the vector records to feature counts
Task = ENVITask('VectorToFeatureCount')
Task.INPUT_RASTER = Raster
Task.INPUT_VECTOR = OSMTask.OUTPUT_VECTOR
Task.ATTRIBUTE_FEATURE_NAME = 'highway'
Task.ATTRIBUTE_DESCRIPTION_NAME = 'name'
Task.Execute
; Display the raster
View = e.GetView()
Layer = View.CreateLayer(Raster)
After running this example, select File > Open from the ENVI main menu bar and select the output .efc
file. When the Data Selection dialog prompts you to choose the associated raster, select qb_boulder_msi
and click OK. ENVI creates a feature counting layer and displays it over the shaded relief image. It opens the Feature Counting Tool so that you can view the attributes of the feature counting layer.
Version History
ENVI 5.5.3 |
Introduced |
API Version
4.2
See Also
ENVITask, ENVIFeatureCount, ENVIVector, DownloadOSMVectors Task