OACALCATT

Calculate object attributes


EnvironmentsPYTHON :: EASI
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Example :: References :: Related

Back to top

Description


From one or more input channels, OACALCATT calculates attributes of objects (polygons) in a vector layer, and then writes the output values to the same or a new segmentation vector layer. Attributes can be statistical, geometrical, textural, or Vegetation Indices (VI).
Back to top

Parameters


oacalcatt(fili, dbic, chnalias, filv, dbvs, filo, dbov, ftype, statatt, texatt, texwinsz, geoatt, ppixatt, index, visirchn)

Name Type Caption Length Value range
FILI* str Input file name 1 -    
DBIC List[int] Input channels 0 -    
CHNALIAS str Aliases of input channels 0 -    
FILV str Name of input vector file 0 -    
DBVS* List[int] Segment number of vector layer 1 - 1  
FILO str Output vector file name 0 -    
DBOV List[int] Output vector segment 0 - 1  
FTYPE str Output file type 0 - 3 PIX | SHP
Default: PIX
STATATT str Statistical attributes to calculate 0 -    
TEXATT str Texture attributes to calculate 0 -    
TEXWINSZ List[int] Size of texture window 0 - 1 Default: 11
GEOATT str Geometrical attributes to calculate 0 -    
PPIXATT str Calculate pure pixels 0 - 3 NO | YES
Default: NO
INDEX str Vegetation Indices 0 -    
VISIRCHN List[int] Input channel or channels 0 - 4 -

* Required parameter
Back to top

Parameter descriptions

FILI

The name of the PCIDSK file that contains the channels to process.

DBIC

The channel or channels from which to extract attributes.

By default, all channels are processed.

CHNALIAS

Comma-separated aliases, or brief descriptions, of each channel specified as input.

The field names will appear in the attribute table with the aliases you specify.

If you do not specify a value, an alias is generated based on GDB-provided channel metadata, if it exists. If the channel metadata is unavailable, a generic sequence of bands is used; for example, B01, B02, B01, and so on.

Note: Aliases must be in the same order as the input channels, and the channel numbers must correspond.

FILV

The name of the file that contains a vector layer of closed polygons; typically, a segmentation layer generated by OASEG.

If you do not specify a value, the PCIDSK file you specified as input is used.

DBVS

The vector layer to which to write the calculated attributes.

FILO

The file containing the segmentation layer to which to write the calculated attributes.

The file name you specify can be that of the input file or a new output file. When you create a new output file, the objects and attributes you specified are also written to the file.

If you do not specify a value, the segmentation layer is written to the corresponding layer of the input file.

DBOV

The segment number of the vector layer of the output file to which to write the results of the attribute calculation.

When FILO does not exist, DBOV will be ignored. The results will be written to the new file.

FTYPE

The format of the output file.

The following formats are supported:

The default is PIX.

STATATT

The statistical attributes to calculate for each object of the input segmentation vector layer from the input channels.

Specify the attributes you want to calculate as follows:

You can also specify a subset of any statistical attributes. For example, to specify minimum and mean, enter "MIN, MEAN".

TEXATT

The texture attributes to calculate for each object of the input segmentation vector layer from the input raster layers.

The attributes are based on second-order statistics calculated from the gray-level cooccurrence matrices.

Specify the attributes you want to calculate as follows:

You can also specify a subset of any textural attributes. For example, to specify cooccurrence standard deviation and cooccurrence contrast, enter "TSTD, TCON".

TEXWINSZ

The size of the window to use to extract texture attributes.

The value you specify must be an odd integer and a minimum of 5.

The default size is 11.

GEOATT

The geometrical attributes to calculate for each object of the input segmentation vector layer.

Specify the attributes you want to calculate as follows:

By using a comma-separated string, you can define a subset of any geometrical attributes. For example, to specify form factor, solidity, and minor-axis length, enter "FOR, SOL, MIA".

PPIXATT

Calculate pure pixels.

You can specify the value as one of the following: When you specify Yes, the field name will be appended with _PP_ to indicate it is pure-pixel statistics.

This parameter is optional.

INDEX

The Vegetation Indices (VI) to calculate.

You can enter a single index or enter a comma-separated string of one or more.

To calculate all VI relevant to the input data, enter ALL.

The VI you can calculate are as follows:

This parameter is optional.

VISIRCHN

The input channel or channels that contain the blue, green, red, and near infrared (NIR) bands.

If you do not specify a value, the channel-level metadata is used to calculate the indices. If channel-level metadata is unavailable, or if there is more than one appropriate spectral band, you can specify a string of channels to use. The channels in the string must be in a specific order; that is, the first channel must correspond to the blue band, the second to the green band, the third to the red band, and the fourth to the NIR band.

For example, to specify that channel 2 (%2) is the blue band, channel 3 (%3) is the green band, channel 4 (%4) is the red band, and channel 8 (%8) is the NIR band, enter "2,3,4,8".

If you do not specify a value, the channel-level metadata is used to determine the relevant spectral bands.

This parameter is optional.

Back to top

Details

Supported channels

OACALCATT can calculate attributes of the following channel types:

Statistical attributes

Statistical attributes are calculated based on the image pixels inside an object. Attributes are calculated for each of the selected image bands and added to the attribute table of the vector segment layer as new fields (attributes). The following table provides a description of statistical attributes you can calculate.

Table 1. Statistical attributes
Attribute Short name Description
Min. Min Minimum value of the pixels beneath an object in a selected band
Max. Max Maximum value of the pixels beneath an object in a selected band
Mean Mean Mean value of the pixels beneath an object in a selected band
Standard deviation StdV Standard-deviation value of the pixels beneath an object in a selected band

Pure-pixel statistics

Imagery and data sets of various resolutions are often used in an object-based image analysis (OBIA) to combine information from (a) high-spatial-resolution panchromatic or wide-band multispectral imagery acquired at a low-temporal resolution with (b) imagery from narrow-band multispectral high-temporal resolution with a low-spatial resolution. This fusion of information of various resolutions is used commonly with multitemporal image analysis.

Pixels along the borders of segments contain information from the adjoining segments and act as mixed pixels. This can have substantial impact on the local mean of a segment. To overcome the mixed-pixels issue, you can opt to calculate statistics by excluding the pixels on the segment boundary. This is referred to as pure-pixel statistics.

Geometrical attributes

The attributes representing geometrical characteristics of an object (polygon segment) make object-based image analysis (OBIA) advantageous over pixel-based measures. The geometrical attributes are calculated by analyzing the polygon boundary created during segmentation, so raster information is not required. Many of the shape descriptors used commonly are calculated. Each is described in the following table.

Note: Geometrical attributes are independent from the channel aliases, because they are calculated from the shape of objects.
Table 2. Geometrical attributes
Attribute Short name Description
Compactness Compact A measure of closely packed a shape is. A circle is the most compact.

Compactness = √(4 × As ÷ pi) ÷ O

Where As is the area of the object, and O is the perimeter of the object (outer contour).

Elongation Elongation The ratio of the height and width of a rotated, minimal-bounding box; that is, rotate a rectangle so it is the smallest rectangle in which the object fits, and then compare its height with its width.

Elongation = major axis length ÷ minor axis length

Circularity Circular A ratio representing how like is the shape of the object to a circle. Circularity is the ratio of the area of a shape to the perimeter of the square of the shape.

Circularity = As ÷ O2

Where As is the area of the shape, and O2 is square of the perimeter of the shape.

Rectangularity Rectangular How rectangular a shape is; that is, how much it fills its minimum bounding rectangle:

Rectangularity = As ÷ AR

Where As is the area of a shape, and AR is the area of the minimum bounding rectangle.

Convexity Convexity The relative amount that an object differs from a convex object. Convexity is calculated by forming the ratio of the perimeter of the convex hull of an object to the perimeter of the object itself.

Convexity = convex-hull perimeter ÷ object perimeter

Solidity Solidity The density of an object. Solidity is calculated as the ratio of the area of an object to the area of a convex hull of the object. A value of 1 indicates a solid object, and a value less than 1 indicates an object having an irregular boundary or containing holes.

Solidity = area ÷ convex-hull area

Form factor FormFactor The measure that compares the area of a polygon to the square of the perimeter. The form-factor value of a circle is 1, and the value of a square is pi ÷ 4.

Form factor = 4 × pi × area ÷ sqrt (perimeter)

Major-axis length MajorAxis The length of the major axis of an oriented bounding box enclosing the polygon.

Values are map units of the pixel size. If the image is not georeferenced, the values are pixels.

Minor-axis length MinorAxis The length of the minor axis of an oriented bounding box enclosing the polygon.

Values are map units of the pixel size. If the image is not georeferenced, the values are pixels.

Vegetation Indices attributes

You can select from several Vegetation Indices (VI) to perform quantitative and qualitative evaluations of vegetation cover, vigor, growth dynamics, and more.

During Attribute Calculation, file metadata is analyzed to identify the sensor type and available bands. Based on the analysis, various VIs become available for which to calculate attributes. The VIs are based on the availability of the following bands:
  • Red
  • Green
  • Blue
  • Near Infrared (NIR)
Tip: You can calculate additional VIs by running the VEGINDEX algorithm. You can then, in Object Analyst, use the file created by VEGINDEX as input to calculate statistical mean for objects.

If the bands are not defined in the metadata, you can define them.

Vegetation Indices (VI) attributes are independent from the channel aliases and instead rely on the channel metadata or the channels specified as input.

The following table provides descriptions of each Vegetation Index attribute that you can calculate.

Table 3. Vegetation Indices attributes
Attribute Short name Description
Green/Red Vegetation Index GRVI GRVI = (Green - Red) ÷ (Green + Red)
Greenness Index GI GI = ((2.0 × Green) - (Red + Blue)) ÷ ((2.0 × Green) + Red + Blue)
Vegetation Difference Index VDI VDI = NIR - Red
Ratio Vegetation Index RVI RVI = NIR ÷ Red
Normalized Difference Vegetation NDVI NDVI = (NIR - Red) ÷ (NIR + Red)
Transformed Difference Vegetation Index TDVI TDVI = (NIR - Red) ÷ (NIR + Red) + .5
Soil Adjusted Vegetation Index SAVI SAVI = ((NIR - Red) ÷ (NIR + Red + L)) × (1 + L)

The L-value is based on the amount of green vegetative cover. L is a default of 0.5, which means, generally, areas of moderate green vegetative cover.

Modified Soil Adjusted Vegetation Index MSAVI2 MSAVI2 = (0.5) × (2(NIR + 1) - √((2 × NIR + 1) - 8(NIR - Red)))
Global Environmental Monitoring Index GEMI GEMI = eta × (1 - 0.25 × eta) - ((Red - 0.125) ÷ (1 - Red))

Where eta = (2 × (NIR - Red) + 1.5 × NIR + 0.5 × Red) ÷ (NIR + Red + 0.5)

Leaf Area Index LAI LAI = (3.618 × EVI) - 0.118

Where EVI (Enhanced Vegetation Index) = 2.5 × (NIR - Red) ÷ (1 + NIR + (6 × Red) - (7.5 × Blue)

Texture attributes

You can calculate texture measures for a specific direction or directional invariant for all pixels in an input image. The measures are based on second-order statistics calculated from the gray-level cooccurrence matrices.

Table 4. Texture attributes
Attribute Short name Description Algorithm Python EASI Focus/Modeler
Mean Tex_Mean_<ch_alias_name> Cooccurrence mean TEX
Click to view help topic
Click to view help topic
Click to view help topic
Standard deviation Tex_Std_<ch_alias_name> Cooccurrence standard deviation TEX
Click to view help topic
Click to view help topic
Click to view help topic
Entropy Tex_Ent_<ch_alias_name> Cooccurrence entropy TEX
Click to view help topic
Click to view help topic
Click to view help topic
Angular second moment Tex_Ang2m_<ch_alias_name> Cooccurrence angular second moment TEX
Click to view help topic
Click to view help topic
Click to view help topic
Contrast Tex_Cont_<ch_alias_name> Cooccurrence contrast TEX
Click to view help topic
Click to view help topic
Click to view help topic

Band aliases

Aliases supplement the organization of the attributes you calculate. With attributes calculated from image layers, corresponding fields are created in the attribute table of segments. To distinguish among the various attributes, the field name is appended with the relevant layer identifier. By using aliases, you can better manage and interpret the information in the attribute table, which you can view in Attribute Manager.

During attribute calculation, the metadata is analyzed for identification of various band names and short names based on the sensor and wavelength range.

Aliases are generated based on the GDB-provided channel-metadata tag, if it is present. With optical data, aliases are generated from the BandDescription tag and, with SAR data, from the Polorization tag. If the metadata is found, a generic short name, such as B01, B02, B03, and so on is applied as an alias. You can, however, modify the aliases to suit.

The following table shows an example of the channel-level metadata tags and aliases for a sample optical image, LC08_L1TP_018026_20160925_20170221.pix.

Table 5. Aliases for sample optical image
Input channel LC08_L1TP_018026_20160925_20170221 Channel-metadata tag BandDescription Alias
1 Landsat-8 Coastal Aerosol (0.435 - 0.451 um) Coastal Aerosol Aero
2 Landsat-8 Blue (0.452 - 0.512 um) Blue Bl
3 Landsat-8 Green (0.533 - 0.590 um) Green Gr
4 Landsat-8 Red (0.636 - 0.673 um) Red Red
5 Landsat-8 Near Infrared (0.851 - 0.879 um) Near Infrared NIR
6 Landsat-8 SWIR 1 (1.566 - 1.651 um) SWIR 1 S1
7 Landsat-8 SWIR 2 (2.107 - 2.294 um) SWIR 2 S2
8 Landsat-8 Cirrus (1.363 - 1.384 um) Cirrus Cir

For example, to generate the statistical attributes Gr_mean, Gr_min Red_mean, Red_min, NIR_mean NIR_min for each object of a segmentation vector layer, specify the input channels and statistical attributes as follows:
DBIC=3,4,5
CHNALIAS="Gr, Red, NIR"
STATTATT="Mean, Min"
			
Note: If necessary, you can use the same segmentation vector layer to run attribute calculation on several images. If any of the images already have aliases and attributes matching the ones defined herein, they will be overwritten.
Back to top

Example

from pci.oacalcatt import oacalcatt

fili= "l7_ms.pix"
dbic=[2,3,4,5]                                                     # Calculate only the attributes for channels 2, 3, 4 and 5. 
chnalias="green, red, nir, swir1"                     # Band aliases
filv="l7_ms_seg25_0.5_0.5.pix"
dbvs=[2]
filo=""                                               # Blank, calculated attributes will be to filv/dbvs
dbov=[2]
ftype="PIX"
statatt="all"                               # Calculate all statistical attributes
texatt="tmean, tstd"                # Calculate only the mean and standard deviation texture attributes
texwinsz=[11]
geoatt=""                                    # None - Do not calculate geometrical attributes
ppixatt="No"
index="ndvi, lai, gemi, vdi"
visirchn=[]
oacalcatt ( fili, dbic, chnalias, filv, dbvs, filo, dbov, ftype, statatt, texatt, texwinsz, geoatt, ppixatt, index, visirchn)

Back to top

References

For more information about segmentation in remote sensing, see the following published work:
  • Jinru Xue and Baofeng Su, "Significant Remote Sensing Vegetation Indices: A Review of Developments and Applications," Journal of Sensors vol. 2017, Article ID 1353691, 17 pages, 2017.
    hindawi.com

© PCI Geomatics Enterprises, Inc.®, 2024. All rights reserved.