Opened 7 years ago

Closed 5 years ago

# v.to.db compactness and fractal dimension

Reported by: Owned by: mmetz grass-dev@… normal 7.4.2 Vector 7.0.1 v.to.db, shape metrics All All

## Description

If several areas share the same category, v.to.db sums up area sizes and perimeters for all areas with the same category, but for compactness and fractal dimension, the values of the last area processed are used. Instead, for compactness and fractal dimension, area size and perimeter length should be summed up for each category and at the end compactness and fractal dimension should be calculated from the area size and perimeter length sums for each category value.

Further on, compactness aka shape index is normalized to the area size of the most compact shape (a circle), but fractal dimension is not. This normalization is also done by e.g. FRAGSTATS.

The formula for compactness is

```perimeter / (2.0 * sqrt(M_PI * area))
```

which is for given area size and perimeter length of an object the area size of a cirlce with the same perimeter divided by the area size of the object.

The formula for fractal dimension is

```2.0 * log(perimeter) / log(area)
```

but should be

```2.0 * log(perimeter / (2.0 * sqrt(M_PI)) / log(area)
```

which is for given area size and perimeter length of an object the log of the area size of a cirlce with the same perimeter divided by the log of the area size of the object.

Further on, there are problems with using the log() function because log(1) is 0. That means that for area sizes smaller than 1, growing towards 1, the result approaches -infinity and for areas larger than 1 and growing further, the result decreases from +infinity. Thus for area sizes equal 1, the result is undefined, it could be + or -infinity. Results can also be negative or positive, depending on whether perimeter and/or area size are < 1. These problems could be avoided by using log(1 + x) instead of log(x).

The fractal dimension is not only dependent of the shape (cirlce, square, star etc) but also on the size, e.g. larger squares have a smaller fractal dimension than smaller squares. This should be added to the manual to facilitate interpretation of the fractal dimension.

### comment:1 by martinl, 7 years ago

Milestone: 7.3.0 → 7.4.0

Milestone renamed

### comment:3 by neteler, 6 years ago

Milestone: 7.4.0 → 7.4.1

Ticket retargeted after milestone closed

### comment:4 by martinl, 6 years ago

What is status of this issue?

### comment:5 by neteler, 5 years ago

Milestone: 7.4.1 → 7.4.2

### comment:6 by mmetz, 5 years ago

Resolution: → fixed new → closed

In 72866:

v.to.db: fix compactness and fractal dimension (fixes #3102)

### comment:7 by neteler, 5 years ago

Resolution: fixed closed → reopened

(reopening the automatic closing, since milestone = 7.4.x)

### comment:8 by mmetz, 5 years ago

Resolution: → fixed reopened → closed

In 72869:

v.to.db: fix compactness and fractal dimension (fixes #3102, backport trunk r72866,8)

Note: See TracTickets for help on using tickets.