Giter Site home page Giter Site logo

buzzard's Introduction

buzzard

In a nutshell, buzzard reads and writes geospatial raster and vector data.



license CircleCI codecov FOSSA Status

Table of Contents

buzzard is

  • a python library
  • a gdal/ogr/osr wrapper
  • designed to hide all cumbersome operations while working with GIS files
  • designed for data science workflows
  • under active development (see TODO)
  • tested with pytest in python 2.7 and python 3.6

buzzard contains

  • a class to open/read/write/create GIS files: DataSource
  • classes to interact with opened files: RasterPhysical Vector
  • a toolbox class designed to locate a rectangle in both image space and geometry space: Footprint

Simple example

This example illustrates visualization of a raster based on polygons.

import buzzard as buzz
import numpy as np
import matplotlib.pyplot as plt

rgb_path = 'path/to/raster.file'
polygons_path = 'path/to/vector.file'

ds = buzz.DataSource()
ds.open_raster('rgb', rgb_path)
ds.open_vector('polygons', polygons_path)

# Iterate over the polygons as shapely objects
for poly in ds.polygons.iter_data(None):

    # Compute the Footprint bounding poly
    fp = ds.rgb.fp.intersection(poly)

    # Read rgb at `fp` to a numpy array
    rgb = ds.rgb.get_data(band=(1, 2, 3), fp=fp).astype('uint8')
    alpha = ds.rgb.get_data(band=4, fp=fp).astype('uint8')

    # Create a boolean mask as a numpy array from a shapely polygon
    mask = np.invert(fp.burn_polygons(poly))

    # Darken pixels outside of polygon, set nodata pixels to red
    rgb[mask] = (rgb[mask] * 0.5).astype(np.uint8)
    rgb[alpha == 0] = [255, 0, 0]

    plt.imshow(rgb)
    plt.show()

Advanced (and fun ๐Ÿ˜Š) examples

Additional examples can be found here: jupyter notebook.

Features

  • Raster and vector files opening
  • Raster and vector files reading to numpy.ndarray, shapely objects, geojson and raw coordinates
  • Raster and vector files writing from numpy.ndarray, shapely objects, geojson and raw coordinates
  • Raster and vector files creation
  • Powerful manipulations of raster windows
  • Spatial reference homogenization between opened files like a GIS software

Future features summary

  • Wheels with osgeo binaries included
  • Advanced spatial reference homogenization using gdal warping functions
  • More tools, syntaxes and algorithms to work with raster datasets that don't fit in memory
  • Strong support of non north-up / west-left footprints
  • Data visualization tools
  • Strong performance improvements
  • Floating point precision loss handling improvements

Dependencies

The following table lists dependencies along with the minimum version, their status for the project and the related license.

Library Version Last Mandatory License Comment
gdal >=2.1.3 2.2.2 Yes MIT/X Hard to install. Will be included in buzzard wheels
opencv-python >=3.1.0 3.3.0.10 Yes 3-clause BSD Easy to install with opencv-python wheels. Will be optional
shapely >=1.6.1 1.6.1 Yes 3-clause BSD
affine >=2.0.0 2.1.0 Yes 3-clause BSD
numpy >=1.13.0 1.13.1 Yes numpy
scipy >=0.19.1 0.19.1 Yes scipy
pint >=0.8.1 0.8.1 Yes 3-clause BSD
six >=1.11.0 1.11.0 Yes MIT
chainmap >=1.0.2 1.0.2 Yes Python 2.7 license Only for python <3.2
pytest >=3.2.2 3.2.2 No MIT Only for tests
attrdict >=2.0.0 2.0.0 Yes MIT
geopandas 0.3.0 No 3-clause BSD Future dependency. Will be optional

How to install

Package manager and pip

# Install GDAL
# Windows: http://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
# MacOS: brew install gdal && brew tap osgeo/osgeo4mac && brew tap --repair && brew install gdal2 && export PATH="/usr/local/opt/gdal2/bin:$PATH" && pip install 'gdal==2.1.3'
# Ubuntu: apt-get install python-gdal=2.1.3+dfsg-1~xenial2 libproj-dev libgdal-dev gdal-bin

# Install buzzard
pip install buzzard

Anaconda and pip

# Install Anaconda
# https://www.anaconda.com/download/

# Create env
conda create -n buzz python=3.6 gdal opencv scipy shapely -c 'conda-forge'

# Activate env
# Windows: activate buzz
# Linux, MacOS: source activate buzz

# Install buzzard
pip install buzzard

How to test

git clone https://github.com/airware/buzzard
pip install -r buzzard/requirements-dev.txt
pytest buzzard/buzzard/test

Documentation

Hosted soon, in the meantime

Contributions and feedback

Welcome to the buzzard project! We appreciate any contribution and feedback, your proposals and pull requests will be considered and responded to. For more information, see the CONTRIBUTING.md file.

Authors

See AUTHORS

License and Notice

See LICENSE and NOTICE.

FOSSA Status

Other pages


buzzard's People

Contributors

fossabot avatar hervenivon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.