geoviews.operation.resample module#

geoviews.operation.resample.bounds_to_poly(bounds)[source]#

Constructs a shapely Polygon from the provided bounds tuple.

Parameters:
boundspython:tuple

Tuple representing the (left, bottom, right, top) coordinates

Returns:
polygonshapely.geometry.Polygon

Shapely Polygon geometry of the bounds

geoviews.operation.resample.compute_zoom_level(bounds, domain, levels)[source]#

Computes a zoom level given a bounds polygon, a polygon of the overall domain and the number of zoom levels to divide the data into.

Parameters:
boundsshapely.geometry.Polygon

Polygon representing the area of the current viewport

domainshapely.geometry.Polygon

Polygon representing the overall bounding region of the data

levelspython:int

Number of zoom levels to divide the domain into

Returns:
zoom_levelpython:int

Integer zoom level

geoviews.operation.resample.find_geom(geom, geoms)[source]#

Returns the index of a geometry in a list of geometries avoiding expensive equality checks of in operator.

class geoviews.operation.resample.resample_geometry(*, cache, clip, display_threshold, preserve_topology, tolerance_factor, x_range, y_range, zoom_levels, dynamic, group, input_ranges, link_inputs, streams, name)[source]#

Bases: Operation

This operation dynamically culls and resamples Path or Polygons elements based on the current zoom level. On first execution a RTree is created using the Sort-Tile-Recursive algorithm, which is used to query for geometries within the current viewport (defined by the x_range and y_range).

Any geometries returned by the RTree query are tested to ensure their area is over the display_threshold, expressed as a fraction of the current viewport area. Any remaining polygons are simplified using the Douglas-Peucker algorithm, which eliminates vertices while ensuring that the curve does not diverge from the original curve by more than the tolerance. The tolerance is expressed as a fraction of the square root of the area of the current viewport.

Once computed a simplified geometry is cached depending on the current zoom level. The number of valid zoom levels can be declared and are used to recursively subdivide the domain into smaller subregions.

If requested the geometries can also be clipped to the current viewport which avoids having to render vertices that are not visible.

Methods

instance(**params)

Return an instance of this class, copying parameters from any existing instance provided.

Parameter Definitions


Parameters inherited from:

holoviews.core.operation.Operation: group, input_ranges, link_inputs

dynamic = Boolean(default=True, label='Dynamic')

Enables dynamic processing by default.

streams = ClassSelector(class_=(<class 'dict'>, <class 'list'>), default=[<class 'holoviews.streams.RangeXY'>], label='Streams')

List or dictionary streams that are applied if dynamic=True, allowing for dynamic interaction with the plot.

cache = Boolean(default=True, label='Cache')

Whether to cache simplified geometries depending on the zoom level.

clip = Boolean(default=False, label='Clip')

Whether to disable the cache and clip polygons to current bounds.

display_threshold = Number(default=0.0001, inclusive_bounds=(True, True), label='Display threshold')

The fraction of the current viewport covered by a geometry before it is shown.

preserve_topology = Boolean(default=False, label='Preserve topology')

Whether to preserve topology between geometries. If disabled simplification can produce self-intersecting or otherwise invalid geometries but will be much faster.

tolerance_factor = Number(default=0.002, inclusive_bounds=(True, True), label='Tolerance factor')

The tolerance distance for path simplification as a fraction of the square root of the area of the current viewport.

x_range = NumericTuple(allow_None=True, label='X range', length=2)

The x_range as a tuple of min and max x-value. Auto-ranges if set to None.

y_range = NumericTuple(allow_None=True, label='Y range', length=2)

The x_range as a tuple of min and max y-value. Auto-ranges if set to None.

zoom_levels = Integer(default=20, inclusive_bounds=(True, True), label='Zoom levels')

The number of zoom levels to cache.

instance(**params)[source]#

Return an instance of this class, copying parameters from any existing instance provided.