xagg — xagg 2.4 documentation

# xagg

A package to aggregate gridded data in `xarray` to polygons in `geopandas` using area-weighting from the relative area overlaps between pixels and polygons.

The simplest code run, involving raster data in an `xarray` Dataset `ds` and polygons in a `geopandas` GeoDataFrame `gpd`, is:

    import xagg as xa

    # Get overlap between pixels and polygons
    weightmap = xa.pixel_overlaps(ds,gdf)

    # Aggregate data in [ds] onto polygons
    aggregated = xa.aggregate(ds,weightmap)

`aggregated` can then be turned into an `xarray` Dataset, a `geopandas` GeoDataFrame, or directly exported to a CSV (for use in, e.g., STATA), NetCDF, or Shapefile.

Contents

- Intro
  - Overview
  - Use cases
    - Climate econometrics
- Installation
- Base run
  - Import
  - Aggregate
  - Convert
- Detailed code run
  - Intro
  - Calculating area weights between a raster grid and polygons
  - Aggregating gridded data to the polygons using the area weights (and other weights) calculated above
  - Converting aggregated data
  - Exporting aggregated data
    - Export to netCDF
    - Export to .csv
    - Export to shapefile
- User API
  - Core clases
  - Primary (wrapper) functions
  - Auxiliary functions
- Backend API
  - Core functions
  - Export functions

# Indices and tables

@ -29,4 +106,4 @@ Indices and tables * Module Index * Search Page