Contour polygons¶
- detroit.contours()¶
For each threshold value, the contour generator constructs a GeoJSON MultiPolygon geometry object representing the area where the input values are greater than or equal to the threshold value. The geometry is in planar coordinates, where \((i + 0.5, j + 0.5)\) corresponds to element
i + j * nin the input values array.
- class detroit.contour.contours.Contours¶
For each threshold value, the contour generator constructs a GeoJSON MultiPolygon geometry object representing the area where the input values are greater than or equal to the threshold value. The geometry is in planar coordinates, where \((i + 0.5, j + 0.5)\) corresponds to element
i + j * nin the input values array.- __call__(values: list[float]) list[MultiPolygonGeoJSON]¶
Computes the contours for the given array of values, returning an array of GeoJSON MultiPolygon geometry objects.
- Parameters:
values (list[float]) – Input grid values which must be an array of length \(n \times m\) where \([n, m]\) is the contour generator’s size; furthermore, each
values[i + j * n]must represent the value at the position \((i, j)\).- Returns:
Geometry objects
- Return type:
list[GeoJSON]
- contour(values: list[float], value: float) MultiPolygonGeoJSON¶
Computes a single contour
- Parameters:
values (list[float]) – Input grid values which must be an array of length \(n \times m\) where \([n, m]\) is the contour generator’s size; furthermore, each
values[i + j * n]must represent the value at the position \((i, j)\).value (float) – Threshold value; the input values are greater than or equal to this value.
- Returns:
GeoJSON MultiPolygon geometry object
- Return type:
GeoJSON
- set_size(size: tuple[float, float]) Contours¶
Sets the size of the input values to the contour generator and returns itself.
- Parameters:
size (tuple[float, float]) – Size of the input values
- Returns:
Itself
- Return type:
- set_smooth(smooth: bool) Contours¶
Sets if contour polygons are smoothed using interpolatation and returns itself.
- Parameters:
smooth (bool) – Boolean value
- Returns:
Itself
- Return type:
- set_thresholds(thresholds: Callable[[list[float], ...], float | list[float]] | list[float] | float) Contours¶
Sets the threshold function to the contour generator and returns itself.
- Parameters:
thresholds (Callable[[list[float], ...], float | list[float]] | list[float] | float) – Threshold function or array or constant value; default
d3.threshold_sturges- Returns:
Itself
- Return type: