shape_metric
cellseg_gsontools.geometry.shape_metric(gdf, metrics, parallel=True, num_processes=-1, col_prefix=None, create_copy=True)
¶
Compute a set of shape metrics for every row of the gdf.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gdf |
GeoDataFrame
|
The input GeoDataFrame. |
required |
metrics |
Tuple[str, ...]
|
A Tuple/List of shape metrics. |
required |
parallel |
bool
|
Flag whether to use parallel apply operations when computing the diversities. |
True
|
num_processes |
int, default=-1
|
The number of processes to use when parallel=True. If -1, this will use all available cores. |
-1
|
col_prefix |
str
|
Prefix for the new column names. |
None
|
create_copy |
bool
|
Flag whether to create a copy of the input gdf or not. |
True
|
Note
Allowed shape metrics are:
area
major_axis_len
minor_axis_len
major_axis_angle
minor_axis_angle
compactness
circularity
convexity
solidity
elongation
eccentricity
fractal_dimension
sphericity
shape_index
rectangularity
squareness
equivalent_rectangular_index
Raises:
Type | Description |
---|---|
ValueError
|
If an illegal metric is given. |
Returns:
Type | Description |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: The input geodataframe with computed shape metric columns added. |
Examples:
Compute the eccentricity and solidity for each polygon in gdf.
>>> from cellseg_gsontools.geometry import shape_metric
>>> shape_metric(gdf, metrics=["eccentricity", "solidity"], parallel=True)
Source code in cellseg_gsontools/geometry/shape_metrics.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
|