| Environments | PYTHON :: EASI :: MODELER |
| Quick links | Description :: Parameters :: Parameter descriptions :: Return Value :: Details :: Example :: Related |
| Back to top |
| Back to top |
crcentroid(fili, filo, dbvs, dbic, srcattr, centroid)
| Name | Type | Caption | Length | Value range |
|---|---|---|---|---|
| FILI * | str | Input file name | 1 - | |
| FILO | str | Output file name | 0 - | |
| DBVS | List[int] | Input vector segment | 0 - 1 | |
| DBIC | List[int] | Input raster channel | 0 - 1 | |
| SRCATTR | str | Source attributes | 0 - 4 | COPY, JOIN Default: COPY |
| CENTROID | str | Generate centroids for (polygons only or all shapes) | 0 - 8 | Default: Polygons |
| Back to top |
FILI
Specifies the name of the file that contains the input vector or thematic raster data from which the centroids will be generated.
FILO
Specifies the name of the PCIDSK image file that receives the point layer (centroids) generated from the input layer.
FILO is created if it does not already exist.
DBVS
Specifies the segment that contains the vectors for which the centroid layer will be constructed. If DBVS is not specified, DBIC must be specified.
DBIC
Specifies the thematic raster channel that contains the image for which the centroid layer will be constructed. If DBIC is not specified, DBVS must be specified.
SRCATTR
Specifies whether the attributes from the source layer are copied or joined to the point (centroid) layer.
CENTROID
Specifies whether the centroid is to be generated for polygons only or for all shapes. This parameter is only used when the input is a vector layer.
Valid values are: POLYGONS or ALL. If this parameter is unspecified, the centroid is generated by default for polygons only.
| Back to top |
Returns:
Type: PCI_INT
| Back to top |
CRCENTROID generates centroids from a vector layer or thematic raster layer.
For vector layers, CRCENTROID creates centroids for polygons only or for all shapes in the layer. If the shape is a point, the resulting centroid is the same as the point. If the shape is a line, the resulting centroid is a point at the center of the line (not necessarily on a vertex of the shape). The generated coordinates are of the same projection as the input polygon layer. The point layer has only one attribute, which is the shape ID of the shape from which the point is generated. The attributes of the source shape are joined or copied to the corresponding point in the point layer.
For thematic rasters, a point is generated for each attribute record. The centroid is contained in the biggest contiguous area. If you want a centroid for each contiguous area of pixels, use RAS2PNT.
| Back to top |
The following example creates a centroid layer in the output file based on thematic raster 2 in the combined1.pix file.
from pci.crcentroid import crcentroid
fili = "combined1.pix" # Input file name
filo = "output.pix"
dbvs = [] # Uses DBIC
dbic = [2] # Uses channel 2
srcattr = "" # Default is "COPY"
centroid = "" # Default is "Polygons"
crcentroid( fili, filo, dbvs, dbic, srcattr, centroid )
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.