geowrangler 0.5.1
🌏 A python package for wrangling geospatial datasets
License: MIT License
Requires Python: >=3.8
Keywords: nbdev jupyter notebook python

# Geowrangler


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

<img src="https://raw.githubusercontent.com/thinkingmachines/geowrangler/master/images/Geowrangler.svg" alt="Geowrangler logo" style="max-width: 245px;" />

### Overview

[![License:MIT](https://img.shields.io/github/license/thinkingmachines/geowrangler?style=flat-square.png)](https://github.com/thinkingmachines/geowrangler/blob/master/LICENSE)
[![Versions](https://img.shields.io/pypi/pyversions/geowrangler.svg?style=flat-square)](https://pypi.org/project/geowrangler/)
[![Docs](https://img.shields.io/badge/docs-passing-green?style=flat-square.png)](https://geowrangler.thinkingmachin.es)

**Geowrangler** is a Python package for geodata wrangling. It helps you
build data transformation workflows that have no out-of-the-box
solutions from other geospatial libraries.

We surveyed our past geospatial projects to extract these solutions for
our work and hope that these will be useful for others as well.

Our audience are researchers, analysts, and engineers delivering
geospatial projects.

We [welcome your comments, suggestions, bug reports, and code
contributions](https://github.com/thinkingmachines/geowrangler/discussions)
to make **Geowrangler** better.

[![](https://raw.githubusercontent.com/thinkingmachines/geowrangler/master/images/github.svg "View on github button")](https://github.com/thinkingmachines/geowrangler)

### Context

**Geowrangler** was borne out of our efforts to reduce the amount of
boilerplate code in wrangling geospatial data. It builds on top of
existing geospatial libraries such as geopandas, rasterio, rasterstats,
morecantile, and others. Our goals are centered on the following tasks:

- Extracting area of interest zonal statistics from vector and raster
  data
- Gridding areas of interest
- Validating geospatial datasets
- Downloading of publically available geospatial datasets (e.g., OSM,
  Ookla, and Nightlights)
- Other geospatial vector and raster data processing tasks

To make it easy to document, maintain, and extend the package, we opted
to maintain the source code, tests and documentation on Jupyter
notebooks. We use [nbdev](https://nbdev.fast.ai) to generate the Python
package and documentation from the notebooks. See this
[document](https://github.com/thinkingmachines/geowrangler/blob/master/DEVELOPMENT.md)
to learn more about our development workflow.

By doing this, we hope to make it easy for geospatial analysts,
scientists, and engineers to learn, explore, and extend this package for
their geospatial processing needs.

Aside from providing reference documentation for each module, we have
included extensive tutorials and use case examples in order to make it
easy to learn and use.

### Modules

- Grid Tile Generation
- Geometry Validation
- Vector Zonal Stats
- Raster Zonal Stats
- Area Zonal Stats
- Distance Zonal Stats
- Vector to Raster Mask
- Raster to Dataframe
- Raster Processing
- Demographic and Health Survey (DHS) Processing Utils
- Geofabrik (OSM) Data Download
- Ookla Data Download
- Night Lights
- Dataset Utils
- Tile Clustering
- Spatial Join Highest Intersection

*Check [this page for more details about our
Roadmap](https://github.com/orgs/thinkingmachines/projects/17).*

### Installation

    pip install geowrangler

### Exploring the Documentation

We develop the package modules alongside their documentation. Each page
comes with an *Open in Colab* button that will open the Jupyter notebook
in Colab for exploration (including this page).

Click on the *Open in Colab* button below to open this page as a Google
Colab notebook.

[![](https://colab.research.google.com/assets/colab-badge.svg "Open in Colab button")](https://colab.research.google.com/github/thinkingmachines/geowrangler/blob/master/notebooks/index.ipynb)

``` python
# view the source of a grid component
gdf = gpd.GeoDataFrame()
grid = geowrangler.grids.SquareGridGenerator(gdf, 1)
grid??
```

    Type:        SquareGridGenerator
    String form: <geowrangler.grids.SquareGridGenerator object>
    File:        ~/work/unicef-ai4d/geowrangler-1/geowrangler/grids.py
    Source:     
    class SquareGridGenerator:
        def __init__(
            self,
            cell_size: float,  # height and width of a square cell in meters
            grid_projection: str = "EPSG:3857",  # projection of grid output
            boundary: Union[SquareGridBoundary, List[float]] = None,  # original boundary
        ):
            self.cell_size = cell_size
            self.grid_projection = grid_projection
            self.boundary = boundary

#### Tutorials

- [Grids
  Generation](https://geowrangler.thinkingmachin.es/tutorial.grids.html)
- [Geometry
  Validation](https://geowrangler.thinkingmachin.es/tutorial.geometry_validation.html)
- [Vector Zonal
  Stats](https://geowrangler.thinkingmachin.es/tutorial.vector_zonal_stats.html)
- [Raster Zonal
  Stats](https://geowrangler.thinkingmachin.es/tutorial.raster_zonal_stats.html)
- [Area Zonal
  Stats](https://geowrangler.thinkingmachin.es/tutorial.area_zonal_stats.html)
- [Distance Zonal
  Stats](https://geowrangler.thinkingmachin.es/tutorial.distance_zonal_stats.html)
- [DHS Processing
  Utils](https://geowrangler.thinkingmachin.es/tutorial.dhs.html)
- [Dataset
  Downloads](https://geowrangler.thinkingmachin.es/tutorial.datasets.html)
- [Spatial Join Using Highest
  Intersection](https://geowrangler.thinkingmachin.es/tutorial.spatial_join_highest_intersection.html)
- [Tile
  Clustering](https://geowrangler.thinkingmachin.es/tutorial.tile_clustering.html)
- [Raster
  Processing](https://geowrangler.thinkingmachin.es/tutorial.raster_processing.html)
- [Raster to
  Dataframe](https://geowrangler.thinkingmachin.es/tutorial.raster_to_dataframe.html)

#### Reference

- [Grids Generation](https://geowrangler.thinkingmachin.es/grids.html)
- [Polygon Fill
  Algorithms](https://geowrangler.thinkingmachin.es/polygon_fill.html)
- [Geometry
  Validation](https://geowrangler.thinkingmachin.es/validation.html)
- [Vector Zonal
  Stats](https://geowrangler.thinkingmachin.es/vector_zonal_stats.html)
- [Raster Zonal
  Stats](https://geowrangler.thinkingmachin.es/raster_zonal_stats.html)
- [Area Zonal
  Stats](https://geowrangler.thinkingmachin.es/area_zonal_stats.html)
- [Distance Zonal
  Stats](https://geowrangler.thinkingmachin.es/distance_zonal_stats.html)
- [DHS Processing Utils](https://geowrangler.thinkingmachin.es/dhs.html)
- [Dataset Geofabrik
  (OSM)](https://geowrangler.thinkingmachin.es/datasets_geofabrik.html)
- [Dataset
  Ookla](https://geowrangler.thinkingmachin.es/datasets_ookla.html)

> [!NOTE]
>
> All the documentation pages (including the references) are executable
> Jupyter notebooks.