--- id: regionmask version: "0.13.0" license: MIT license_treatment: permissive maintenance: active --- # regionmask — create masks of geospatial regions for arbitrary grids License: permissive · Maintenance: active · Downloads: 177.3K/mo ## What it is and what it does regionmask is a Python package for creating spatial masks that map grid points in geospatial datasets to geographic regions. It solves the common problem in climate science and geospatial analysis of needing to aggregate gridded data (such as climate model output or reanalysis data) by region—countries, continents, or custom areas—by determining which region each grid point belongs to. The package generates masks in multiple formats (2D integer, 3D boolean, or 3D fractional) and handles edge cases like region boundaries and overlaps carefully. The package includes a library of predefined regions (countries, landmasks, and regions from scientific literature) and can also work with user-defined regions from shapefiles via geopandas, numpy arrays, or shapely geometries. It depends on geopandas, numpy, xarray, rasterio, shapely, pooch, and packaging to handle data I/O, spatial operations, and grid manipulation. It is actively maintained, supports modern Python versions, and carries no known security vulnerabilities. Use it for: - Compute regional climate averages from global model output by masking grid points to countries or continents. - Aggregate reanalysis data over custom geographic regions defined in scientific literature. - Generate land-sea masks or other binary spatial masks for filtering gridded datasets. - Create visualizations of predefined or custom regions overlaid on geospatial grids. - Build workflows that combine multiple region definitions (overlapping or non-overlapping) for multi-scale analysis. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. regionmask creates spatial masks for gridded data that identify which region each grid point belongs to, enabling regional aggregation of climate, reanalysis, and other geospatial datasets. Yes. regionmask is actively maintained, has no known vulnerabilities, installs with low friction, and is licensed permissively. It directly solves a common and specific need in climate and geospatial data workflows. Install it if you work with gridded data and need to aggregate or mask by geographic region. ## Install pip install regionmask uv add regionmask poetry add regionmask ## Installing regionmask Before you install: Low friction install with a wheel distribution. Active maintenance with recent commits and stable production status; supports current Python versions (3.10–3.13). License in practice: MIT license is permissive; you can use, modify, and distribute regionmask with minimal restrictions, making it suitable for both open and proprietary projects. Quickstart: import regionmask import xarray as xr # Load gridded data data = xr.open_dataset('climate_data.nc') # Create a mask for a predefined region mask = regionmask.defined_regions.countries.mask(data) Requires Python >= 3.10; rasterio may need system libraries (GDAL) depending on your environment. Verify before relying: - Whether predefined regions (countries, landmasks, literature regions) are current and comprehensive enough for typical use cases. - Performance characteristics when masking very large grids or many overlapping regions. - Availability and quality of shapefile support for custom region definitions beyond the built-in set. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 177.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags geospatial region masks, gridded data regional aggregation, climate model region masking, spatial region definition, geographic grid masking, country mask generation, reanalysis data regional averaging, geospatial, climate-data, gridded-data [View on SkillFed](https://skillfed.io/packages/regionmask) · [View on PyPI](https://pypi.org/project/regionmask/)