geoviews.operation.resample module#
- geoviews.operation.resample.bounds_to_poly(bounds)[source]#
Constructs a shapely Polygon from the provided bounds tuple.
- Parameters:
- bounds
python:tuple Tuple representing the (left, bottom, right, top) coordinates
- bounds
- Returns:
- polygon
shapely.geometry.Polygon Shapely Polygon geometry of the bounds
- polygon
- 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:
- bounds
shapely.geometry.Polygon Polygon representing the area of the current viewport
- domain
shapely.geometry.Polygon Polygon representing the overall bounding region of the data
- levels
python:int Number of zoom levels to divide the domain into
- bounds
- Returns:
- zoom_level
python:int Integer zoom level
- 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:
OperationThis 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)Create and return an instance of this class.
Parameter Definitions
Parameters inherited from:
holoviews.core.operation.Operation: group, input_ranges, link_inputsdynamic = 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]#
Create and return an instance of this class.
This method returns an instance of the
ParameterizedFunctionclass, copying parameter values from any existing instance provided or initializing them with the specifiedparams.This method is useful for obtaining a persistent object representation of a
ParameterizedFunctionwithout triggering its execution (__call__).- Parameters:
- **params
python:dict Parameter values to initialize the instance with. If an existing instance is used, its parameters are copied and updated with the provided values.
- **params
- Returns:
ParameterizedFunctionAn instance of the class with the specified or inherited parameters.
References
See https://param.holoviz.org/user_guide/ParameterizedFunctions.html
Examples
Create an instance with default parameters:
>>> import param >>> class Scale(param.ParameterizedFunction): ... multiplier = param.Number(default=2, bounds=(0, 10), doc="The multiplier value.") ... >>> instance = Scale.instance() >>> instance.multiplier 2
Use the instance:
>>> instance(5) 10