Description
The DensityCalculator calculates the density of a candidate feature based on a set of reference features. It was initially created to be able to calculate the density of rivers and streams within a single river basin.
The actual calculation is the sum of the length/area/number of the individual candidate features, divided by the area of a single area feature.

Gotchas
One gotcha is that multiple area features are treated as a single area, unless you specifically use the group-by function to match them to their respective candidates.
Example
The attached workspace calculates the density of the transit network within each city grid for the City of Interopolis.
Source Data
The source data is a set of bus routes in FFS format (FME's own internal format) and a set of city grid features in ESRI E00 format.
Workspace Screenshot
The workspace to carry out this process is very simple:

Individual Steps
- Step 1 is to use the city grid outlines to clip the bus routes. There are many reasons:
- The routes would otherwise extend beyond the grid.
- The routes are not split at grid boundaries
- The routes are given the ID of each grid, so we can match them later with the group-by option
- Step 2 is to calculate the density of the bus routes per grid tile.
- The grid tiles are the Area features
- The clipped routes are the Candidates
- We calculate the density on the basis of bus route length (rather than number)
- A group-by is set to ensure each grid is matched to the correct routes (if we don't do this the result will be the same for each grid tile)

Above: The DensityCalculator settings. Note the group-by set to tile name, plus the calculation by line length
Output
The output looks like this.....

But the important part is the density attribute.


Above: The densest network has a value of 0.00682129660286487


Above: Its neighbor - to the right - has a less dense network and a value of 0.000757240972613154