Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


  >  Docs Center  >  ENVI API  >  Processing  >  ENVIGeoJSONToROITask

ENVIGeoJSONToROITask

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


; 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)
 
; Define a GeoJSON object
jsonString = '{"type": "GeometryCollection",' + $
              '"crs": {' + $
                '"type": "name",' + $
                '"properties": {' + $
                '"name": "urn:ogc:def:crs:EPSG::4326"' + $
                '}' + $
              '},' + $
             '"geometries": [' + $
               '{"type": "MultiPolygon",' + $
                '"coordinates": '+ $
                  '[' + $
                    ; Outer Polygons
                    '[' + $
                       ; water 1
                       '[ [-105.20418905,40.00161644],' + $
                       '[-105.20579077,39.99951061],' + $
                       '[-105.20243658,39.99929828],' + $
                       '[-105.20418905,40.00161644] ],' + $
                       ; water 2
                       '[ [-105.22100219,39.99188934],' + $
                       '[-105.22120192,39.99157745],' + $
                       '[-105.22077586,39.99159722],' + $
                       '[-105.22100219,39.99188934] ]' + $
                       '],' + $
                       ; holes
                       '[]' + $
                     '],' + $
             ' "properties":{'+$
                 '"name": "water",' + $
                 '"color": [0,0,255]' + $
                 '}' + $
               '},' + $
               '{"type": "MultiPolygon",' + $
             '"coordinates": '+ $
               '[' + $
                 ; Outer Polygons
                 '[' + $
                    ; grass
                    '[ [-105.21645204,39.98990144],' + $
                    '[-105.21706805,39.98894798],' + $
                    '[-105.21554790,39.98946003],' + $
                    '[-105.21645204,39.98990144] ]' + $
                 '],' + $
                 ; holes
                 '[]' + $
               '],' + $
              ' "properties":{'+$
                  '"name": "grass",' + $
                  '"color": [0,255,0]' + $
                  '}' + $
               '},' + $
               '{"type": "MultiPolygon",' + $
              '"coordinates": '+ $
                '[' + $
                  ; Outer Polygons
                  '[' + $
                   ; roof
                   '[ [-105.20932273,40.00311630],' + $
                   '[-105.20942141,40.00299338],' + $
                   '[-105.20909107,40.00295165],' + $
                   '[-105.20900897,40.00309994],' + $
                   '[-105.20932273,40.00311630] ]' + $
                   '],' + $
                   ; holes
                   '[]' + $
                '],' + $
               ' "properties":{'+$
                   '"name": "roof",' + $
                   '"color": [255,255,0]' + $
                   '}' + $
                 '}' + $
               ']' + $
             '}'
 
; Get the task from the catalog of ENVITasks
task = ENVITask('GeoJSONToROI')
 
; Define task inputs
task.Input_GeoJSON = ENVIGeoJSON(JSON_Parse(jsonString))
 
; Run the task
task.Execute
 
; Display the result
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


ENVI 5.3

Introduced

API Version


3.2

See Also


ENVITask, ENVITask::Parameter



© 2018 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us