Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ env:
global:
- PIP_WHEEL_DIR=$HOME/.cache/pip/wheels
- PIP_FIND_LINKS=file://$HOME/.cache/pip/wheels
addons:
apt:
packages:
- libgdal1h
- gdal-bin
- libgdal-dev
python:
- 2.7
- 3.4
Expand All @@ -22,7 +16,7 @@ before_install:
- pip install -U pip setuptools --upgrade
- pip install wheel
install:
- pip install numpy>=1.9 Cython
- pip install numpy "rasterio>=1.0a12"
- pip install -r requirements_dev.txt
- pip install coveralls
- pip install -e .
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def run_tests(self):
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
"Topic :: Utilities",
'Topic :: Scientific/Engineering :: GIS',
],
Expand Down
2 changes: 1 addition & 1 deletion src/rasterstats/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.12.0"
__version__ = "0.12.1"
19 changes: 15 additions & 4 deletions src/rasterstats/main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
import numpy as np
import warnings

from affine import Affine
from shapely.geometry import shape
import numpy as np
import numpy.distutils.system_info as sysinfo
import warnings

from .io import read_features, Raster
from .utils import (rasterize_geom, get_percentile, check_stats,
remap_categories, key_assoc_val, boxify_points)
Expand Down Expand Up @@ -158,7 +161,8 @@ def gen_zonal_stats(
isnodata = (fsrc.array == fsrc.nodata)

# add nan mask (if necessary)
has_nan = (np.issubdtype(fsrc.array.dtype, float)
has_nan = (
np.issubdtype(fsrc.array.dtype, float)
and np.isnan(fsrc.array.min()))
if has_nan:
isnodata = (isnodata | np.isnan(fsrc.array))
Expand All @@ -169,6 +173,14 @@ def gen_zonal_stats(
fsrc.array,
mask=(isnodata | ~rv_array))

# If we're on 64 bit platform and the array is an integer type
# make sure we cast to 64 bit to avoid overflow.
# workaround for https://github.com/numpy/numpy/issues/8433
if sysinfo.platform_bits == 64 and \
masked.dtype != np.int64 and \
issubclass(masked.dtype.type, np.integer):
masked = masked.astype(np.int64)

# execute zone_func on masked zone ndarray
if zone_func is not None:
if not callable(zone_func):
Expand All @@ -188,7 +200,6 @@ def gen_zonal_stats(
pixel_count = dict(zip([np.asscalar(k) for k in keys],
[np.asscalar(c) for c in counts]))


if categorical:
feature_stats = dict(pixel_count)
if category_map:
Expand Down