From 783376bf74dce5b217b50ea48f7c21a13b3dd71d Mon Sep 17 00:00:00 2001 From: Matthew Hanson Date: Fri, 15 Jul 2016 00:27:58 -0400 Subject: [PATCH] initial commit --- .gitignore | 2 ++ .travis.yml | 24 ++++++++++++++++++++++++ README.md | 8 ++++++++ requirements.txt | 1 + satstats/__init__.py | 0 satstats/utils.py | 5 +++++ satstats/version.py | 1 + setup.py | 41 +++++++++++++++++++++++++++++++++++++++++ test/test_utils.py | 12 ++++++++++++ 9 files changed, 94 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 README.md create mode 100644 requirements.txt create mode 100644 satstats/__init__.py create mode 100644 satstats/utils.py create mode 100644 satstats/version.py create mode 100644 setup.py create mode 100644 test/test_utils.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f3d74a9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc +*~ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..de5d982 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +language: python + +python: +- '2.7' +- '3.5' + +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - libgdal1h + - gdal-bin + - libgdal-dev + +before_install: +- pip install -r requirements.txt +- pip install -r requirements-dev.txt + +install: +- pip install -e . + +script: +- nosetests -v -s diff --git a/README.md b/README.md new file mode 100644 index 0000000..434e5bb --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# sat-stats + +This utility library calculates zonal statistics on images being stored remotely on S3. Currently it uses the rasterstats package. + +This requires GDAL2, which allows direct GDAL reading in S3 buckets. + +For now, this is just calculating stats given an S3 key. However, the intention is that this could be a higher level library that uses sat-api and sat-search for calculating zonal stats on imagery stored on S3 file without downloading any data. + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..bf78e66 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +rasterstats==0.10.3 diff --git a/satstats/__init__.py b/satstats/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/satstats/utils.py b/satstats/utils.py new file mode 100644 index 0000000..aa2ccb4 --- /dev/null +++ b/satstats/utils.py @@ -0,0 +1,5 @@ +import rasterstats + +def get_stats(s3key, vectors): + """ Retrieve stats from image for vectors """ + pass diff --git a/satstats/version.py b/satstats/version.py new file mode 100644 index 0000000..b8023d8 --- /dev/null +++ b/satstats/version.py @@ -0,0 +1 @@ +__version__ = '0.0.1' diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..cb7536b --- /dev/null +++ b/setup.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +import os +from codecs import open +from setuptools import setup, find_packages +import imp + +here = os.path.abspath(os.path.dirname(__file__)) +__version__ = imp.load_source('satstats.version', 'satstats/version.py').__version__ + +# get the dependencies and installs +with open(os.path.join(here, 'requirements.txt'), encoding='utf-8') as f: + all_reqs = f.read().split('\n') + +install_requires = [x.strip() for x in all_reqs if 'git+' not in x] +dependency_links = [x.strip().replace('git+', '') for x in all_reqs if 'git+' not in x] + +setup( + name='sat-stats', + version=__version__, + author='Matthew Hanson (matthewhanson)', + description='Get zonal summary stats from images that are stored remotely, without downloading entire image' + url='https://github.com/sat-utils/sat-stats', + license='MIT', + classifiers=[ + 'Framework :: Pytest', + 'Topic :: Scientific/Engineering :: GIS', + 'Topic :: Scientific/Engineering', + 'Intended Audience :: Developers', + 'Intended Audience :: Science/Research', + 'License :: Freeware', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + ], + packages=find_packages(exclude=['docs', 'tests*']), + include_package_data=True, + install_requires=install_requires, + dependency_links=dependency_links, + tests_require=['nose'], +) diff --git a/test/test_utils.py b/test/test_utils.py new file mode 100644 index 0000000..5822a94 --- /dev/null +++ b/test/test_utils.py @@ -0,0 +1,12 @@ +import unittest +from satstats import utils + +def TestUtils(unittest.TestCase): + + s3key = '' + vectors = None + + def test_get_stats(self): + """ Get statistics for vector """ + stats = utils.get_stats(self.s3key, vectors) + self.assertTrue(stats is not None)