ENVIGeoJSONToROITask
This task converts GeoJSON features to a region of interest (ROI).
GeoJSON is a geospatial format based on JSON code that is used for encoding geographic data structures. For more information, see the GeoJSON Format Specification. Also see the GeoJSONLint web page for example code and for tools that validate GeoJSON code.
Example
e = ENVI()
File = Filepath('qb_boulder_msi', Subdir=['data'], $
Root_Dir=e.Root_Dir)
Raster = e.OpenRaster(File)
jsonString = '{"type": "GeometryCollection",' + $
'"crs": {' + $
'"type": "name",' + $
'"properties": {' + $
'"name": "urn:ogc:def:crs:EPSG::4326"' + $
'}' + $
'},' + $
'"geometries": [' + $
'{"type": "MultiPolygon",' + $
'"coordinates": '+ $
'[' + $
'[' + $
'[ [-105.20418905,40.00161644],' + $
'[-105.20579077,39.99951061],' + $
'[-105.20243658,39.99929828],' + $
'[-105.20418905,40.00161644] ],' + $
'[ [-105.22100219,39.99188934],' + $
'[-105.22120192,39.99157745],' + $
'[-105.22077586,39.99159722],' + $
'[-105.22100219,39.99188934] ]' + $
'],' + $
'[]' + $
'],' + $
' "properties":{'+$
'"name": "water",' + $
'"color": [0,0,255]' + $
'}' + $
'},' + $
'{"type": "MultiPolygon",' + $
'"coordinates": '+ $
'[' + $
'[' + $
'[ [-105.21645204,39.98990144],' + $
'[-105.21706805,39.98894798],' + $
'[-105.21554790,39.98946003],' + $
'[-105.21645204,39.98990144] ]' + $
'],' + $
'[]' + $
'],' + $
' "properties":{'+$
'"name": "grass",' + $
'"color": [0,255,0]' + $
'}' + $
'},' + $
'{"type": "MultiPolygon",' + $
'"coordinates": '+ $
'[' + $
'[' + $
'[ [-105.20932273,40.00311630],' + $
'[-105.20942141,40.00299338],' + $
'[-105.20909107,40.00295165],' + $
'[-105.20900897,40.00309994],' + $
'[-105.20932273,40.00311630] ]' + $
'],' + $
'[]' + $
'],' + $
' "properties":{'+$
'"name": "roof",' + $
'"color": [255,255,0]' + $
'}' + $
'}' + $
']' + $
'}'
task = ENVITask('GeoJSONToROI')
task.Input_GeoJSON = ENVIGeoJSON(JSON_Parse(jsonString))
task.Execute
view = e.GetView()
layer = view.CreateLayer(Raster)
rois = task.OUTPUT_ROI
roiLayers = OBJARR(N_ELEMENTS(rois))
FOR i=0, N_ELEMENTS(rois)-1 DO roiLayers[i] = layer.AddROI(rois[i])
Syntax
Result = ENVITask('GeoJSONToROI')
Input properties (Set, Get): INPUT_GEOJSON, OUTPUT_ROI_URI
Output properties (Get only): OUTPUT_ROI
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:
AddParameter
Execute
Parameter
ParameterNames
RemoveParameter
Properties
This task inherits the following properties from ENVITask:
COMMUTE_ON_DOWNSAMPLE
COMMUTE_ON_SUBSET
DESCRIPTION
DISPLAY_NAME
NAME
REVISION
TAGS
This task also contains the following properties:
INPUT_GEOJSON (required)
Specify an input GeoJSON object.
- ENVI currently supports GeometryCollection type objects. These objects can only contain one or more MultiPolygon type geometries.
- The crs tag is not required. If the code contains this tag, ENVI converts it to a string. Otherwise, it uses a default value of wgs84.
- You can add name and color properties to each MultiPolygon object. See the example code in this topic.
To ensure properly validated GeoJSON code, refer to the GeoJSONLint web page.
OUTPUT_ROI
This is a reference to the output ROI.
OUTPUT_ROI_URI (optional)
Specify a string with the fully-qualified path and filename for OUTPUT_ROI.
Version History
API Version
3.3
See Also
ENVITask, ENVITask::Parameter