exactextract.exact_extract ========================== .. py:module:: exactextract.exact_extract Functions --------- .. autoapisummary:: exactextract.exact_extract.exact_extract Module Contents --------------- .. py:function:: exact_extract(rast, vec, ops, *, weights=None, include_cols=None, include_geom=False, strategy: str = 'feature-sequential', max_cells_in_memory: int = 30000000, grid_compat_tol: float = 0.001, output: str = 'geojson', output_options: Optional[Mapping] = None, progress=False) Calculate zonal statistics. :param rast: One or a list of :py:class:`RasterSource` object(s) or filename(s) that can be opened by GDAL/rasterio/xarray. :param vec: A :py:class:`FeatureSource` or filename that can be opened by GDAL/fiona :param ops: A list of :py:class:`Operation` objects, or strings that can be used to construct them (e.g., ``"mean"``, ``"quantile(q=0.33)"``). Check out :doc:`Available operations ` for more information. :param weights: An optional :py:class:`RasterSource` or filename for weights to be used in weighted operations. :param include_cols: An optional list of columns from the input features to be included into the output. :param include_geom: Flag indicating whether the geometry should be copied from the input features into the output. :param strategy: Specifies the strategy to use when processing features. Detailed performance notes are available in :ref:`Performance - Processing strategies `. Must be set to one of: - ``"feature-sequential"`` (the default): iterate over the features in ``vec``, read the corresponding pixels from ``rast``/``weights``, and compute the summary operations. This offers predictable memory consumption but may be inefficient if the order of features in ``vec`` causes the same, relatively large raster blocks to be read and decompressed many times. - ``"raster-sequential"``: iterate over chunks of pixels in ``rast``, identify the intersecting features from ``vec``, and compute statistics. This performs better than ``strategy="feature-sequential"`` in some cases, but comes at a cost of higher memory usage. :param max_cells_in_memory: Indicates the maximum number of raster cells that should be loaded into memory at a given time. :param grid_compat_tol: require value and weight grids to align within ``grid_compat_tol`` times the smaller of the two grid resolutions :param output: An :py:class:`OutputWriter` or one of the following strings: - "geojson" (the default): return a list of GeoJSON-like features - "pandas": return a ``pandas.DataFrame`` or ``geopandas.GeoDataFrame``, depending on the value of ``include_geom`` - "gdal": write results to disk using GDAL/OGR as they are written. This option (with ``strategy="feature-sequential"``) avoids the need to maintain results for all features in memory at a single time, which may be significant for operations with large result sizes such as ``cell_id``, ``values``, etc. :param output_options: an optional dictionary of options passed to the :py:class:`writer.JSONWriter`, :py:class:`writer.PandasWriter`, or :py:class:`writer.GDALWriter`. :param progress: if `True`, a progress bar will be displayed. Alternatively, a function may be provided that will be called with the completion fraction and a status message.