class_docstr: An abstract canvas representing the space in which to bin.
  
  Parameters
  ----------
  plot_width, plot_height : int, optional
      Width and height of the output aggregate in pixels.
  x_range, y_range : tuple, optional
      A tuple representing the bounds inclusive space ``[min, max]`` along
      the axis.
  x_axis_type, y_axis_type : str, optional
      The type of the axis. Valid options are ``'linear'`` [default], and
      ``'log'``.
class_docstr_tok: ["An","abstract","canvas","representing","the","space","in","which","to","bin",".","Parameters","--","--","--","--","--","plot_width",",","plot_height",":","int",",","optional","Width","and","height","of","the","output","aggregate","in","pixels",".","x_range",",","y_range",":","tuple",",","optional","A","tuple","representing","the","bounds","inclusive","space","``","[","min",",","max","]","``","along","the","axis",".","x_axis_type",",","y_axis_type",":","str",",","optional","The","type","of","the","axis",".","Valid","options","are","``","'linear","'","``","[","default","]",",","and","``","'log","'","``","."]
docstr: Compute a reduction by pixel, mapping data to pixels as one or
  more filled polygons.
  
  Parameters
  ----------
  source : xarray.DataArray or Dataset
      The input datasource.
  geometry : str
      Column name of a PolygonsArray of the coordinates of each line.
  agg : Reduction, optional
      Reduction to compute. Default is ``any()``.
  
  Returns
  -------
  data : xarray.DataArray
  
  Examples
  --------
  >>> import datashader as ds  # doctest: +SKIP
  ... import datashader.transfer_functions as tf
  ... from spatialpandas.geometry import PolygonArray
  ... from spatialpandas import GeoDataFrame
  ... import pandas as pd
  ...
  ... polygons = PolygonArray([
  ...     # First Element
  ...     [[0, 0, 1, 0, 2, 2, -1, 4, 0, 0],  # Filled quadrilateral (CCW order)
  ...      [0.5, 1,  1, 2,  1.5, 1.5,  0.5, 1],     # Triangular hole (CW order)
  ...      [0, 2, 0, 2.5, 0.5, 2.5, 0.5, 2, 0, 2],  # Rectangular hole (CW order)
  ...      [2.5, 3, 3.5, 3, 3.5, 4, 2.5, 3],  # Filled triangle
  ...     ],
  ...
  ...     # Second Element
  ...     [[3, 0, 3, 2, 4, 2, 4, 0, 3, 0],  # Filled rectangle (CCW order)
  ...      # Rectangular hole (CW order)
  ...      [3.25, 0.25, 3.75, 0.25, 3.75, 1.75, 3.25, 1.75, 3.25, 0.25],
  ...     ]
  ... ])
  ...
  ... df = GeoDataFrame({'polygons': polygons, 'v': range(len(polygons))})
  ...
  ... cvs = ds.Canvas()
  ... agg = cvs.polygons(df, geometry='polygons', agg=ds.sum('v'))
  ... tf.shade(agg)
docstr_tok: ["Compute","a","reduction","by","pixel",",","mapping","data","to","pixels","as","one","or","more","filled","polygons",".","Parameters","--","--","--","--","--","source",":","xarray.DataArray","or","Dataset","The","input","datasource",".","geometry",":","str","Column","name","of","a","PolygonsArray","of","the","coordinates","of","each","line",".","agg",":","Reduction",",","optional","Reduction","to","compute",".","Default","is","``","any","(",")","``",".","Returns","--","--","--","-","data",":","xarray.DataArray","Examples","--","--","--","--",">",">",">","import","datashader","as","ds","#","doctest",":","+SKIP","...","import","datashader.transfer_functions","as","tf","...","from","spatialpandas.geometry","import","PolygonArray","...","from","spatialpandas","import","GeoDataFrame","...","import","pandas","as","pd","...","...","polygons","=","PolygonArray","(","[","...","#","First","Element","...","[","[","0",",","0",",","1",",","0",",","2",",","2",",","-1",",","4",",","0",",","0","]",",","#","Filled","quadrilateral","(","CCW","order",")","...","[","0.5",",","1",",","1",",","2",",","1.5",",","1.5",",","0.5",",","1","]",",","#","Triangular","hole","(","CW","order",")","...","[","0",",","2",",","0",",","2.5",",","0.5",",","2.5",",","0.5",",","2",",","0",",","2","]",",","#","Rectangular","hole","(","CW","order",")","...","[","2.5",",","3",",","3.5",",","3",",","3.5",",","4",",","2.5",",","3","]",",","#","Filled","triangle","...","]",",","...","...","#","Second","Element","...","[","[","3",",","0",",","3",",","2",",","4",",","2",",","4",",","0",",","3",",","0","]",",","#","Filled","rectangle","(","CCW","order",")","...","#","Rectangular","hole","(","CW","order",")","...","[","3.25",",","0.25",",","3.75",",","0.25",",","3.75",",","1.75",",","3.25",",","1.75",",","3.25",",","0.25","]",",","...","]","...","]",")","...","...","df","=","GeoDataFrame","(","{","'polygons","'",":","polygons",",","'","v","'",":","range","(","len","(","polygons",")",")","}",")","...","...","cvs","=","ds.Canvas","(",")","...","agg","=","cvs.polygons","(","df",",","geometry='polygons","'",",","agg=ds.sum","(","'","v","'",")",")","...","tf.shade","(","agg",")"]
code: def polygons(self, source, geometry, agg=None):
      """Compute a reduction by pixel, mapping data to pixels as one or
      more filled polygons.
  
      Parameters
      ----------
      source : xarray.DataArray or Dataset
          The input datasource.
      geometry : str
          Column name of a PolygonsArray of the coordinates of each line.
      agg : Reduction, optional
          Reduction to compute. Default is ``any()``.
  
      Returns
      -------
      data : xarray.DataArray
  
      Examples
      --------
      >>> import datashader as ds  # doctest: +SKIP
      ... import datashader.transfer_functions as tf
      ... from spatialpandas.geometry import PolygonArray
      ... from spatialpandas import GeoDataFrame
      ... import pandas as pd
      ...
      ... polygons = PolygonArray([
      ...     # First Element
      ...     [[0, 0, 1, 0, 2, 2, -1, 4, 0, 0],  # Filled quadrilateral (CCW order)
      ...      [0.5, 1,  1, 2,  1.5, 1.5,  0.5, 1],     # Triangular hole (CW order)
      ...      [0, 2, 0, 2.5, 0.5, 2.5, 0.5, 2, 0, 2],  # Rectangular hole (CW order)
      ...      [2.5, 3, 3.5, 3, 3.5, 4, 2.5, 3],  # Filled triangle
      ...     ],
      ...
      ...     # Second Element
      ...     [[3, 0, 3, 2, 4, 2, 4, 0, 3, 0],  # Filled rectangle (CCW order)
      ...      # Rectangular hole (CW order)
      ...      [3.25, 0.25, 3.75, 0.25, 3.75, 1.75, 3.25, 1.75, 3.25, 0.25],
      ...     ]
      ... ])
      ...
      ... df = GeoDataFrame({'polygons': polygons, 'v': range(len(polygons))})
      ...
      ... cvs = ds.Canvas()
      ... agg = cvs.polygons(df, geometry='polygons', agg=ds.sum('v'))
      ... tf.shade(agg)
      """
      from .glyphs import PolygonGeom
      from .reductions import any as any_rdn
  
      if spatialpandas and isinstance(
          source, spatialpandas.dask.DaskGeoDataFrame
      ):
          # Downselect partitions to those that may contain polygons in viewport
          x_range = (
              self.x_range if self.x_range is not None else (None, None)
          )
          y_range = (
              self.y_range if self.y_range is not None else (None, None)
          )
          source = source.cx_partitions[
              slice(*x_range), slice(*y_range)
          ]
          glyph = PolygonGeom(geometry)
      elif spatialpandas and isinstance(
          source, spatialpandas.GeoDataFrame
      ):
          glyph = PolygonGeom(geometry)
      elif (
          geopandas_source := self._source_from_geopandas(source)
      ) is not None:
          source = geopandas_source
          from .glyphs.polygon import GeopandasPolygonGeom
  
          glyph = GeopandasPolygonGeom(geometry)
      else:
          raise ValueError(
              "source must be an instance of spatialpandas.GeoDataFrame, "
              "spatialpandas.dask.DaskGeoDataFrame, geopandas.GeoDataFrame or "
              f"dask_geopandas.GeoDataFrame, not {type(source)}"
          )
  
      if agg is None:
          agg = any_rdn()
      return bypixel(source, self, glyph, agg)
  
imports: from __future__ import annotations
  from numbers import Number
  from math import log10
  import warnings
  import numpy
  import pandas
  import dask.dataframe
  import dask.array
  from xarray import DataArray, Dataset
  from .utils import Dispatcher, ngjit, calc_res, calc_bbox, orient_array, dshape_from_xarray_dataset
  from .utils import get_indices, dshape_from_pandas, dshape_from_dask
  from .utils import Expr
  from .resampling import resample_2d, resample_2d_distributed
  from .None import reductions
label_desc: Use image node_id 5 for calling the Canvas obj's underlying member method code with example usage: obj.polygons(source, geometry, agg) and returns: bypixel