This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!
Project Description

A bit like the PostGIS ST_SummaryStats function for rasters on your filesystem. Mostly we’re just stringing together some awesome libraries:

Install

Activate your project virtual environment, and then:

pip install winston

If you just want to use the command-line features, you could:

pip install --user winston

Usage

You can either use Winston on the command-line or as a module.

Command-line

To see your options, simply:

winston --help

For example, to get stats for all WKTs in a text file for a given raster:

winston some_file.tif -f wkts.txt

or just for one point, including raster metadata:

winston /path/to/data/*.tif -w 'POINT (-4.483545 54.150744)' -m

Since we require rasterio, you can also use the rio command-line tool to inspect your rasters:

rio insp /path/to/geo.tif

Read more in the Rasterio docs.

Module

You can also use Winston in your code:

>>> import rasterio
>>> from winston.stats import summary
>>> from shapely.geometry import Point
>>> src = rasterio.open('/path/to/raster.tif')
>>> print summary(src)
Summary(count=37324800, sum=49041320.0, mean=5.8627439, min=0.0, max=10.0, std=2.2037256)
>>> print summary(src, bounds=(4, 6))
Summary(count=37324800, sum=9569182.0, mean=5.1044292, min=4.0, max=5.9999995, std=0.56939822)
>>> print summary(src, bounds=(4, 6), mean_only=True)
5.09
>>> print summary(src, Point(-2.36, 51.38).buffer(0.25))
Summary(count=169, sum=1229.4401, mean=8.9740152, min=8.3602285, max=9.4269724, std=0.24473859)

Exporting results is reasonably simple with tablib:

>>> import rasterio
>>> import tablib
>>> from winston.stats import summary
>>> from shapely.geometry import Point
>>> src = rasterio.open('/path/to/raster.tif')
>>> shapes = [Point(x, y).buffer(0.25) for x, y in zip(range(5), range(5, 0, -1))]
>>> summaries = [summary(src, shape) for shape in shapes]
>>> d = tablib.Dataset()
>>> d.dict = [s.__dict__ for s in summaries]
>>> print d.headers
['count', 'sum', 'mean', 'min', 'max', 'std']
>>> open('output.csv', 'w').write(d.csv)

History

0.3.0 (2016-12-19)

  • Updated CLI defaults to be more… sane
  • Remove data_count from summary results
  • Now accept a exclude_nodata_value to be consistent with PostGIS
  • Added some basic tests

0.2.3 (2016-10-13)

  • Invert default value of all_touched flag to be consistent with Rasterio
  • Added missing requirement (six) and reorganised requirements files

0.2.2 (2016-10-13)

  • Bugfix in namedtuple parameter ordering (oops!)

0.2.1 (2016-10-12)

  • Accept WKT strings as well as GeoJSON & Shapely geometries
  • Fix the processing of ‘no result’ summaries

0.2.0 (2016-10-12)

winston.stats.summary:

  • now accepts Shapely geometries as well as GeoJSON-like objects
  • we no longer round results to 3 decimal places
  • the stats are now returned as a namedtuple rather than a list

0.1.1 (2016-10-12)

  • Minor packaging fixes.

0.1.0 (2016-10-12)

  • First release on PyPI.
Release History

Release History

0.3.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
winston-0.3.0.tar.gz (8.8 kB) Copy SHA256 Checksum SHA256 Source Dec 19, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting