/* Generated by Cython 0.20 on Mon Mar 31 10:48:50 2014 */

#define PY_SSIZE_T_CLEAN
#ifndef CYTHON_USE_PYLONG_INTERNALS
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 0
#else
#include "pyconfig.h"
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 1
#else
#define CYTHON_USE_PYLONG_INTERNALS 0
#endif
#endif
#endif
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02040000
    #error Cython requires Python 2.4+.
#else
#define CYTHON_ABI "0_20"
#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if CYTHON_COMPILING_IN_PYPY
#define Py_OptimizeFlag 0
#endif
#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define CYTHON_FORMAT_SSIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_As_int(o)
  #define PyNumber_Index(o)    ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
                                (PyErr_Format(PyExc_TypeError, \
                                              "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
                                 (PyObject*)0))
  #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \
                                  !PyComplex_Check(o))
  #define PyIndex_Check __Pyx_PyIndex_Check
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  #define __PYX_BUILD_PY_SSIZE_T "i"
#else
  #define __PYX_BUILD_PY_SSIZE_T "n"
  #define CYTHON_FORMAT_SSIZE_T "z"
  #define __Pyx_PyIndex_Check PyIndex_Check
#endif
#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)
  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;
  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
  #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
  typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
  typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
#endif
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyClass_Type
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #define __Pyx_DefaultClassType PyType_Type
#endif
#if PY_VERSION_HEX < 0x02060000
  #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
#endif
#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#if PY_VERSION_HEX < 0x02060000
  #define Py_TPFLAGS_HAVE_VERSION_TAG 0
#endif
#if PY_VERSION_HEX < 0x02060000 && !defined(Py_TPFLAGS_IS_ABSTRACT)
  #define Py_TPFLAGS_IS_ABSTRACT 0
#endif
#if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE)
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
#else
  #define CYTHON_PEP393_ENABLED 0
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
#define __Pyx_PyString_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#define __Pyx_PyUnicode_Concat(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
    PyNumber_Add(a, b) : PyUnicode_Concat(a, b))
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
#else
  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif
#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \
                                         PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
#endif
#if PY_VERSION_HEX < 0x02060000
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  #define PyNumber_Int                 PyNumber_Long
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_VERSION_HEX < 0x03020000
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif
#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif
#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
   a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
   a quiet NaN. */
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__rasterio___io
#define __PYX_HAVE_API__rasterio___io
#include "string.h"
#include "stdio.h"
#include "stdlib.h"
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#include "gdal.h"
#include "cpl_conv.h"
#include "cpl_string.h"
#include "ogr_srs_api.h"
#include "gdalwarper.h"
#include "gdal_alg.h"
#include "ogr_core.h"
#include "ogr_api.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif

#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (    \
    (sizeof(type) < sizeof(Py_ssize_t))  ||             \
    (sizeof(type) > sizeof(Py_ssize_t) &&               \
          likely(v < (type)PY_SSIZE_T_MAX ||            \
                 v == (type)PY_SSIZE_T_MAX)  &&         \
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||       \
                                v == (type)PY_SSIZE_T_MIN)))  ||  \
    (sizeof(type) == sizeof(Py_ssize_t) &&              \
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||        \
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromUString(s)  __Pyx_PyObject_FromString((char*)s)
#define __Pyx_PyBytes_FromUString(s)   __Pyx_PyBytes_FromString((char*)s)
#define __Pyx_PyByteArray_FromUString(s)   __Pyx_PyByteArray_FromString((char*)s)
#define __Pyx_PyStr_FromUString(s)     __Pyx_PyStr_FromString((char*)s)
#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s)
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
{
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return u_end - u - 1;
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys = NULL;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    sys = PyImport_ImportModule("sys");
    if (sys == NULL) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    if (default_encoding == NULL) goto bad;
    if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        const char* default_encoding_c = PyBytes_AS_STRING(default_encoding);
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (ascii_chars_u == NULL) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
    }
    Py_XDECREF(sys);
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return 0;
bad:
    Py_XDECREF(sys);
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
    PyObject* sys = NULL;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (sys == NULL) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    if (default_encoding == NULL) goto bad;
    default_encoding_c = PyBytes_AS_STRING(default_encoding);
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(sys);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(sys);
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


#ifdef __GNUC__
  /* Test for GCC > 2.95 */
  #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
    #define likely(x)   __builtin_expect(!!(x), 1)
    #define unlikely(x) __builtin_expect(!!(x), 0)
  #else /* __GNUC__ > 2 ... */
    #define likely(x)   (x)
    #define unlikely(x) (x)
  #endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */

static PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;

#if !defined(CYTHON_CCOMPLEX)
  #if defined(__cplusplus)
    #define CYTHON_CCOMPLEX 1
  #elif defined(_Complex_I)
    #define CYTHON_CCOMPLEX 1
  #else
    #define CYTHON_CCOMPLEX 0
  #endif
#endif
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #include <complex>
  #else
    #include <complex.h>
  #endif
#endif
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  #undef _Complex_I
  #define _Complex_I 1.0fj
#endif


static const char *__pyx_f[] = {
  "_io.pyx",
  "_io.pxd",
  "__init__.pxd",
  "type.pxd",
};
#define IS_UNSIGNED(type) (((type) -1) > 0)
struct __Pyx_StructField_;
#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
typedef struct {
  const char* name; /* for error messages only */
  struct __Pyx_StructField_* fields;
  size_t size;     /* sizeof(type) */
  size_t arraysize[8]; /* length of array in each dimension */
  int ndim;
  char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject, c_H_ar */
  char is_unsigned;
  int flags;
} __Pyx_TypeInfo;
typedef struct __Pyx_StructField_ {
  __Pyx_TypeInfo* type;
  const char* name;
  size_t offset;
} __Pyx_StructField;
typedef struct {
  __Pyx_StructField* field;
  size_t parent_offset;
} __Pyx_BufFmt_StackElem;
typedef struct {
  __Pyx_StructField root;
  __Pyx_BufFmt_StackElem* head;
  size_t fmt_offset;
  size_t new_count, enc_count;
  size_t struct_alignment;
  int is_complex;
  char enc_type;
  char new_packmode;
  char enc_packmode;
  char is_valid_array;
} __Pyx_BufFmt_Context;


/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":723
 * # in Cython to enable them only on the right systems.
 * 
 * ctypedef npy_int8       int8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 */
typedef npy_int8 __pyx_t_5numpy_int8_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":724
 * 
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t
 */
typedef npy_int16 __pyx_t_5numpy_int16_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":725
 * ctypedef npy_int8       int8_t
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_int64      int64_t
 * #ctypedef npy_int96      int96_t
 */
typedef npy_int32 __pyx_t_5numpy_int32_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":726
 * ctypedef npy_int16      int16_t
 * ctypedef npy_int32      int32_t
 * ctypedef npy_int64      int64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_int96      int96_t
 * #ctypedef npy_int128     int128_t
 */
typedef npy_int64 __pyx_t_5numpy_int64_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":730
 * #ctypedef npy_int128     int128_t
 * 
 * ctypedef npy_uint8      uint8_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 */
typedef npy_uint8 __pyx_t_5numpy_uint8_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":731
 * 
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t
 */
typedef npy_uint16 __pyx_t_5numpy_uint16_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":732
 * ctypedef npy_uint8      uint8_t
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uint64     uint64_t
 * #ctypedef npy_uint96     uint96_t
 */
typedef npy_uint32 __pyx_t_5numpy_uint32_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":733
 * ctypedef npy_uint16     uint16_t
 * ctypedef npy_uint32     uint32_t
 * ctypedef npy_uint64     uint64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_uint96     uint96_t
 * #ctypedef npy_uint128    uint128_t
 */
typedef npy_uint64 __pyx_t_5numpy_uint64_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":737
 * #ctypedef npy_uint128    uint128_t
 * 
 * ctypedef npy_float32    float32_t             # <<<<<<<<<<<<<<
 * ctypedef npy_float64    float64_t
 * #ctypedef npy_float80    float80_t
 */
typedef npy_float32 __pyx_t_5numpy_float32_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":738
 * 
 * ctypedef npy_float32    float32_t
 * ctypedef npy_float64    float64_t             # <<<<<<<<<<<<<<
 * #ctypedef npy_float80    float80_t
 * #ctypedef npy_float128   float128_t
 */
typedef npy_float64 __pyx_t_5numpy_float64_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":747
 * # The int types are mapped a bit surprising --
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t
 */
typedef npy_long __pyx_t_5numpy_int_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":748
 * # numpy.int corresponds to 'l' and numpy.long to 'q'
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longlong   longlong_t
 * 
 */
typedef npy_longlong __pyx_t_5numpy_long_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":749
 * ctypedef npy_long       int_t
 * ctypedef npy_longlong   long_t
 * ctypedef npy_longlong   longlong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_ulong      uint_t
 */
typedef npy_longlong __pyx_t_5numpy_longlong_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":751
 * ctypedef npy_longlong   longlong_t
 * 
 * ctypedef npy_ulong      uint_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t
 */
typedef npy_ulong __pyx_t_5numpy_uint_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":752
 * 
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t             # <<<<<<<<<<<<<<
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 */
typedef npy_ulonglong __pyx_t_5numpy_ulong_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":753
 * ctypedef npy_ulong      uint_t
 * ctypedef npy_ulonglong  ulong_t
 * ctypedef npy_ulonglong  ulonglong_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_intp       intp_t
 */
typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":755
 * ctypedef npy_ulonglong  ulonglong_t
 * 
 * ctypedef npy_intp       intp_t             # <<<<<<<<<<<<<<
 * ctypedef npy_uintp      uintp_t
 * 
 */
typedef npy_intp __pyx_t_5numpy_intp_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":756
 * 
 * ctypedef npy_intp       intp_t
 * ctypedef npy_uintp      uintp_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_double     float_t
 */
typedef npy_uintp __pyx_t_5numpy_uintp_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":758
 * ctypedef npy_uintp      uintp_t
 * 
 * ctypedef npy_double     float_t             # <<<<<<<<<<<<<<
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t
 */
typedef npy_double __pyx_t_5numpy_float_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":759
 * 
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t             # <<<<<<<<<<<<<<
 * ctypedef npy_longdouble longdouble_t
 * 
 */
typedef npy_double __pyx_t_5numpy_double_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":760
 * ctypedef npy_double     float_t
 * ctypedef npy_double     double_t
 * ctypedef npy_longdouble longdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cfloat      cfloat_t
 */
typedef npy_longdouble __pyx_t_5numpy_longdouble_t;

/* "_ogr.pxd":2
 * 
 * ctypedef int OGRErr             # <<<<<<<<<<<<<<
 * ctypedef struct OGREnvelope:
 *     double MinX
 */
typedef int __pyx_t_8rasterio_4_ogr_OGRErr;

/* "rasterio/_io.pxd":57
 *     cdef readonly object _options
 * 
 * ctypedef np.uint8_t DTYPE_UBYTE_t             # <<<<<<<<<<<<<<
 * ctypedef np.uint16_t DTYPE_UINT16_t
 * ctypedef np.int16_t DTYPE_INT16_t
 */
typedef __pyx_t_5numpy_uint8_t __pyx_t_8rasterio_3_io_DTYPE_UBYTE_t;

/* "rasterio/_io.pxd":58
 * 
 * ctypedef np.uint8_t DTYPE_UBYTE_t
 * ctypedef np.uint16_t DTYPE_UINT16_t             # <<<<<<<<<<<<<<
 * ctypedef np.int16_t DTYPE_INT16_t
 * ctypedef np.uint32_t DTYPE_UINT32_t
 */
typedef __pyx_t_5numpy_uint16_t __pyx_t_8rasterio_3_io_DTYPE_UINT16_t;

/* "rasterio/_io.pxd":59
 * ctypedef np.uint8_t DTYPE_UBYTE_t
 * ctypedef np.uint16_t DTYPE_UINT16_t
 * ctypedef np.int16_t DTYPE_INT16_t             # <<<<<<<<<<<<<<
 * ctypedef np.uint32_t DTYPE_UINT32_t
 * ctypedef np.int32_t DTYPE_INT32_t
 */
typedef __pyx_t_5numpy_int16_t __pyx_t_8rasterio_3_io_DTYPE_INT16_t;

/* "rasterio/_io.pxd":60
 * ctypedef np.uint16_t DTYPE_UINT16_t
 * ctypedef np.int16_t DTYPE_INT16_t
 * ctypedef np.uint32_t DTYPE_UINT32_t             # <<<<<<<<<<<<<<
 * ctypedef np.int32_t DTYPE_INT32_t
 * ctypedef np.float32_t DTYPE_FLOAT32_t
 */
typedef __pyx_t_5numpy_uint32_t __pyx_t_8rasterio_3_io_DTYPE_UINT32_t;

/* "rasterio/_io.pxd":61
 * ctypedef np.int16_t DTYPE_INT16_t
 * ctypedef np.uint32_t DTYPE_UINT32_t
 * ctypedef np.int32_t DTYPE_INT32_t             # <<<<<<<<<<<<<<
 * ctypedef np.float32_t DTYPE_FLOAT32_t
 * ctypedef np.float64_t DTYPE_FLOAT64_t
 */
typedef __pyx_t_5numpy_int32_t __pyx_t_8rasterio_3_io_DTYPE_INT32_t;

/* "rasterio/_io.pxd":62
 * ctypedef np.uint32_t DTYPE_UINT32_t
 * ctypedef np.int32_t DTYPE_INT32_t
 * ctypedef np.float32_t DTYPE_FLOAT32_t             # <<<<<<<<<<<<<<
 * ctypedef np.float64_t DTYPE_FLOAT64_t
 * 
 */
typedef __pyx_t_5numpy_float32_t __pyx_t_8rasterio_3_io_DTYPE_FLOAT32_t;

/* "rasterio/_io.pxd":63
 * ctypedef np.int32_t DTYPE_INT32_t
 * ctypedef np.float32_t DTYPE_FLOAT32_t
 * ctypedef np.float64_t DTYPE_FLOAT64_t             # <<<<<<<<<<<<<<
 * 
 * cdef int io_ubyte(
 */
typedef __pyx_t_5numpy_float64_t __pyx_t_8rasterio_3_io_DTYPE_FLOAT64_t;
#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< float > __pyx_t_float_complex;
  #else
    typedef float _Complex __pyx_t_float_complex;
  #endif
#else
    typedef struct { float real, imag; } __pyx_t_float_complex;
#endif

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    typedef ::std::complex< double > __pyx_t_double_complex;
  #else
    typedef double _Complex __pyx_t_double_complex;
  #endif
#else
    typedef struct { double real, imag; } __pyx_t_double_complex;
#endif


/*--- Type declarations ---*/
struct __pyx_obj_8rasterio_3_io_RasterReader;
struct __pyx_obj_8rasterio_3_io_RasterUpdater;
struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows;
struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index;
struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":762
 * ctypedef npy_longdouble longdouble_t
 * 
 * ctypedef npy_cfloat      cfloat_t             # <<<<<<<<<<<<<<
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t
 */
typedef npy_cfloat __pyx_t_5numpy_cfloat_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":763
 * 
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t             # <<<<<<<<<<<<<<
 * ctypedef npy_clongdouble clongdouble_t
 * 
 */
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":764
 * ctypedef npy_cfloat      cfloat_t
 * ctypedef npy_cdouble     cdouble_t
 * ctypedef npy_clongdouble clongdouble_t             # <<<<<<<<<<<<<<
 * 
 * ctypedef npy_cdouble     complex_t
 */
typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":766
 * ctypedef npy_clongdouble clongdouble_t
 * 
 * ctypedef npy_cdouble     complex_t             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 */
typedef npy_cdouble __pyx_t_5numpy_complex_t;
struct __pyx_t_8rasterio_4_ogr_OGREnvelope;
typedef struct __pyx_t_8rasterio_4_ogr_OGREnvelope __pyx_t_8rasterio_4_ogr_OGREnvelope;

/* "_ogr.pxd":3
 * 
 * ctypedef int OGRErr
 * ctypedef struct OGREnvelope:             # <<<<<<<<<<<<<<
 *     double MinX
 *     double MaxX
 */
struct __pyx_t_8rasterio_4_ogr_OGREnvelope {
  double MinX;
  double MaxX;
  double MinY;
  double MaxY;
};

/* "rasterio/_io.pxd":28
 *         GF_Write
 * 
 * cdef class RasterReader:             # <<<<<<<<<<<<<<
 *     # Read-only access to raster data and metadata.
 * 
 */
struct __pyx_obj_8rasterio_3_io_RasterReader {
  PyObject_HEAD
  struct __pyx_vtabstruct_8rasterio_3_io_RasterReader *__pyx_vtab;
  void *_hds;
  PyObject *name;
  PyObject *mode;
  PyObject *width;
  PyObject *height;
  PyObject *shape;
  PyObject *driver;
  PyObject *_count;
  PyObject *_dtypes;
  PyObject *_closed;
  PyObject *_crs;
  PyObject *_crs_wkt;
  PyObject *_transform;
  PyObject *_block_shapes;
  PyObject *_nodatavals;
  PyObject *_read;
  PyObject *env;
};


/* "rasterio/_io.pxd":51
 *     cdef void *band(self, int bidx)
 * 
 * cdef class RasterUpdater(RasterReader):             # <<<<<<<<<<<<<<
 *     # Read-write access to raster data and metadata.
 *     cdef readonly object _init_dtype
 */
struct __pyx_obj_8rasterio_3_io_RasterUpdater {
  struct __pyx_obj_8rasterio_3_io_RasterReader __pyx_base;
  PyObject *_init_dtype;
  PyObject *_init_nodata;
  PyObject *_options;
};


/* "rasterio/_io.pyx":386
 *         return self._nodatavals
 * 
 *     def block_windows(self, bdix):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over a band's block windows and their
 *         indexes.
 */
struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows {
  PyObject_HEAD
  PyObject *__pyx_v_bdix;
  PyObject *__pyx_v_col;
  PyObject *__pyx_v_d;
  PyObject *__pyx_v_h;
  PyObject *__pyx_v_height;
  int __pyx_v_i;
  int __pyx_v_j;
  PyObject *__pyx_v_m;
  PyObject *__pyx_v_ncols;
  PyObject *__pyx_v_nrows;
  PyObject *__pyx_v_row;
  struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self;
  PyObject *__pyx_v_w;
  PyObject *__pyx_v_width;
  long __pyx_t_0;
  int __pyx_t_1;
  long __pyx_t_2;
  int __pyx_t_3;
};


/* "rasterio/_io.pyx":153
 *     return b-a, d-c
 * 
 * def window_index(window):             # <<<<<<<<<<<<<<
 *     return tuple(slice(*w) for w in window)
 * 
 */
struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index {
  PyObject_HEAD
  PyObject *__pyx_v_window;
};


/* "rasterio/_io.pyx":154
 * 
 * def window_index(window):
 *     return tuple(slice(*w) for w in window)             # <<<<<<<<<<<<<<
 * 
 * 
 */
struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr {
  PyObject_HEAD
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index *__pyx_outer_scope;
  PyObject *__pyx_v_w;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};



/* "rasterio/_io.pyx":157
 * 
 * 
 * cdef class RasterReader:             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, path):
 */

struct __pyx_vtabstruct_8rasterio_3_io_RasterReader {
  void *(*band)(struct __pyx_obj_8rasterio_3_io_RasterReader *, int);
};
static struct __pyx_vtabstruct_8rasterio_3_io_RasterReader *__pyx_vtabptr_8rasterio_3_io_RasterReader;


/* "rasterio/_io.pyx":684
 *         return out
 * 
 * cdef class RasterUpdater(RasterReader):             # <<<<<<<<<<<<<<
 *     # Read-write access to raster data and metadata.
 *     # TODO: the r+ mode.
 */

struct __pyx_vtabstruct_8rasterio_3_io_RasterUpdater {
  struct __pyx_vtabstruct_8rasterio_3_io_RasterReader __pyx_base;
};
static struct __pyx_vtabstruct_8rasterio_3_io_RasterUpdater *__pyx_vtabptr_8rasterio_3_io_RasterUpdater;
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          if (acquire_gil) { \
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
              PyGILState_Release(__pyx_gilstate_save); \
          } else { \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext() \
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_XDECREF_SET(r, v) do {                            \
        PyObject *tmp = (PyObject *) r;                         \
        r = v; __Pyx_XDECREF(tmp);                              \
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {                             \
        PyObject *tmp = (PyObject *) r;                         \
        r = v; __Pyx_DECREF(tmp);                               \
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
    const char* function_name); /*proto*/

#ifndef CYTHON_PROFILE
  #define CYTHON_PROFILE 1
#endif
#ifndef CYTHON_TRACE
  #define CYTHON_TRACE 0
#endif
#if CYTHON_TRACE
  #undef CYTHON_PROFILE_REUSE_FRAME
#endif
#ifndef CYTHON_PROFILE_REUSE_FRAME
  #define CYTHON_PROFILE_REUSE_FRAME 0
#endif
#if CYTHON_PROFILE || CYTHON_TRACE
  #include "compile.h"
  #include "frameobject.h"
  #include "traceback.h"
  #if CYTHON_PROFILE_REUSE_FRAME
    #define CYTHON_FRAME_MODIFIER static
    #define CYTHON_FRAME_DEL
  #else
    #define CYTHON_FRAME_MODIFIER
    #define CYTHON_FRAME_DEL Py_CLEAR(__pyx_frame)
  #endif
  #define __Pyx_TraceDeclarations                                     \
  static PyCodeObject *__pyx_frame_code = NULL;                      \
  CYTHON_FRAME_MODIFIER PyFrameObject *__pyx_frame = NULL;           \
  int __Pyx_use_tracing = 0;
  #define __Pyx_TraceCall(funcname, srcfile, firstlineno)                            \
  if (unlikely(PyThreadState_GET()->use_tracing &&                                   \
          (PyThreadState_GET()->c_profilefunc || (CYTHON_TRACE && PyThreadState_GET()->c_tracefunc)))) {      \
      __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, funcname, srcfile, firstlineno);  \
  }
  #define __Pyx_TraceException()                                                           \
  if (unlikely(__Pyx_use_tracing) && PyThreadState_GET()->use_tracing &&                   \
          (PyThreadState_GET()->c_profilefunc || (CYTHON_TRACE && PyThreadState_GET()->c_tracefunc))) {  \
      PyThreadState* tstate = PyThreadState_GET();                                         \
      tstate->use_tracing = 0;                                                             \
      PyObject *exc_info = __Pyx_GetExceptionTuple();                                      \
      if (exc_info) {                                                                      \
          if (CYTHON_TRACE && tstate->c_tracefunc)                                         \
              tstate->c_tracefunc(                                                         \
                  tstate->c_traceobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);          \
          tstate->c_profilefunc(                                                           \
              tstate->c_profileobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);            \
          Py_DECREF(exc_info);                                                             \
      }                                                                                    \
      tstate->use_tracing = 1;                                                             \
  }
  #define __Pyx_TraceReturn(result)                                                  \
  if (unlikely(__Pyx_use_tracing) && PyThreadState_GET()->use_tracing) {             \
      PyThreadState* tstate = PyThreadState_GET();                                   \
      tstate->use_tracing = 0;                                                        \
      if (CYTHON_TRACE && tstate->c_tracefunc)                                       \
          tstate->c_tracefunc(                                                       \
              tstate->c_traceobj, __pyx_frame, PyTrace_RETURN, (PyObject*)result);  \
      if (tstate->c_profilefunc)                                                     \
          tstate->c_profilefunc(                                                     \
              tstate->c_profileobj, __pyx_frame, PyTrace_RETURN, (PyObject*)result);  \
      CYTHON_FRAME_DEL;                                                              \
      tstate->use_tracing = 1;                                                       \
  }
  static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno); /*proto*/
  static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, const char *funcname, const char *srcfile, int firstlineno); /*proto*/
#else
  #define __Pyx_TraceDeclarations
  #define __Pyx_TraceCall(funcname, srcfile, firstlineno)
  #define __Pyx_TraceException()
  #define __Pyx_TraceReturn(result)
#endif /* CYTHON_PROFILE */
#if CYTHON_TRACE
  #define __Pyx_TraceLine(lineno)                                                          \
  if (unlikely(__Pyx_use_tracing) && unlikely(PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_tracefunc)) {    \
      PyThreadState* tstate = PyThreadState_GET();                                         \
      __pyx_frame->f_lineno = lineno;                                                     \
      tstate->use_tracing = 0;                                                             \
      tstate->c_tracefunc(tstate->c_traceobj, __pyx_frame, PyTrace_LINE, NULL);           \
      tstate->use_tracing = 1;                                                             \
  }
#else
  #define __Pyx_TraceLine(lineno)
#endif

static CYTHON_INLINE int  __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
    __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);

static void __Pyx_RaiseBufferIndexError(int axis); /*proto*/

#define __Pyx_BufPtrCContig2d(type, buf, i0, s0, i1, s1) ((type)((char*)buf + i0 * s0) + i1)
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename,
                                  int full_traceback); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/

#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname);

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/

#include <string.h>

static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
         const char* cstring, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));

static double __Pyx__PyObject_AsDouble(PyObject* obj); /* proto */
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyObject_AsDouble(obj) \
(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) : \
 likely(PyInt_CheckExact(obj)) ? \
 PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
#else
#define __Pyx_PyObject_AsDouble(obj) \
((likely(PyFloat_CheckExact(obj))) ? \
 PyFloat_AS_DOUBLE(obj) : __Pyx__PyObject_AsDouble(obj))
#endif

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);

#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
    __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) : \
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) : \
               __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck);

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

static PyObject* __Pyx_PyObject_CallMethodTuple(PyObject* obj, PyObject* method_name, PyObject* args) {
    PyObject *method, *result = NULL;
    if (unlikely(!args)) return NULL;
    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
    if (unlikely(!method)) goto bad;
    result = PyObject_Call(method, args, NULL);
    Py_DECREF(method);
bad:
    Py_DECREF(args);
    return result;
}
#define __Pyx_PyObject_CallMethod3(obj, name, arg1, arg2, arg3) \
    __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(3, arg1, arg2, arg3))
#define __Pyx_PyObject_CallMethod2(obj, name, arg1, arg2) \
    __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(2, arg1, arg2))
#define __Pyx_PyObject_CallMethod1(obj, name, arg1) \
    __Pyx_PyObject_CallMethodTuple(obj, name, PyTuple_Pack(1, arg1))
#define __Pyx_PyObject_CallMethod0(obj, name) \
    __Pyx_PyObject_CallMethodTuple(obj, name, (Py_INCREF(__pyx_empty_tuple), __pyx_empty_tuple))

static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x); /*proto*/

#if PY_VERSION_HEX < 0x02050000
#ifndef PyAnySet_CheckExact
#define PyAnySet_CheckExact(ob) \
    ((ob)->ob_type == &PySet_Type || \
     (ob)->ob_type == &PyFrozenSet_Type)
#define PySet_New(iterable) \
    PyObject_CallFunctionObjArgs((PyObject *)&PySet_Type, (iterable), NULL)
#define Pyx_PyFrozenSet_New(iterable) \
    PyObject_CallFunctionObjArgs((PyObject *)&PyFrozenSet_Type, (iterable), NULL)
#define PySet_Size(anyset) \
    PyObject_Size((anyset))
#define PySet_Contains(anyset, key) \
    PySequence_Contains((anyset), (key))
#define PySet_Pop(set) \
    PyObject_CallMethod((set), (char*)"pop", NULL)
static CYTHON_INLINE int PySet_Clear(PyObject *set) {
    PyObject *ret = PyObject_CallMethod(set, (char*)"clear", NULL);
    if (!ret) return -1;
    Py_DECREF(ret); return 0;
}
static CYTHON_INLINE int PySet_Discard(PyObject *set, PyObject *key) {
    PyObject *ret = PyObject_CallMethod(set, (char*)"discard", (char*)"(O)", key);
    if (!ret) return -1;
    Py_DECREF(ret); return 0;
}
static CYTHON_INLINE int PySet_Add(PyObject *set, PyObject *key) {
    PyObject *ret = PyObject_CallMethod(set, (char*)"add", (char*)"(O)", key);
    if (!ret) return -1;
    Py_DECREF(ret); return 0;
}
#endif /* PyAnySet_CheckExact (<= Py2.4) */
#endif /* < Py2.5  */

static CYTHON_INLINE int __Pyx_PySequence_Contains(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/

#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

#if PY_MAJOR_VERSION < 3
#define __Pyx_PyString_Join __Pyx_PyBytes_Join
#define __Pyx_PyBaseString_Join(s, v) (PyUnicode_CheckExact(s) ? PyUnicode_Join(s, v) : __Pyx_PyBytes_Join(s, v))
#else
#define __Pyx_PyString_Join PyUnicode_Join
#define __Pyx_PyBaseString_Join PyUnicode_Join
#endif
#if CYTHON_COMPILING_IN_CPYTHON
    #if PY_MAJOR_VERSION < 3
    #define __Pyx_PyBytes_Join _PyString_Join
    #else
    #define __Pyx_PyBytes_Join _PyBytes_Join
    #endif
#else
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values); /*proto*/
#endif

static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /*proto*/

static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);

static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);

#define __Pyx_CyFunction_USED 1
#include <structmember.h>
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CyFunction_GetClosure(f) \
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#define __Pyx_CyFunction_GetClassObj(f) \
    (((__pyx_CyFunctionObject *) (f))->func_classobj)
#define __Pyx_CyFunction_Defaults(type, f) \
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g) \
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
    PyCFunctionObject func;
    int flags;
    PyObject *func_dict;
    PyObject *func_weakreflist;
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
    PyObject *func_classobj; /* No-args super() class cell */
    void *defaults;
    int defaults_pyobjects;
    PyObject *defaults_tuple;   /* Const defaults tuple */
    PyObject *defaults_kwdict;  /* Const kwonly defaults dict */
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations; /* function annotations dict */
} __pyx_CyFunctionObject;
static PyTypeObject *__pyx_CyFunctionType = 0;
#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code) \
    __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *self,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
                                                         size_t size,
                                                         int pyobjects);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
                                                             PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
                                                              PyObject *dict);
static int __Pyx_CyFunction_init(void);

static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
                                           PyObject *mkw, PyObject *modname, PyObject *doc); /*proto*/
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
                                      PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); /*proto*/

static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name); /*proto*/

typedef struct {
  Py_ssize_t shape, strides, suboffsets;
} __Pyx_Buf_DimInfo;
typedef struct {
  size_t refcount;
  Py_buffer pybuffer;
} __Pyx_Buffer;
typedef struct {
  __Pyx_Buffer *rcbuffer;
  char *data;
  __Pyx_Buf_DimInfo diminfo[8];
} __Pyx_LocalBuf_ND;

#if PY_MAJOR_VERSION < 3
    static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
    static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
    #define __Pyx_GetBuffer PyObject_GetBuffer
    #define __Pyx_ReleaseBuffer PyBuffer_Release
#endif


static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0};
static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1};

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/

static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);

static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_short(short value);

static CYTHON_INLINE short __Pyx_PyInt_As_short(PyObject *);

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    #define __Pyx_CREAL(z) ((z).real())
    #define __Pyx_CIMAG(z) ((z).imag())
  #else
    #define __Pyx_CREAL(z) (__real__(z))
    #define __Pyx_CIMAG(z) (__imag__(z))
  #endif
#else
    #define __Pyx_CREAL(z) ((z).real)
    #define __Pyx_CIMAG(z) ((z).imag)
#endif
#if (defined(_WIN32) || defined(__clang__)) && defined(__cplusplus) && CYTHON_CCOMPLEX
    #define __Pyx_SET_CREAL(z,x) ((z).real(x))
    #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
    #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
    #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif

static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);

#if CYTHON_CCOMPLEX
    #define __Pyx_c_eqf(a, b)   ((a)==(b))
    #define __Pyx_c_sumf(a, b)  ((a)+(b))
    #define __Pyx_c_difff(a, b) ((a)-(b))
    #define __Pyx_c_prodf(a, b) ((a)*(b))
    #define __Pyx_c_quotf(a, b) ((a)/(b))
    #define __Pyx_c_negf(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zerof(z) ((z)==(float)0)
    #define __Pyx_c_conjf(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_absf(z)     (::std::abs(z))
        #define __Pyx_c_powf(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zerof(z) ((z)==0)
    #define __Pyx_c_conjf(z)    (conjf(z))
    #if 1
        #define __Pyx_c_absf(z)     (cabsf(z))
        #define __Pyx_c_powf(a, b)  (cpowf(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex);
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex);
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex);
    #if 1
        static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex);
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex);
    #endif
#endif

static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);

#if CYTHON_CCOMPLEX
    #define __Pyx_c_eq(a, b)   ((a)==(b))
    #define __Pyx_c_sum(a, b)  ((a)+(b))
    #define __Pyx_c_diff(a, b) ((a)-(b))
    #define __Pyx_c_prod(a, b) ((a)*(b))
    #define __Pyx_c_quot(a, b) ((a)/(b))
    #define __Pyx_c_neg(a)     (-(a))
  #ifdef __cplusplus
    #define __Pyx_c_is_zero(z) ((z)==(double)0)
    #define __Pyx_c_conj(z)    (::std::conj(z))
    #if 1
        #define __Pyx_c_abs(z)     (::std::abs(z))
        #define __Pyx_c_pow(a, b)  (::std::pow(a, b))
    #endif
  #else
    #define __Pyx_c_is_zero(z) ((z)==0)
    #define __Pyx_c_conj(z)    (conj(z))
    #if 1
        #define __Pyx_c_abs(z)     (cabs(z))
        #define __Pyx_c_pow(a, b)  (cpow(a, b))
    #endif
 #endif
#else
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex);
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex);
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex);
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex);
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex);
    #endif
#endif

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

#define __Pyx_Generator_USED
#include <structmember.h>
#include <frameobject.h>
typedef PyObject *(*__pyx_generator_body_t)(PyObject *, PyObject *);
typedef struct {
    PyObject_HEAD
    __pyx_generator_body_t body;
    PyObject *closure;
    PyObject *exc_type;
    PyObject *exc_value;
    PyObject *exc_traceback;
    PyObject *gi_weakreflist;
    PyObject *classobj;
    PyObject *yieldfrom;
    int resume_label;
    char is_running;
} __pyx_GeneratorObject;
static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
                                                  PyObject *closure);
static int __pyx_Generator_init(void);
static int __Pyx_Generator_clear(PyObject* self);
#if 1 || PY_VERSION_HEX < 0x030300B0
static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue);
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue)
#endif

static int __Pyx_check_binary_version(void);

static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig); /*proto*/

#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

static PyObject *__Pyx_ImportModule(const char *name); /*proto*/

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);  /*proto*/

typedef struct {
    int code_line;
    PyCodeObject* code_object;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/


/* Module declarations from 'cpython.buffer' */

/* Module declarations from 'cpython.ref' */

/* Module declarations from 'libc.string' */

/* Module declarations from 'libc.stdio' */

/* Module declarations from 'cpython.object' */

/* Module declarations from '__builtin__' */

/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;

/* Module declarations from 'libc.stdlib' */

/* Module declarations from 'numpy' */

/* Module declarations from 'numpy' */
static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/

/* Module declarations from 'rasterio' */

/* Module declarations from 'rasterio._gdal' */

/* Module declarations from 'rasterio._ogr' */

/* Module declarations from 'rasterio._io' */
static PyTypeObject *__pyx_ptype_8rasterio_3_io_RasterReader = 0;
static PyTypeObject *__pyx_ptype_8rasterio_3_io_RasterUpdater = 0;
static PyTypeObject *__pyx_ptype_8rasterio_3_io___pyx_scope_struct_2_block_windows = 0;
static PyTypeObject *__pyx_ptype_8rasterio_3_io___pyx_scope_struct__window_index = 0;
static PyTypeObject *__pyx_ptype_8rasterio_3_io___pyx_scope_struct_1_genexpr = 0;
static int __pyx_f_8rasterio_3_io_io_ubyte(void *, int, int, int, int, int, PyArrayObject *); /*proto*/
static int __pyx_f_8rasterio_3_io_io_uint16(void *, int, int, int, int, int, PyArrayObject *); /*proto*/
static int __pyx_f_8rasterio_3_io_io_int16(void *, int, int, int, int, int, PyArrayObject *); /*proto*/
static int __pyx_f_8rasterio_3_io_io_uint32(void *, int, int, int, int, int, PyArrayObject *); /*proto*/
static int __pyx_f_8rasterio_3_io_io_int32(void *, int, int, int, int, int, PyArrayObject *); /*proto*/
static int __pyx_f_8rasterio_3_io_io_float32(void *, int, int, int, int, int, PyArrayObject *); /*proto*/
static int __pyx_f_8rasterio_3_io_io_float64(void *, int, int, int, int, int, PyArrayObject *); /*proto*/
static PyObject *__pyx_f_8rasterio_3_io_eval_window(PyObject *, int, int, int __pyx_skip_dispatch); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_UBYTE_t = { "DTYPE_UBYTE_t", NULL, sizeof(__pyx_t_8rasterio_3_io_DTYPE_UBYTE_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_8rasterio_3_io_DTYPE_UBYTE_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_8rasterio_3_io_DTYPE_UBYTE_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_UINT16_t = { "DTYPE_UINT16_t", NULL, sizeof(__pyx_t_8rasterio_3_io_DTYPE_UINT16_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_8rasterio_3_io_DTYPE_UINT16_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_8rasterio_3_io_DTYPE_UINT16_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_INT16_t = { "DTYPE_INT16_t", NULL, sizeof(__pyx_t_8rasterio_3_io_DTYPE_INT16_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_8rasterio_3_io_DTYPE_INT16_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_8rasterio_3_io_DTYPE_INT16_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_UINT32_t = { "DTYPE_UINT32_t", NULL, sizeof(__pyx_t_8rasterio_3_io_DTYPE_UINT32_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_8rasterio_3_io_DTYPE_UINT32_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_8rasterio_3_io_DTYPE_UINT32_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_INT32_t = { "DTYPE_INT32_t", NULL, sizeof(__pyx_t_8rasterio_3_io_DTYPE_INT32_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_8rasterio_3_io_DTYPE_INT32_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_8rasterio_3_io_DTYPE_INT32_t), 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_FLOAT32_t = { "DTYPE_FLOAT32_t", NULL, sizeof(__pyx_t_8rasterio_3_io_DTYPE_FLOAT32_t), { 0 }, 0, 'R', 0, 0 };
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_FLOAT64_t = { "DTYPE_FLOAT64_t", NULL, sizeof(__pyx_t_8rasterio_3_io_DTYPE_FLOAT64_t), { 0 }, 0, 'R', 0, 0 };
#define __Pyx_MODULE_NAME "rasterio._io"
int __pyx_module_is_main_rasterio___io = 0;

/* Implementation of 'rasterio._io' */
static PyObject *__pyx_builtin_property;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_hex;
static PyObject *__pyx_builtin_id;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_IndexError;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_pf_8rasterio_3_io_11NullHandler_emit(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_record); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_eval_window(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_window, int __pyx_v_height, int __pyx_v_width); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_2window_shape(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_window, PyObject *__pyx_v_height, PyObject *__pyx_v_width); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12window_index_genexpr(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_4window_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_window); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader___init__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_path); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_2__repr__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_4start(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_6read_crs(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_8read_crs_wkt(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_10read_transform(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_12stop(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_14close(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_16__enter__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_18__exit__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_type, CYTHON_UNUSED PyObject *__pyx_v_value, CYTHON_UNUSED PyObject *__pyx_v_traceback); /* proto */
static void __pyx_pf_8rasterio_3_io_12RasterReader_20__dealloc__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_22closed(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_24count(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_26indexes(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_28dtypes(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_30block_shapes(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_32nodatavals(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_34block_windows(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_bdix); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_37bounds(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_39res(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_41ul(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_row, PyObject *__pyx_v_col); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_43index(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_45meta(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_47get_crs(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_49get_crs_wkt(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_51get_transform(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_53read_band(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_bidx, PyObject *__pyx_v_out, PyObject *__pyx_v_window); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_55tags(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_bidx, PyObject *__pyx_v_ns); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_57colormap(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_bidx); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_59read_mask(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_out, PyObject *__pyx_v_window); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_4name___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_4mode___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_5width___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_6height___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_5shape___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_6driver___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_6driver_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_6driver_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_6_count___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_6_count_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_6_count_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_7_dtypes___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_7_dtypes_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_7_dtypes_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_7_closed___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_7_closed_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_7_closed_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_4_crs___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_4_crs_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_4_crs_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_8_crs_wkt___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_8_crs_wkt_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_8_crs_wkt_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_10_transform___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_10_transform_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_10_transform_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_13_block_shapes___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_13_block_shapes_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_13_block_shapes_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_11_nodatavals___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_11_nodatavals_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_11_nodatavals_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_5_read___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_5_read_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_8rasterio_3_io_12RasterReader_5_read_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self); /* proto */
static int __pyx_pf_8rasterio_3_io_13RasterUpdater___init__(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_path, PyObject *__pyx_v_mode, PyObject *__pyx_v_driver, PyObject *__pyx_v_width, PyObject *__pyx_v_height, PyObject *__pyx_v_count, PyObject *__pyx_v_crs, PyObject *__pyx_v_transform, PyObject *__pyx_v_dtype, PyObject *__pyx_v_nodata, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_2__repr__(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_4start(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_6get_crs(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_8write_crs(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_crs); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_10write_transform(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_transform); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_12get_transform(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_14write_band(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_bidx, PyObject *__pyx_v_src, PyObject *__pyx_v_window); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_16update_tags(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_bidx, PyObject *__pyx_v_ns, PyObject *__pyx_v_kwargs); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_18write_colormap(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_bidx, PyObject *__pyx_v_colormap); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_20write_mask(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_src, PyObject *__pyx_v_window); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_11_init_dtype___get__(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_12_init_nodata___get__(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_8_options___get__(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self); /* proto */
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
static PyObject *__pyx_tp_new_8rasterio_3_io_RasterReader(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_8rasterio_3_io_RasterUpdater(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_8rasterio_3_io___pyx_scope_struct_2_block_windows(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_8rasterio_3_io___pyx_scope_struct__window_index(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_8rasterio_3_io___pyx_scope_struct_1_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static char __pyx_k_B[] = "B";
static char __pyx_k_H[] = "H";
static char __pyx_k_I[] = "I";
static char __pyx_k_L[] = "L";
static char __pyx_k_O[] = "O";
static char __pyx_k_Q[] = "Q";
static char __pyx_k_a[] = "a";
static char __pyx_k_b[] = "b";
static char __pyx_k_c[] = "c";
static char __pyx_k_d[] = "d";
static char __pyx_k_f[] = "f";
static char __pyx_k_g[] = "g";
static char __pyx_k_h[] = "h";
static char __pyx_k_i[] = "i";
static char __pyx_k_l[] = "l";
static char __pyx_k_q[] = "q";
static char __pyx_k_r[] = "r";
static char __pyx_k_s[] = "+%s";
static char __pyx_k_w[] = "w";
static char __pyx_k_x[] = "x";
static char __pyx_k_y[] = "y";
static char __pyx_k_Zd[] = "Zd";
static char __pyx_k_Zf[] = "Zf";
static char __pyx_k_Zg[] = "Zg";
static char __pyx_k_id[] = "id";
static char __pyx_k_np[] = "np";
static char __pyx_k_ns[] = "ns";
static char __pyx_k_os[] = "os";
static char __pyx_k__11[] = "=";
static char __pyx_k__13[] = "+";
static char __pyx_k__53[] = " ";
static char __pyx_k_col[] = "col";
static char __pyx_k_crs[] = "crs";
static char __pyx_k_doc[] = "__doc__";
static char __pyx_k_get[] = "get";
static char __pyx_k_hex[] = "hex";
static char __pyx_k_log[] = "log";
static char __pyx_k_out[] = "out";
static char __pyx_k_r_2[] = "r+";
static char __pyx_k_res[] = "res";
static char __pyx_k_row[] = "row";
static char __pyx_k_s_s[] = "+%s=%s";
static char __pyx_k_src[] = "src";
static char __pyx_k_args[] = "args";
static char __pyx_k_bidx[] = "bidx";
static char __pyx_k_bool[] = "bool";
static char __pyx_k_emit[] = "emit";
static char __pyx_k_info[] = "info";
static char __pyx_k_join[] = "join";
static char __pyx_k_main[] = "__main__";
static char __pyx_k_math[] = "math";
static char __pyx_k_meta[] = "meta";
static char __pyx_k_mode[] = "mode";
static char __pyx_k_open[] = "open";
static char __pyx_k_path[] = "path";
static char __pyx_k_self[] = "self";
static char __pyx_k_send[] = "send";
static char __pyx_k_sqrt[] = "sqrt";
static char __pyx_k_stop[] = "stop";
static char __pyx_k_test[] = "__test__";
static char __pyx_k_type[] = "type";
static char __pyx_k_warn[] = "warn";
static char __pyx_k_GTiff[] = "GTiff";
static char __pyx_k_close[] = "close";
static char __pyx_k_count[] = "count";
static char __pyx_k_debug[] = "debug";
static char __pyx_k_dtype[] = "dtype";
static char __pyx_k_index[] = "index";
static char __pyx_k_int16[] = "int16";
static char __pyx_k_int32[] = "int32";
static char __pyx_k_items[] = "items";
static char __pyx_k_numpy[] = "numpy";
static char __pyx_k_range[] = "range";
static char __pyx_k_split[] = "split";
static char __pyx_k_start[] = "start";
static char __pyx_k_strip[] = "strip";
static char __pyx_k_throw[] = "throw";
static char __pyx_k_ubyte[] = "ubyte";
static char __pyx_k_uint8[] = "uint8";
static char __pyx_k_upper[] = "upper";
static char __pyx_k_utf_8[] = "utf-8";
static char __pyx_k_value[] = "value";
static char __pyx_k_width[] = "width";
static char __pyx_k_zeros[] = "zeros";
static char __pyx_k_append[] = "append";
static char __pyx_k_astype[] = "astype";
static char __pyx_k_bounds[] = "bounds";
static char __pyx_k_closed[] = "closed";
static char __pyx_k_driver[] = "driver";
static char __pyx_k_dtypes[] = "dtypes";
static char __pyx_k_encode[] = "encode";
static char __pyx_k_exists[] = "exists";
static char __pyx_k_height[] = "height";
static char __pyx_k_import[] = "__import__";
static char __pyx_k_lstrip[] = "lstrip";
static char __pyx_k_module[] = "__module__";
static char __pyx_k_nodata[] = "nodata";
static char __pyx_k_record[] = "record";
static char __pyx_k_uint16[] = "uint16";
static char __pyx_k_uint32[] = "uint32";
static char __pyx_k_unlink[] = "unlink";
static char __pyx_k_window[] = "window";
static char __pyx_k_GDALEnv[] = "GDALEnv";
static char __pyx_k_Handler[] = "Handler";
static char __pyx_k_crs_wkt[] = "crs_wkt";
static char __pyx_k_float32[] = "float32";
static char __pyx_k_float64[] = "float64";
static char __pyx_k_genexpr[] = "genexpr";
static char __pyx_k_get_crs[] = "get_crs";
static char __pyx_k_indexes[] = "indexes";
static char __pyx_k_logging[] = "logging";
static char __pyx_k_no_defs[] = "no_defs";
static char __pyx_k_os_path[] = "os.path";
static char __pyx_k_prepare[] = "__prepare__";
static char __pyx_k_Option_r[] = "Option: %r\n";
static char __pyx_k_Params_s[] = "Params: %s";
static char __pyx_k_colormap[] = "colormap";
static char __pyx_k_property[] = "property";
static char __pyx_k_qualname[] = "__qualname__";
static char __pyx_k_rasterio[] = "rasterio";
static char __pyx_k_read_crs[] = "read_crs";
static char __pyx_k_NULL_band[] = "NULL band";
static char __pyx_k_Null_band[] = "Null band";
static char __pyx_k_dtype_fwd[] = "dtype_fwd";
static char __pyx_k_dtype_rev[] = "dtype_rev";
static char __pyx_k_getLogger[] = "getLogger";
static char __pyx_k_metaclass[] = "__metaclass__";
static char __pyx_k_text_type[] = "text_type";
static char __pyx_k_traceback[] = "traceback";
static char __pyx_k_transform[] = "transform";
static char __pyx_k_write_crs[] = "write_crs";
static char __pyx_k_IndexError[] = "IndexError";
static char __pyx_k_ValueError[] = "ValueError";
static char __pyx_k_addHandler[] = "addHandler";
static char __pyx_k_nodatavals[] = "nodatavals";
static char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static char __pyx_k_NullHandler[] = "NullHandler";
static char __pyx_k_get_crs_wkt[] = "get_crs_wkt";
static char __pyx_k_NULL_dataset[] = "NULL dataset";
static char __pyx_k_Null_dataset[] = "Null dataset";
static char __pyx_k_RuntimeError[] = "RuntimeError";
static char __pyx_k_block_shapes[] = "block_shapes";
static char __pyx_k_driver_count[] = "driver_count";
static char __pyx_k_rasterio__io[] = "rasterio._io";
static char __pyx_k_read_crs_wkt[] = "read_crs_wkt";
static char __pyx_k_window_index[] = "window_index";
static char __pyx_k_window_shape[] = "window_shape";
static char __pyx_k_Color_d_d_d_d[] = "Color: (%d, %d, %d, %d)";
static char __pyx_k_Invalid_dtype[] = "Invalid dtype";
static char __pyx_k_get_transform[] = "get_transform";
static char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer";
static char __pyx_k_rasterio_five[] = "rasterio.five";
static char __pyx_k_NULL_band_mask[] = "NULL band mask";
static char __pyx_k_read_transform[] = "read_transform";
static char __pyx_k_Null_projection[] = "Null projection";
static char __pyx_k_invalid_width_d[] = "invalid width: %d";
static char __pyx_k_write_transform[] = "write_transform";
static char __pyx_k_NULL_color_table[] = "NULL color table";
static char __pyx_k_NullHandler_emit[] = "NullHandler.emit";
static char __pyx_k_invalid_height_d[] = "invalid height: %d";
static char __pyx_k_Created_mask_band[] = "Created mask band";
static char __pyx_k_NULL_driver_for_s[] = "NULL driver for %s";
static char __pyx_k_pyx_releasebuffer[] = "__pyx_releasebuffer";
static char __pyx_k_rasterio__drivers[] = "rasterio._drivers";
static char __pyx_k_Invalid_band_index[] = "Invalid band index";
static char __pyx_k_Unsupported_dtype_s[] = "Unsupported dtype: %s";
static char __pyx_k_Failed_to_create_mask[] = "Failed to create mask";
static char __pyx_k_Got_coordinate_system[] = "Got coordinate system";
static char __pyx_k_s_RasterReader_s_at_s[] = "<%s RasterReader '%s' at %s>";
static char __pyx_k_Invalid_colormap_key_d[] = "Invalid colormap key %d";
static char __pyx_k_Null_spatial_reference[] = "Null spatial reference";
static char __pyx_k_s_RasterUpdater_s_at_s[] = "<%s RasterUpdater '%s' at %s>";
static char __pyx_k_band_index_out_of_range[] = "band index out of range";
static char __pyx_k_NULL_color_at_d_skipping[] = "NULL color at %d, skipping";
static char __pyx_k_Unexpected_proj_parameter_s[] = "Unexpected proj parameter %s";
static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous";
static char __pyx_k_invalid_window_col_range_d_d[] = "invalid window: col range (%d, %d)";
static char __pyx_k_invalid_window_row_range_d_d[] = "invalid window: row range (%d, %d)";
static char __pyx_k_Can_t_read_closed_raster_file[] = "Can't read closed raster file";
static char __pyx_k_can_t_read_closed_raster_file[] = "can't read closed raster file";
static char __pyx_k_can_t_write_closed_raster_file[] = "can't write closed raster file";
static char __pyx_k_Users_seang_code_rasterio_raste[] = "/Users/seang/code/rasterio/rasterio/_io.pyx";
static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)";
static char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd";
static char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported";
static char __pyx_k_Projection_not_found_cogr_crs_wa[] = "Projection not found (cogr_crs was NULL)";
static char __pyx_k_Unexpected_NULL_spatial_referenc[] = "Unexpected NULL spatial reference";
static char __pyx_k_Unexpected_Null_spatial_referenc[] = "Unexpected Null spatial reference";
static char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous";
static char __pyx_k_only_GTiffs_can_be_opened_in_w_m[] = "only GTiffs can be opened in 'w' mode";
static char __pyx_k_the_array_s_dtype_s_does_not_mat[] = "the array's dtype '%s' does not match the file's dtype '%s'";
static char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short.";
static PyObject *__pyx_kp_s_Can_t_read_closed_raster_file;
static PyObject *__pyx_kp_s_Color_d_d_d_d;
static PyObject *__pyx_kp_s_Created_mask_band;
static PyObject *__pyx_kp_s_Failed_to_create_mask;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor;
static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2;
static PyObject *__pyx_n_s_GDALEnv;
static PyObject *__pyx_n_s_GTiff;
static PyObject *__pyx_kp_s_Got_coordinate_system;
static PyObject *__pyx_n_s_Handler;
static PyObject *__pyx_n_s_IndexError;
static PyObject *__pyx_kp_s_Invalid_band_index;
static PyObject *__pyx_kp_s_Invalid_colormap_key_d;
static PyObject *__pyx_kp_s_Invalid_dtype;
static PyObject *__pyx_kp_s_NULL_band;
static PyObject *__pyx_kp_s_NULL_band_mask;
static PyObject *__pyx_kp_s_NULL_color_at_d_skipping;
static PyObject *__pyx_kp_s_NULL_color_table;
static PyObject *__pyx_kp_s_NULL_dataset;
static PyObject *__pyx_kp_s_NULL_driver_for_s;
static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor;
static PyObject *__pyx_n_s_NullHandler;
static PyObject *__pyx_n_s_NullHandler_emit;
static PyObject *__pyx_kp_s_Null_band;
static PyObject *__pyx_kp_s_Null_dataset;
static PyObject *__pyx_kp_s_Null_projection;
static PyObject *__pyx_kp_s_Null_spatial_reference;
static PyObject *__pyx_kp_s_Option_r;
static PyObject *__pyx_kp_s_Params_s;
static PyObject *__pyx_kp_s_Projection_not_found_cogr_crs_wa;
static PyObject *__pyx_n_s_RuntimeError;
static PyObject *__pyx_kp_s_Unexpected_NULL_spatial_referenc;
static PyObject *__pyx_kp_s_Unexpected_Null_spatial_referenc;
static PyObject *__pyx_kp_s_Unexpected_proj_parameter_s;
static PyObject *__pyx_kp_s_Unsupported_dtype_s;
static PyObject *__pyx_kp_s_Users_seang_code_rasterio_raste;
static PyObject *__pyx_n_s_ValueError;
static PyObject *__pyx_kp_s__11;
static PyObject *__pyx_kp_s__13;
static PyObject *__pyx_kp_s__53;
static PyObject *__pyx_n_s_a;
static PyObject *__pyx_n_s_addHandler;
static PyObject *__pyx_n_s_append;
static PyObject *__pyx_n_s_args;
static PyObject *__pyx_n_s_astype;
static PyObject *__pyx_n_s_b;
static PyObject *__pyx_kp_s_band_index_out_of_range;
static PyObject *__pyx_n_s_bidx;
static PyObject *__pyx_n_s_block_shapes;
static PyObject *__pyx_n_s_bool;
static PyObject *__pyx_n_s_bounds;
static PyObject *__pyx_n_s_c;
static PyObject *__pyx_kp_s_can_t_read_closed_raster_file;
static PyObject *__pyx_kp_s_can_t_write_closed_raster_file;
static PyObject *__pyx_n_s_close;
static PyObject *__pyx_n_s_closed;
static PyObject *__pyx_n_s_col;
static PyObject *__pyx_n_s_colormap;
static PyObject *__pyx_n_s_count;
static PyObject *__pyx_n_s_crs;
static PyObject *__pyx_n_s_crs_wkt;
static PyObject *__pyx_n_s_d;
static PyObject *__pyx_n_s_debug;
static PyObject *__pyx_n_s_doc;
static PyObject *__pyx_n_s_driver;
static PyObject *__pyx_n_s_driver_count;
static PyObject *__pyx_n_s_dtype;
static PyObject *__pyx_n_s_dtype_fwd;
static PyObject *__pyx_n_s_dtype_rev;
static PyObject *__pyx_n_s_dtypes;
static PyObject *__pyx_n_s_emit;
static PyObject *__pyx_n_s_encode;
static PyObject *__pyx_n_s_exists;
static PyObject *__pyx_n_s_float32;
static PyObject *__pyx_n_s_float64;
static PyObject *__pyx_n_s_genexpr;
static PyObject *__pyx_n_s_get;
static PyObject *__pyx_n_s_getLogger;
static PyObject *__pyx_n_s_get_crs;
static PyObject *__pyx_n_s_get_crs_wkt;
static PyObject *__pyx_n_s_get_transform;
static PyObject *__pyx_n_s_height;
static PyObject *__pyx_n_s_hex;
static PyObject *__pyx_n_s_id;
static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_index;
static PyObject *__pyx_n_s_indexes;
static PyObject *__pyx_n_s_info;
static PyObject *__pyx_n_s_int16;
static PyObject *__pyx_n_s_int32;
static PyObject *__pyx_kp_s_invalid_height_d;
static PyObject *__pyx_kp_s_invalid_width_d;
static PyObject *__pyx_kp_s_invalid_window_col_range_d_d;
static PyObject *__pyx_kp_s_invalid_window_row_range_d_d;
static PyObject *__pyx_n_s_items;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_s_log;
static PyObject *__pyx_n_s_logging;
static PyObject *__pyx_n_s_lstrip;
static PyObject *__pyx_n_s_main;
static PyObject *__pyx_n_s_math;
static PyObject *__pyx_n_s_meta;
static PyObject *__pyx_n_s_metaclass;
static PyObject *__pyx_n_s_mode;
static PyObject *__pyx_n_s_module;
static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous;
static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou;
static PyObject *__pyx_n_s_no_defs;
static PyObject *__pyx_n_s_nodata;
static PyObject *__pyx_n_s_nodatavals;
static PyObject *__pyx_n_s_np;
static PyObject *__pyx_n_s_ns;
static PyObject *__pyx_n_s_numpy;
static PyObject *__pyx_kp_s_only_GTiffs_can_be_opened_in_w_m;
static PyObject *__pyx_n_s_open;
static PyObject *__pyx_n_s_os;
static PyObject *__pyx_n_s_os_path;
static PyObject *__pyx_n_s_out;
static PyObject *__pyx_n_s_path;
static PyObject *__pyx_n_s_prepare;
static PyObject *__pyx_n_s_property;
static PyObject *__pyx_n_s_pyx_getbuffer;
static PyObject *__pyx_n_s_pyx_releasebuffer;
static PyObject *__pyx_n_s_pyx_vtable;
static PyObject *__pyx_n_s_qualname;
static PyObject *__pyx_n_s_r;
static PyObject *__pyx_kp_s_r_2;
static PyObject *__pyx_n_s_range;
static PyObject *__pyx_n_s_rasterio;
static PyObject *__pyx_n_s_rasterio__drivers;
static PyObject *__pyx_n_s_rasterio__io;
static PyObject *__pyx_n_s_rasterio_five;
static PyObject *__pyx_n_s_read_crs;
static PyObject *__pyx_n_s_read_crs_wkt;
static PyObject *__pyx_n_s_read_transform;
static PyObject *__pyx_n_s_record;
static PyObject *__pyx_n_s_res;
static PyObject *__pyx_n_s_row;
static PyObject *__pyx_kp_s_s;
static PyObject *__pyx_kp_s_s_RasterReader_s_at_s;
static PyObject *__pyx_kp_s_s_RasterUpdater_s_at_s;
static PyObject *__pyx_kp_s_s_s;
static PyObject *__pyx_n_s_self;
static PyObject *__pyx_n_s_send;
static PyObject *__pyx_n_s_split;
static PyObject *__pyx_n_s_sqrt;
static PyObject *__pyx_n_s_src;
static PyObject *__pyx_n_s_start;
static PyObject *__pyx_n_s_stop;
static PyObject *__pyx_n_s_strip;
static PyObject *__pyx_n_s_test;
static PyObject *__pyx_n_s_text_type;
static PyObject *__pyx_kp_s_the_array_s_dtype_s_does_not_mat;
static PyObject *__pyx_n_s_throw;
static PyObject *__pyx_n_s_traceback;
static PyObject *__pyx_n_s_transform;
static PyObject *__pyx_n_s_type;
static PyObject *__pyx_n_s_ubyte;
static PyObject *__pyx_n_s_uint16;
static PyObject *__pyx_n_s_uint32;
static PyObject *__pyx_n_s_uint8;
static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd;
static PyObject *__pyx_n_s_unlink;
static PyObject *__pyx_n_s_upper;
static PyObject *__pyx_kp_s_utf_8;
static PyObject *__pyx_n_s_value;
static PyObject *__pyx_n_s_w;
static PyObject *__pyx_n_s_warn;
static PyObject *__pyx_n_s_width;
static PyObject *__pyx_n_s_window;
static PyObject *__pyx_n_s_window_index;
static PyObject *__pyx_n_s_window_shape;
static PyObject *__pyx_n_s_write_crs;
static PyObject *__pyx_n_s_write_transform;
static PyObject *__pyx_n_s_x;
static PyObject *__pyx_n_s_y;
static PyObject *__pyx_n_s_zeros;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_255;
static PyObject *__pyx_int_256;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_tuple_;
static PyObject *__pyx_tuple__2;
static PyObject *__pyx_tuple__3;
static PyObject *__pyx_tuple__4;
static PyObject *__pyx_tuple__5;
static PyObject *__pyx_tuple__6;
static PyObject *__pyx_tuple__7;
static PyObject *__pyx_tuple__8;
static PyObject *__pyx_tuple__9;
static PyObject *__pyx_tuple__10;
static PyObject *__pyx_tuple__12;
static PyObject *__pyx_tuple__14;
static PyObject *__pyx_tuple__15;
static PyObject *__pyx_tuple__16;
static PyObject *__pyx_tuple__17;
static PyObject *__pyx_tuple__18;
static PyObject *__pyx_tuple__19;
static PyObject *__pyx_tuple__20;
static PyObject *__pyx_tuple__21;
static PyObject *__pyx_tuple__22;
static PyObject *__pyx_tuple__23;
static PyObject *__pyx_tuple__24;
static PyObject *__pyx_tuple__25;
static PyObject *__pyx_tuple__26;
static PyObject *__pyx_tuple__27;
static PyObject *__pyx_tuple__28;
static PyObject *__pyx_tuple__29;
static PyObject *__pyx_tuple__30;
static PyObject *__pyx_tuple__31;
static PyObject *__pyx_tuple__32;
static PyObject *__pyx_tuple__33;
static PyObject *__pyx_tuple__34;
static PyObject *__pyx_tuple__35;
static PyObject *__pyx_tuple__36;
static PyObject *__pyx_tuple__37;
static PyObject *__pyx_tuple__38;
static PyObject *__pyx_tuple__39;
static PyObject *__pyx_tuple__40;
static PyObject *__pyx_tuple__41;
static PyObject *__pyx_tuple__42;
static PyObject *__pyx_tuple__43;
static PyObject *__pyx_tuple__44;
static PyObject *__pyx_tuple__45;
static PyObject *__pyx_tuple__46;
static PyObject *__pyx_tuple__47;
static PyObject *__pyx_tuple__48;
static PyObject *__pyx_tuple__49;
static PyObject *__pyx_tuple__50;
static PyObject *__pyx_tuple__51;
static PyObject *__pyx_tuple__52;
static PyObject *__pyx_tuple__54;
static PyObject *__pyx_tuple__55;
static PyObject *__pyx_tuple__56;
static PyObject *__pyx_tuple__57;
static PyObject *__pyx_tuple__58;
static PyObject *__pyx_tuple__59;
static PyObject *__pyx_tuple__60;
static PyObject *__pyx_tuple__61;
static PyObject *__pyx_tuple__62;
static PyObject *__pyx_tuple__63;
static PyObject *__pyx_tuple__64;
static PyObject *__pyx_tuple__65;
static PyObject *__pyx_tuple__66;
static PyObject *__pyx_tuple__67;
static PyObject *__pyx_tuple__68;
static PyObject *__pyx_tuple__69;
static PyObject *__pyx_tuple__70;
static PyObject *__pyx_tuple__71;
static PyObject *__pyx_tuple__72;
static PyObject *__pyx_tuple__73;
static PyObject *__pyx_tuple__74;
static PyObject *__pyx_tuple__75;
static PyObject *__pyx_tuple__76;
static PyObject *__pyx_tuple__77;
static PyObject *__pyx_tuple__78;
static PyObject *__pyx_tuple__79;
static PyObject *__pyx_tuple__80;
static PyObject *__pyx_tuple__81;
static PyObject *__pyx_tuple__83;
static PyObject *__pyx_tuple__85;
static PyObject *__pyx_codeobj__82;
static PyObject *__pyx_codeobj__84;
static PyObject *__pyx_codeobj__86;

/* "rasterio/_io.pyx":19
 * log = logging.getLogger('rasterio')
 * class NullHandler(logging.Handler):
 *     def emit(self, record):             # <<<<<<<<<<<<<<
 *         pass
 * log.addHandler(NullHandler())
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_11NullHandler_1emit(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_8rasterio_3_io_11NullHandler_1emit = {__Pyx_NAMESTR("emit"), (PyCFunction)__pyx_pw_8rasterio_3_io_11NullHandler_1emit, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_8rasterio_3_io_11NullHandler_1emit(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  CYTHON_UNUSED PyObject *__pyx_v_record = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("emit (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_record,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_record)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("emit", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "emit") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_self = values[0];
    __pyx_v_record = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("emit", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("rasterio._io.NullHandler.emit", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_11NullHandler_emit(__pyx_self, __pyx_v_self, __pyx_v_record);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_11NullHandler_emit(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_record) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("emit", 0);
  __Pyx_TraceCall("emit", __pyx_f[0], 19);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":23
 * log.addHandler(NullHandler())
 * 
 * cdef int io_ubyte(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

static int __pyx_f_8rasterio_3_io_io_ubyte(void *__pyx_v_hband, int __pyx_v_mode, int __pyx_v_xoff, int __pyx_v_yoff, int __pyx_v_width, int __pyx_v_height, PyArrayObject *__pyx_v_buffer) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_buffer;
  __Pyx_Buffer __pyx_pybuffer_buffer;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  long __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("io_ubyte", 0);
  __Pyx_TraceCall("io_ubyte", __pyx_f[0], 23);
  __pyx_pybuffer_buffer.pybuffer.buf = NULL;
  __pyx_pybuffer_buffer.refcount = 0;
  __pyx_pybuffernd_buffer.data = NULL;
  __pyx_pybuffernd_buffer.rcbuffer = &__pyx_pybuffer_buffer;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer, (PyObject*)__pyx_v_buffer, &__Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_UBYTE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_buffer.diminfo[0].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_buffer.diminfo[0].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_buffer.diminfo[1].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_buffer.diminfo[1].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[1];

  /* "rasterio/_io.pyx":33
 *     return _gdal.GDALRasterIO(
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 1, 0, 0)             # <<<<<<<<<<<<<<
 * 
 * cdef int io_uint16(
 */
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = -1;
  if (__pyx_t_1 < 0) {
    __pyx_t_1 += __pyx_pybuffernd_buffer.diminfo[0].shape;
    if (unlikely(__pyx_t_1 < 0)) __pyx_t_3 = 0;
  } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_buffer.diminfo[0].shape)) __pyx_t_3 = 0;
  if (__pyx_t_2 < 0) {
    __pyx_t_2 += __pyx_pybuffernd_buffer.diminfo[1].shape;
    if (unlikely(__pyx_t_2 < 0)) __pyx_t_3 = 1;
  } else if (unlikely(__pyx_t_2 >= __pyx_pybuffernd_buffer.diminfo[1].shape)) __pyx_t_3 = 1;
  if (unlikely(__pyx_t_3 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_3);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":31
 *         int height,
 *         np.ndarray[DTYPE_UBYTE_t, ndim=2, mode='c'] buffer):
 *     return _gdal.GDALRasterIO(             # <<<<<<<<<<<<<<
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 1, 0, 0)
 */
  __pyx_r = GDALRasterIO(__pyx_v_hband, __pyx_v_mode, __pyx_v_xoff, __pyx_v_yoff, __pyx_v_width, __pyx_v_height, (&(*__Pyx_BufPtrCContig2d(__pyx_t_8rasterio_3_io_DTYPE_UBYTE_t *, __pyx_pybuffernd_buffer.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_buffer.diminfo[0].strides, __pyx_t_2, __pyx_pybuffernd_buffer.diminfo[1].strides))), (__pyx_v_buffer->dimensions[1]), (__pyx_v_buffer->dimensions[0]), 1, 0, 0);
  goto __pyx_L0;

  /* "rasterio/_io.pyx":23
 * log.addHandler(NullHandler())
 * 
 * cdef int io_ubyte(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

  /* function exit code */
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_WriteUnraisable("rasterio._io.io_ubyte", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":35
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 1, 0, 0)
 * 
 * cdef int io_uint16(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

static int __pyx_f_8rasterio_3_io_io_uint16(void *__pyx_v_hband, int __pyx_v_mode, int __pyx_v_xoff, int __pyx_v_yoff, int __pyx_v_width, int __pyx_v_height, PyArrayObject *__pyx_v_buffer) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_buffer;
  __Pyx_Buffer __pyx_pybuffer_buffer;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  long __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("io_uint16", 0);
  __Pyx_TraceCall("io_uint16", __pyx_f[0], 35);
  __pyx_pybuffer_buffer.pybuffer.buf = NULL;
  __pyx_pybuffer_buffer.refcount = 0;
  __pyx_pybuffernd_buffer.data = NULL;
  __pyx_pybuffernd_buffer.rcbuffer = &__pyx_pybuffer_buffer;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer, (PyObject*)__pyx_v_buffer, &__Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_UINT16_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_buffer.diminfo[0].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_buffer.diminfo[0].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_buffer.diminfo[1].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_buffer.diminfo[1].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[1];

  /* "rasterio/_io.pyx":45
 *     return _gdal.GDALRasterIO(
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 2, 0, 0)             # <<<<<<<<<<<<<<
 * 
 * cdef int io_int16(
 */
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = -1;
  if (__pyx_t_1 < 0) {
    __pyx_t_1 += __pyx_pybuffernd_buffer.diminfo[0].shape;
    if (unlikely(__pyx_t_1 < 0)) __pyx_t_3 = 0;
  } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_buffer.diminfo[0].shape)) __pyx_t_3 = 0;
  if (__pyx_t_2 < 0) {
    __pyx_t_2 += __pyx_pybuffernd_buffer.diminfo[1].shape;
    if (unlikely(__pyx_t_2 < 0)) __pyx_t_3 = 1;
  } else if (unlikely(__pyx_t_2 >= __pyx_pybuffernd_buffer.diminfo[1].shape)) __pyx_t_3 = 1;
  if (unlikely(__pyx_t_3 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_3);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":43
 *         int height,
 *         np.ndarray[DTYPE_UINT16_t, ndim=2, mode='c'] buffer):
 *     return _gdal.GDALRasterIO(             # <<<<<<<<<<<<<<
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 2, 0, 0)
 */
  __pyx_r = GDALRasterIO(__pyx_v_hband, __pyx_v_mode, __pyx_v_xoff, __pyx_v_yoff, __pyx_v_width, __pyx_v_height, (&(*__Pyx_BufPtrCContig2d(__pyx_t_8rasterio_3_io_DTYPE_UINT16_t *, __pyx_pybuffernd_buffer.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_buffer.diminfo[0].strides, __pyx_t_2, __pyx_pybuffernd_buffer.diminfo[1].strides))), (__pyx_v_buffer->dimensions[1]), (__pyx_v_buffer->dimensions[0]), 2, 0, 0);
  goto __pyx_L0;

  /* "rasterio/_io.pyx":35
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 1, 0, 0)
 * 
 * cdef int io_uint16(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

  /* function exit code */
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_WriteUnraisable("rasterio._io.io_uint16", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":47
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 2, 0, 0)
 * 
 * cdef int io_int16(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

static int __pyx_f_8rasterio_3_io_io_int16(void *__pyx_v_hband, int __pyx_v_mode, int __pyx_v_xoff, int __pyx_v_yoff, int __pyx_v_width, int __pyx_v_height, PyArrayObject *__pyx_v_buffer) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_buffer;
  __Pyx_Buffer __pyx_pybuffer_buffer;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  long __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("io_int16", 0);
  __Pyx_TraceCall("io_int16", __pyx_f[0], 47);
  __pyx_pybuffer_buffer.pybuffer.buf = NULL;
  __pyx_pybuffer_buffer.refcount = 0;
  __pyx_pybuffernd_buffer.data = NULL;
  __pyx_pybuffernd_buffer.rcbuffer = &__pyx_pybuffer_buffer;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer, (PyObject*)__pyx_v_buffer, &__Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_INT16_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_buffer.diminfo[0].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_buffer.diminfo[0].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_buffer.diminfo[1].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_buffer.diminfo[1].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[1];

  /* "rasterio/_io.pyx":57
 *     return _gdal.GDALRasterIO(
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 3, 0, 0)             # <<<<<<<<<<<<<<
 * 
 * cdef int io_uint32(
 */
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = -1;
  if (__pyx_t_1 < 0) {
    __pyx_t_1 += __pyx_pybuffernd_buffer.diminfo[0].shape;
    if (unlikely(__pyx_t_1 < 0)) __pyx_t_3 = 0;
  } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_buffer.diminfo[0].shape)) __pyx_t_3 = 0;
  if (__pyx_t_2 < 0) {
    __pyx_t_2 += __pyx_pybuffernd_buffer.diminfo[1].shape;
    if (unlikely(__pyx_t_2 < 0)) __pyx_t_3 = 1;
  } else if (unlikely(__pyx_t_2 >= __pyx_pybuffernd_buffer.diminfo[1].shape)) __pyx_t_3 = 1;
  if (unlikely(__pyx_t_3 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_3);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":55
 *         int height,
 *         np.ndarray[DTYPE_INT16_t, ndim=2, mode='c'] buffer):
 *     return _gdal.GDALRasterIO(             # <<<<<<<<<<<<<<
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 3, 0, 0)
 */
  __pyx_r = GDALRasterIO(__pyx_v_hband, __pyx_v_mode, __pyx_v_xoff, __pyx_v_yoff, __pyx_v_width, __pyx_v_height, (&(*__Pyx_BufPtrCContig2d(__pyx_t_8rasterio_3_io_DTYPE_INT16_t *, __pyx_pybuffernd_buffer.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_buffer.diminfo[0].strides, __pyx_t_2, __pyx_pybuffernd_buffer.diminfo[1].strides))), (__pyx_v_buffer->dimensions[1]), (__pyx_v_buffer->dimensions[0]), 3, 0, 0);
  goto __pyx_L0;

  /* "rasterio/_io.pyx":47
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 2, 0, 0)
 * 
 * cdef int io_int16(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

  /* function exit code */
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_WriteUnraisable("rasterio._io.io_int16", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":59
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 3, 0, 0)
 * 
 * cdef int io_uint32(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

static int __pyx_f_8rasterio_3_io_io_uint32(void *__pyx_v_hband, int __pyx_v_mode, int __pyx_v_xoff, int __pyx_v_yoff, int __pyx_v_width, int __pyx_v_height, PyArrayObject *__pyx_v_buffer) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_buffer;
  __Pyx_Buffer __pyx_pybuffer_buffer;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  long __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("io_uint32", 0);
  __Pyx_TraceCall("io_uint32", __pyx_f[0], 59);
  __pyx_pybuffer_buffer.pybuffer.buf = NULL;
  __pyx_pybuffer_buffer.refcount = 0;
  __pyx_pybuffernd_buffer.data = NULL;
  __pyx_pybuffernd_buffer.rcbuffer = &__pyx_pybuffer_buffer;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer, (PyObject*)__pyx_v_buffer, &__Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_UINT32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_buffer.diminfo[0].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_buffer.diminfo[0].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_buffer.diminfo[1].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_buffer.diminfo[1].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[1];

  /* "rasterio/_io.pyx":69
 *     return _gdal.GDALRasterIO(
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 4, 0, 0)             # <<<<<<<<<<<<<<
 * 
 * cdef int io_int32(
 */
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = -1;
  if (__pyx_t_1 < 0) {
    __pyx_t_1 += __pyx_pybuffernd_buffer.diminfo[0].shape;
    if (unlikely(__pyx_t_1 < 0)) __pyx_t_3 = 0;
  } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_buffer.diminfo[0].shape)) __pyx_t_3 = 0;
  if (__pyx_t_2 < 0) {
    __pyx_t_2 += __pyx_pybuffernd_buffer.diminfo[1].shape;
    if (unlikely(__pyx_t_2 < 0)) __pyx_t_3 = 1;
  } else if (unlikely(__pyx_t_2 >= __pyx_pybuffernd_buffer.diminfo[1].shape)) __pyx_t_3 = 1;
  if (unlikely(__pyx_t_3 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_3);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":67
 *         int height,
 *         np.ndarray[DTYPE_UINT32_t, ndim=2, mode='c'] buffer):
 *     return _gdal.GDALRasterIO(             # <<<<<<<<<<<<<<
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 4, 0, 0)
 */
  __pyx_r = GDALRasterIO(__pyx_v_hband, __pyx_v_mode, __pyx_v_xoff, __pyx_v_yoff, __pyx_v_width, __pyx_v_height, (&(*__Pyx_BufPtrCContig2d(__pyx_t_8rasterio_3_io_DTYPE_UINT32_t *, __pyx_pybuffernd_buffer.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_buffer.diminfo[0].strides, __pyx_t_2, __pyx_pybuffernd_buffer.diminfo[1].strides))), (__pyx_v_buffer->dimensions[1]), (__pyx_v_buffer->dimensions[0]), 4, 0, 0);
  goto __pyx_L0;

  /* "rasterio/_io.pyx":59
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 3, 0, 0)
 * 
 * cdef int io_uint32(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

  /* function exit code */
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_WriteUnraisable("rasterio._io.io_uint32", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":71
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 4, 0, 0)
 * 
 * cdef int io_int32(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

static int __pyx_f_8rasterio_3_io_io_int32(void *__pyx_v_hband, int __pyx_v_mode, int __pyx_v_xoff, int __pyx_v_yoff, int __pyx_v_width, int __pyx_v_height, PyArrayObject *__pyx_v_buffer) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_buffer;
  __Pyx_Buffer __pyx_pybuffer_buffer;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  long __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("io_int32", 0);
  __Pyx_TraceCall("io_int32", __pyx_f[0], 71);
  __pyx_pybuffer_buffer.pybuffer.buf = NULL;
  __pyx_pybuffer_buffer.refcount = 0;
  __pyx_pybuffernd_buffer.data = NULL;
  __pyx_pybuffernd_buffer.rcbuffer = &__pyx_pybuffer_buffer;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer, (PyObject*)__pyx_v_buffer, &__Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_INT32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_buffer.diminfo[0].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_buffer.diminfo[0].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_buffer.diminfo[1].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_buffer.diminfo[1].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[1];

  /* "rasterio/_io.pyx":81
 *     return _gdal.GDALRasterIO(
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 5, 0, 0)             # <<<<<<<<<<<<<<
 * 
 * cdef int io_float32(
 */
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = -1;
  if (__pyx_t_1 < 0) {
    __pyx_t_1 += __pyx_pybuffernd_buffer.diminfo[0].shape;
    if (unlikely(__pyx_t_1 < 0)) __pyx_t_3 = 0;
  } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_buffer.diminfo[0].shape)) __pyx_t_3 = 0;
  if (__pyx_t_2 < 0) {
    __pyx_t_2 += __pyx_pybuffernd_buffer.diminfo[1].shape;
    if (unlikely(__pyx_t_2 < 0)) __pyx_t_3 = 1;
  } else if (unlikely(__pyx_t_2 >= __pyx_pybuffernd_buffer.diminfo[1].shape)) __pyx_t_3 = 1;
  if (unlikely(__pyx_t_3 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_3);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":79
 *         int height,
 *         np.ndarray[DTYPE_INT32_t, ndim=2, mode='c'] buffer):
 *     return _gdal.GDALRasterIO(             # <<<<<<<<<<<<<<
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 5, 0, 0)
 */
  __pyx_r = GDALRasterIO(__pyx_v_hband, __pyx_v_mode, __pyx_v_xoff, __pyx_v_yoff, __pyx_v_width, __pyx_v_height, (&(*__Pyx_BufPtrCContig2d(__pyx_t_8rasterio_3_io_DTYPE_INT32_t *, __pyx_pybuffernd_buffer.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_buffer.diminfo[0].strides, __pyx_t_2, __pyx_pybuffernd_buffer.diminfo[1].strides))), (__pyx_v_buffer->dimensions[1]), (__pyx_v_buffer->dimensions[0]), 5, 0, 0);
  goto __pyx_L0;

  /* "rasterio/_io.pyx":71
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 4, 0, 0)
 * 
 * cdef int io_int32(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

  /* function exit code */
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_WriteUnraisable("rasterio._io.io_int32", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":83
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 5, 0, 0)
 * 
 * cdef int io_float32(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

static int __pyx_f_8rasterio_3_io_io_float32(void *__pyx_v_hband, int __pyx_v_mode, int __pyx_v_xoff, int __pyx_v_yoff, int __pyx_v_width, int __pyx_v_height, PyArrayObject *__pyx_v_buffer) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_buffer;
  __Pyx_Buffer __pyx_pybuffer_buffer;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  long __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("io_float32", 0);
  __Pyx_TraceCall("io_float32", __pyx_f[0], 83);
  __pyx_pybuffer_buffer.pybuffer.buf = NULL;
  __pyx_pybuffer_buffer.refcount = 0;
  __pyx_pybuffernd_buffer.data = NULL;
  __pyx_pybuffernd_buffer.rcbuffer = &__pyx_pybuffer_buffer;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer, (PyObject*)__pyx_v_buffer, &__Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_FLOAT32_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_buffer.diminfo[0].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_buffer.diminfo[0].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_buffer.diminfo[1].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_buffer.diminfo[1].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[1];

  /* "rasterio/_io.pyx":93
 *     return _gdal.GDALRasterIO(
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 6, 0, 0)             # <<<<<<<<<<<<<<
 * 
 * cdef int io_float64(
 */
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = -1;
  if (__pyx_t_1 < 0) {
    __pyx_t_1 += __pyx_pybuffernd_buffer.diminfo[0].shape;
    if (unlikely(__pyx_t_1 < 0)) __pyx_t_3 = 0;
  } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_buffer.diminfo[0].shape)) __pyx_t_3 = 0;
  if (__pyx_t_2 < 0) {
    __pyx_t_2 += __pyx_pybuffernd_buffer.diminfo[1].shape;
    if (unlikely(__pyx_t_2 < 0)) __pyx_t_3 = 1;
  } else if (unlikely(__pyx_t_2 >= __pyx_pybuffernd_buffer.diminfo[1].shape)) __pyx_t_3 = 1;
  if (unlikely(__pyx_t_3 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_3);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":91
 *         int height,
 *         np.ndarray[DTYPE_FLOAT32_t, ndim=2, mode='c'] buffer):
 *     return _gdal.GDALRasterIO(             # <<<<<<<<<<<<<<
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 6, 0, 0)
 */
  __pyx_r = GDALRasterIO(__pyx_v_hband, __pyx_v_mode, __pyx_v_xoff, __pyx_v_yoff, __pyx_v_width, __pyx_v_height, (&(*__Pyx_BufPtrCContig2d(__pyx_t_8rasterio_3_io_DTYPE_FLOAT32_t *, __pyx_pybuffernd_buffer.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_buffer.diminfo[0].strides, __pyx_t_2, __pyx_pybuffernd_buffer.diminfo[1].strides))), (__pyx_v_buffer->dimensions[1]), (__pyx_v_buffer->dimensions[0]), 6, 0, 0);
  goto __pyx_L0;

  /* "rasterio/_io.pyx":83
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 5, 0, 0)
 * 
 * cdef int io_float32(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

  /* function exit code */
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_WriteUnraisable("rasterio._io.io_float32", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":95
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 6, 0, 0)
 * 
 * cdef int io_float64(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

static int __pyx_f_8rasterio_3_io_io_float64(void *__pyx_v_hband, int __pyx_v_mode, int __pyx_v_xoff, int __pyx_v_yoff, int __pyx_v_width, int __pyx_v_height, PyArrayObject *__pyx_v_buffer) {
  __Pyx_LocalBuf_ND __pyx_pybuffernd_buffer;
  __Pyx_Buffer __pyx_pybuffer_buffer;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  long __pyx_t_1;
  long __pyx_t_2;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("io_float64", 0);
  __Pyx_TraceCall("io_float64", __pyx_f[0], 95);
  __pyx_pybuffer_buffer.pybuffer.buf = NULL;
  __pyx_pybuffer_buffer.refcount = 0;
  __pyx_pybuffernd_buffer.data = NULL;
  __pyx_pybuffernd_buffer.rcbuffer = &__pyx_pybuffer_buffer;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer, (PyObject*)__pyx_v_buffer, &__Pyx_TypeInfo_nn___pyx_t_8rasterio_3_io_DTYPE_FLOAT64_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_pybuffernd_buffer.diminfo[0].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_buffer.diminfo[0].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_buffer.diminfo[1].strides = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_buffer.diminfo[1].shape = __pyx_pybuffernd_buffer.rcbuffer->pybuffer.shape[1];

  /* "rasterio/_io.pyx":105
 *     return _gdal.GDALRasterIO(
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 7, 0, 0)             # <<<<<<<<<<<<<<
 * 
 * # Window utils
 */
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = -1;
  if (__pyx_t_1 < 0) {
    __pyx_t_1 += __pyx_pybuffernd_buffer.diminfo[0].shape;
    if (unlikely(__pyx_t_1 < 0)) __pyx_t_3 = 0;
  } else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_buffer.diminfo[0].shape)) __pyx_t_3 = 0;
  if (__pyx_t_2 < 0) {
    __pyx_t_2 += __pyx_pybuffernd_buffer.diminfo[1].shape;
    if (unlikely(__pyx_t_2 < 0)) __pyx_t_3 = 1;
  } else if (unlikely(__pyx_t_2 >= __pyx_pybuffernd_buffer.diminfo[1].shape)) __pyx_t_3 = 1;
  if (unlikely(__pyx_t_3 != -1)) {
    __Pyx_RaiseBufferIndexError(__pyx_t_3);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":103
 *         int height,
 *         np.ndarray[DTYPE_FLOAT64_t, ndim=2, mode='c'] buffer):
 *     return _gdal.GDALRasterIO(             # <<<<<<<<<<<<<<
 *         hband, mode, xoff, yoff, width, height,
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 7, 0, 0)
 */
  __pyx_r = GDALRasterIO(__pyx_v_hband, __pyx_v_mode, __pyx_v_xoff, __pyx_v_yoff, __pyx_v_width, __pyx_v_height, (&(*__Pyx_BufPtrCContig2d(__pyx_t_8rasterio_3_io_DTYPE_FLOAT64_t *, __pyx_pybuffernd_buffer.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_buffer.diminfo[0].strides, __pyx_t_2, __pyx_pybuffernd_buffer.diminfo[1].strides))), (__pyx_v_buffer->dimensions[1]), (__pyx_v_buffer->dimensions[0]), 7, 0, 0);
  goto __pyx_L0;

  /* "rasterio/_io.pyx":95
 *         &buffer[0, 0], buffer.shape[1], buffer.shape[0], 6, 0, 0)
 * 
 * cdef int io_float64(             # <<<<<<<<<<<<<<
 *         void *hband,
 *         int mode,
 */

  /* function exit code */
  __pyx_L1_error:;
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_WriteUnraisable("rasterio._io.io_float64", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_buffer.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":111
 * # ((row_start, row_stop), (col_start, col_stop))
 * 
 * cpdef eval_window(object window, int height, int width):             # <<<<<<<<<<<<<<
 *     """Evaluates a window tuple that might contain negative values
 *     in the context of a raster height and width."""
 */

static PyObject *__pyx_pw_8rasterio_3_io_1eval_window(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_8rasterio_3_io_eval_window(PyObject *__pyx_v_window, int __pyx_v_height, int __pyx_v_width, CYTHON_UNUSED int __pyx_skip_dispatch) {
  int __pyx_v_r_start;
  int __pyx_v_r_stop;
  int __pyx_v_c_start;
  int __pyx_v_c_stop;
  PyObject *__pyx_v_r = NULL;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("eval_window", 0);
  __Pyx_TraceCall("eval_window", __pyx_f[0], 111);

  /* "rasterio/_io.pyx":115
 *     in the context of a raster height and width."""
 *     cdef int r_start, r_stop, c_start, c_stop
 *     r, c = window             # <<<<<<<<<<<<<<
 *     r_start = r[0] or 0
 *     if r_start < 0:
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_window))) || (PyList_CheckExact(__pyx_v_window))) {
    PyObject* sequence = __pyx_v_window;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
  } else {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_window); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_v_r = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_c = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":116
 *     cdef int r_start, r_stop, c_start, c_stop
 *     r, c = window
 *     r_start = r[0] or 0             # <<<<<<<<<<<<<<
 *     if r_start < 0:
 *         if height < 0:
 */
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_r, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!__pyx_t_5) {
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_1 = __pyx_int_0;
  } else {
    __pyx_t_1 = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_r_start = __pyx_t_6;

  /* "rasterio/_io.pyx":117
 *     r, c = window
 *     r_start = r[0] or 0
 *     if r_start < 0:             # <<<<<<<<<<<<<<
 *         if height < 0:
 *             raise ValueError("invalid height: %d" % height)
 */
  __pyx_t_5 = ((__pyx_v_r_start < 0) != 0);
  if (__pyx_t_5) {

    /* "rasterio/_io.pyx":118
 *     r_start = r[0] or 0
 *     if r_start < 0:
 *         if height < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("invalid height: %d" % height)
 *         r_start += height
 */
    __pyx_t_5 = ((__pyx_v_height < 0) != 0);
    if (__pyx_t_5) {

      /* "rasterio/_io.pyx":119
 *     if r_start < 0:
 *         if height < 0:
 *             raise ValueError("invalid height: %d" % height)             # <<<<<<<<<<<<<<
 *         r_start += height
 *     r_stop = r[1] or height
 */
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_height); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_invalid_height_d, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":120
 *         if height < 0:
 *             raise ValueError("invalid height: %d" % height)
 *         r_start += height             # <<<<<<<<<<<<<<
 *     r_stop = r[1] or height
 *     if r_stop < 0:
 */
    __pyx_v_r_start = (__pyx_v_r_start + __pyx_v_height);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "rasterio/_io.pyx":121
 *             raise ValueError("invalid height: %d" % height)
 *         r_start += height
 *     r_stop = r[1] or height             # <<<<<<<<<<<<<<
 *     if r_stop < 0:
 *         if height < 0:
 */
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_r, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!__pyx_t_5) {
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_height); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __pyx_t_1;
    __pyx_t_1 = 0;
  } else {
    __pyx_t_3 = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_r_stop = __pyx_t_6;

  /* "rasterio/_io.pyx":122
 *         r_start += height
 *     r_stop = r[1] or height
 *     if r_stop < 0:             # <<<<<<<<<<<<<<
 *         if height < 0:
 *             raise ValueError("invalid height: %d" % height)
 */
  __pyx_t_5 = ((__pyx_v_r_stop < 0) != 0);
  if (__pyx_t_5) {

    /* "rasterio/_io.pyx":123
 *     r_stop = r[1] or height
 *     if r_stop < 0:
 *         if height < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("invalid height: %d" % height)
 *         r_stop += height
 */
    __pyx_t_5 = ((__pyx_v_height < 0) != 0);
    if (__pyx_t_5) {

      /* "rasterio/_io.pyx":124
 *     if r_stop < 0:
 *         if height < 0:
 *             raise ValueError("invalid height: %d" % height)             # <<<<<<<<<<<<<<
 *         r_stop += height
 *     if not r_stop >= r_start:
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_height); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_invalid_height_d, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":125
 *         if height < 0:
 *             raise ValueError("invalid height: %d" % height)
 *         r_stop += height             # <<<<<<<<<<<<<<
 *     if not r_stop >= r_start:
 *         raise ValueError(
 */
    __pyx_v_r_stop = (__pyx_v_r_stop + __pyx_v_height);
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "rasterio/_io.pyx":126
 *             raise ValueError("invalid height: %d" % height)
 *         r_stop += height
 *     if not r_stop >= r_start:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             "invalid window: row range (%d, %d)" % (r_start, r_stop))
 */
  __pyx_t_5 = ((!((__pyx_v_r_stop >= __pyx_v_r_start) != 0)) != 0);
  if (__pyx_t_5) {

    /* "rasterio/_io.pyx":128
 *     if not r_stop >= r_start:
 *         raise ValueError(
 *             "invalid window: row range (%d, %d)" % (r_start, r_stop))             # <<<<<<<<<<<<<<
 *     c_start = c[0] or 0
 *     if c_start < 0:
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_r_start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_r_stop); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_2 = 0;
    __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_invalid_window_row_range_d_d, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "rasterio/_io.pyx":127
 *         r_stop += height
 *     if not r_stop >= r_start:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             "invalid window: row range (%d, %d)" % (r_start, r_stop))
 *     c_start = c[0] or 0
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":129
 *         raise ValueError(
 *             "invalid window: row range (%d, %d)" % (r_start, r_stop))
 *     c_start = c[0] or 0             # <<<<<<<<<<<<<<
 *     if c_start < 0:
 *         if width < 0:
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_c, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!__pyx_t_5) {
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_INCREF(__pyx_int_0);
    __pyx_t_1 = __pyx_int_0;
  } else {
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_c_start = __pyx_t_6;

  /* "rasterio/_io.pyx":130
 *             "invalid window: row range (%d, %d)" % (r_start, r_stop))
 *     c_start = c[0] or 0
 *     if c_start < 0:             # <<<<<<<<<<<<<<
 *         if width < 0:
 *             raise ValueError("invalid width: %d" % width)
 */
  __pyx_t_5 = ((__pyx_v_c_start < 0) != 0);
  if (__pyx_t_5) {

    /* "rasterio/_io.pyx":131
 *     c_start = c[0] or 0
 *     if c_start < 0:
 *         if width < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("invalid width: %d" % width)
 *         c_start += width
 */
    __pyx_t_5 = ((__pyx_v_width < 0) != 0);
    if (__pyx_t_5) {

      /* "rasterio/_io.pyx":132
 *     if c_start < 0:
 *         if width < 0:
 *             raise ValueError("invalid width: %d" % width)             # <<<<<<<<<<<<<<
 *         c_start += width
 *     c_stop = c[1] or width
 */
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_invalid_width_d, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":133
 *         if width < 0:
 *             raise ValueError("invalid width: %d" % width)
 *         c_start += width             # <<<<<<<<<<<<<<
 *     c_stop = c[1] or width
 *     if c_stop < 0:
 */
    __pyx_v_c_start = (__pyx_v_c_start + __pyx_v_width);
    goto __pyx_L10;
  }
  __pyx_L10:;

  /* "rasterio/_io.pyx":134
 *             raise ValueError("invalid width: %d" % width)
 *         c_start += width
 *     c_stop = c[1] or width             # <<<<<<<<<<<<<<
 *     if c_stop < 0:
 *         if width < 0:
 */
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_c, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!__pyx_t_5) {
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_t_1;
    __pyx_t_1 = 0;
  } else {
    __pyx_t_2 = __pyx_t_3;
    __pyx_t_3 = 0;
  }
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_c_stop = __pyx_t_6;

  /* "rasterio/_io.pyx":135
 *         c_start += width
 *     c_stop = c[1] or width
 *     if c_stop < 0:             # <<<<<<<<<<<<<<
 *         if width < 0:
 *             raise ValueError("invalid width: %d" % width)
 */
  __pyx_t_5 = ((__pyx_v_c_stop < 0) != 0);
  if (__pyx_t_5) {

    /* "rasterio/_io.pyx":136
 *     c_stop = c[1] or width
 *     if c_stop < 0:
 *         if width < 0:             # <<<<<<<<<<<<<<
 *             raise ValueError("invalid width: %d" % width)
 *         c_stop += width
 */
    __pyx_t_5 = ((__pyx_v_width < 0) != 0);
    if (__pyx_t_5) {

      /* "rasterio/_io.pyx":137
 *     if c_stop < 0:
 *         if width < 0:
 *             raise ValueError("invalid width: %d" % width)             # <<<<<<<<<<<<<<
 *         c_stop += width
 *     if not c_stop >= c_start:
 */
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_width); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_invalid_width_d, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":138
 *         if width < 0:
 *             raise ValueError("invalid width: %d" % width)
 *         c_stop += width             # <<<<<<<<<<<<<<
 *     if not c_stop >= c_start:
 *         raise ValueError(
 */
    __pyx_v_c_stop = (__pyx_v_c_stop + __pyx_v_width);
    goto __pyx_L12;
  }
  __pyx_L12:;

  /* "rasterio/_io.pyx":139
 *             raise ValueError("invalid width: %d" % width)
 *         c_stop += width
 *     if not c_stop >= c_start:             # <<<<<<<<<<<<<<
 *         raise ValueError(
 *             "invalid window: col range (%d, %d)" % (c_start, c_stop))
 */
  __pyx_t_5 = ((!((__pyx_v_c_stop >= __pyx_v_c_start) != 0)) != 0);
  if (__pyx_t_5) {

    /* "rasterio/_io.pyx":141
 *     if not c_stop >= c_start:
 *         raise ValueError(
 *             "invalid window: col range (%d, %d)" % (c_start, c_stop))             # <<<<<<<<<<<<<<
 *     return (r_start, r_stop), (c_start, c_stop)
 * 
 */
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_c_start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_c_stop); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_3 = 0;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_invalid_window_col_range_d_d, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "rasterio/_io.pyx":140
 *         c_stop += width
 *     if not c_stop >= c_start:
 *         raise ValueError(             # <<<<<<<<<<<<<<
 *             "invalid window: col range (%d, %d)" % (c_start, c_stop))
 *     return (r_start, r_stop), (c_start, c_stop)
 */
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":142
 *         raise ValueError(
 *             "invalid window: col range (%d, %d)" % (c_start, c_stop))
 *     return (r_start, r_stop), (c_start, c_stop)             # <<<<<<<<<<<<<<
 * 
 * def window_shape(window, height=-1, width=-1):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_r_start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_r_stop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_c_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_c_stop); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_t_3 = 0;
  __pyx_t_7 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":111
 * # ((row_start, row_stop), (col_start, col_stop))
 * 
 * cpdef eval_window(object window, int height, int width):             # <<<<<<<<<<<<<<
 *     """Evaluates a window tuple that might contain negative values
 *     in the context of a raster height and width."""
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("rasterio._io.eval_window", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_r);
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_1eval_window(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8rasterio_3_io_eval_window[] = "Evaluates a window tuple that might contain negative values\n    in the context of a raster height and width.";
static PyObject *__pyx_pw_8rasterio_3_io_1eval_window(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_window = 0;
  int __pyx_v_height;
  int __pyx_v_width;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("eval_window (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_window,&__pyx_n_s_height,&__pyx_n_s_width,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_height)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("eval_window", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_width)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("eval_window", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "eval_window") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_window = values[0];
    __pyx_v_height = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_height == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_width = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_width == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("eval_window", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("rasterio._io.eval_window", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_eval_window(__pyx_self, __pyx_v_window, __pyx_v_height, __pyx_v_width);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_eval_window(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_window, int __pyx_v_height, int __pyx_v_width) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("eval_window", 0);
  __Pyx_TraceCall("eval_window", __pyx_f[0], 111);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_f_8rasterio_3_io_eval_window(__pyx_v_window, __pyx_v_height, __pyx_v_width, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("rasterio._io.eval_window", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":144
 *     return (r_start, r_stop), (c_start, c_stop)
 * 
 * def window_shape(window, height=-1, width=-1):             # <<<<<<<<<<<<<<
 *     """Returns shape of a window.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_3window_shape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8rasterio_3_io_2window_shape[] = "Returns shape of a window.\n\n    height and width arguments are optional if there are no negative\n    values in the window.\n    ";
static PyMethodDef __pyx_mdef_8rasterio_3_io_3window_shape = {__Pyx_NAMESTR("window_shape"), (PyCFunction)__pyx_pw_8rasterio_3_io_3window_shape, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_2window_shape)};
static PyObject *__pyx_pw_8rasterio_3_io_3window_shape(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_window = 0;
  PyObject *__pyx_v_height = 0;
  PyObject *__pyx_v_width = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("window_shape (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_window,&__pyx_n_s_height,&__pyx_n_s_width,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)__pyx_int_neg_1);
    values[2] = ((PyObject *)__pyx_int_neg_1);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_height);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_width);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "window_shape") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_window = values[0];
    __pyx_v_height = values[1];
    __pyx_v_width = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("window_shape", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("rasterio._io.window_shape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_2window_shape(__pyx_self, __pyx_v_window, __pyx_v_height, __pyx_v_width);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_2window_shape(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_window, PyObject *__pyx_v_height, PyObject *__pyx_v_width) {
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_v_b = NULL;
  PyObject *__pyx_v_c = NULL;
  PyObject *__pyx_v_d = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("window_shape", 0);
  __Pyx_TraceCall("window_shape", __pyx_f[0], 144);

  /* "rasterio/_io.pyx":150
 *     values in the window.
 *     """
 *     (a, b), (c, d) = eval_window(window, height, width)             # <<<<<<<<<<<<<<
 *     return b-a, d-c
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __pyx_f_8rasterio_3_io_eval_window(__pyx_v_window, __pyx_t_1, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    index = 0; __pyx_t_4 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
    PyObject* sequence = __pyx_t_4;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_8);
    #else
    __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    #endif
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_9 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_9)->tp_iternext;
    index = 0; __pyx_t_6 = __pyx_t_7(__pyx_t_9); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_6);
    index = 1; __pyx_t_8 = __pyx_t_7(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_8);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_9), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L6_unpacking_done:;
  }
  __pyx_v_a = __pyx_t_6;
  __pyx_t_6 = 0;
  __pyx_v_b = __pyx_t_8;
  __pyx_t_8 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
    PyObject* sequence = __pyx_t_5;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_6);
    #else
    __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_9)->tp_iternext;
    index = 0; __pyx_t_8 = __pyx_t_7(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L7_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_8);
    index = 1; __pyx_t_6 = __pyx_t_7(__pyx_t_9); if (unlikely(!__pyx_t_6)) goto __pyx_L7_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_9), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L8_unpacking_done;
    __pyx_L7_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L8_unpacking_done:;
  }
  __pyx_v_c = __pyx_t_8;
  __pyx_t_8 = 0;
  __pyx_v_d = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "rasterio/_io.pyx":151
 *     """
 *     (a, b), (c, d) = eval_window(window, height, width)
 *     return b-a, d-c             # <<<<<<<<<<<<<<
 * 
 * def window_index(window):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyNumber_Subtract(__pyx_v_b, __pyx_v_a); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyNumber_Subtract(__pyx_v_d, __pyx_v_c); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_3 = 0;
  __pyx_t_5 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":144
 *     return (r_start, r_stop), (c_start, c_stop)
 * 
 * def window_shape(window, height=-1, width=-1):             # <<<<<<<<<<<<<<
 *     """Returns shape of a window.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("rasterio._io.window_shape", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XDECREF(__pyx_v_b);
  __Pyx_XDECREF(__pyx_v_c);
  __Pyx_XDECREF(__pyx_v_d);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":153
 *     return b-a, d-c
 * 
 * def window_index(window):             # <<<<<<<<<<<<<<
 *     return tuple(slice(*w) for w in window)
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_5window_index(PyObject *__pyx_self, PyObject *__pyx_v_window); /*proto*/
static PyMethodDef __pyx_mdef_8rasterio_3_io_5window_index = {__Pyx_NAMESTR("window_index"), (PyCFunction)__pyx_pw_8rasterio_3_io_5window_index, METH_O, __Pyx_DOCSTR(0)};
static PyObject *__pyx_pw_8rasterio_3_io_5window_index(PyObject *__pyx_self, PyObject *__pyx_v_window) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("window_index (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_4window_index(__pyx_self, ((PyObject *)__pyx_v_window));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_8rasterio_3_io_12window_index_2generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "rasterio/_io.pyx":154
 * 
 * def window_index(window):
 *     return tuple(slice(*w) for w in window)             # <<<<<<<<<<<<<<
 * 
 * 
 */

static PyObject *__pyx_pf_8rasterio_3_io_12window_index_genexpr(PyObject *__pyx_self) {
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr *)__pyx_tp_new_8rasterio_3_io___pyx_scope_struct_1_genexpr(__pyx_ptype_8rasterio_3_io___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index *) __pyx_self;
  __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope));
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_TraceCall("genexpr", __pyx_f[0], 154);
  {
    __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_8rasterio_3_io_12window_index_2generator1, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("rasterio._io.window_index.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_8rasterio_3_io_12window_index_2generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_window)) { __Pyx_RaiseClosureNameError("window"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  if (PyList_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_window) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_window)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_window; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_window); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
  }
  for (;;) {
    if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) {
      if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_w);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_w, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PySequence_Tuple(__pyx_cur_scope->__pyx_v_w); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PySlice_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_5;
    __pyx_t_5 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L6_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Generator_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return NULL;
}

/* "rasterio/_io.pyx":153
 *     return b-a, d-c
 * 
 * def window_index(window):             # <<<<<<<<<<<<<<
 *     return tuple(slice(*w) for w in window)
 * 
 */

static PyObject *__pyx_pf_8rasterio_3_io_4window_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_window) {
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("window_index", 0);
  __pyx_cur_scope = (struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index *)__pyx_tp_new_8rasterio_3_io___pyx_scope_struct__window_index(__pyx_ptype_8rasterio_3_io___pyx_scope_struct__window_index, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __Pyx_TraceCall("window_index", __pyx_f[0], 153);
  __pyx_cur_scope->__pyx_v_window = __pyx_v_window;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_window);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_window);

  /* "rasterio/_io.pyx":154
 * 
 * def window_index(window):
 *     return tuple(slice(*w) for w in window)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_pf_8rasterio_3_io_12window_index_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyTuple_Type))), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":153
 *     return b-a, d-c
 * 
 * def window_index(window):             # <<<<<<<<<<<<<<
 *     return tuple(slice(*w) for w in window)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("rasterio._io.window_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":159
 * cdef class RasterReader:
 * 
 *     def __init__(self, path):             # <<<<<<<<<<<<<<
 *         self.name = path
 *         self.mode = 'r'
 */

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_path = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path,0};
    PyObject* values[1] = {0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
    }
    __pyx_v_path = values[0];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("rasterio._io.RasterReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader___init__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), __pyx_v_path);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader___init__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_path) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 159);

  /* "rasterio/_io.pyx":160
 * 
 *     def __init__(self, path):
 *         self.name = path             # <<<<<<<<<<<<<<
 *         self.mode = 'r'
 *         self._hds = NULL
 */
  __Pyx_INCREF(__pyx_v_path);
  __Pyx_GIVEREF(__pyx_v_path);
  __Pyx_GOTREF(__pyx_v_self->name);
  __Pyx_DECREF(__pyx_v_self->name);
  __pyx_v_self->name = __pyx_v_path;

  /* "rasterio/_io.pyx":161
 *     def __init__(self, path):
 *         self.name = path
 *         self.mode = 'r'             # <<<<<<<<<<<<<<
 *         self._hds = NULL
 *         self._count = 0
 */
  __Pyx_INCREF(__pyx_n_s_r);
  __Pyx_GIVEREF(__pyx_n_s_r);
  __Pyx_GOTREF(__pyx_v_self->mode);
  __Pyx_DECREF(__pyx_v_self->mode);
  __pyx_v_self->mode = __pyx_n_s_r;

  /* "rasterio/_io.pyx":162
 *         self.name = path
 *         self.mode = 'r'
 *         self._hds = NULL             # <<<<<<<<<<<<<<
 *         self._count = 0
 *         self._closed = True
 */
  __pyx_v_self->_hds = NULL;

  /* "rasterio/_io.pyx":163
 *         self.mode = 'r'
 *         self._hds = NULL
 *         self._count = 0             # <<<<<<<<<<<<<<
 *         self._closed = True
 *         self._dtypes = []
 */
  __Pyx_INCREF(__pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_GOTREF(__pyx_v_self->_count);
  __Pyx_DECREF(__pyx_v_self->_count);
  __pyx_v_self->_count = __pyx_int_0;

  /* "rasterio/_io.pyx":164
 *         self._hds = NULL
 *         self._count = 0
 *         self._closed = True             # <<<<<<<<<<<<<<
 *         self._dtypes = []
 *         self._block_shapes = []
 */
  __Pyx_INCREF(Py_True);
  __Pyx_GIVEREF(Py_True);
  __Pyx_GOTREF(__pyx_v_self->_closed);
  __Pyx_DECREF(__pyx_v_self->_closed);
  __pyx_v_self->_closed = Py_True;

  /* "rasterio/_io.pyx":165
 *         self._count = 0
 *         self._closed = True
 *         self._dtypes = []             # <<<<<<<<<<<<<<
 *         self._block_shapes = []
 *         self._nodatavals = []
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_dtypes);
  __Pyx_DECREF(__pyx_v_self->_dtypes);
  __pyx_v_self->_dtypes = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":166
 *         self._closed = True
 *         self._dtypes = []
 *         self._block_shapes = []             # <<<<<<<<<<<<<<
 *         self._nodatavals = []
 *         self._crs = None
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_block_shapes);
  __Pyx_DECREF(__pyx_v_self->_block_shapes);
  __pyx_v_self->_block_shapes = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":167
 *         self._dtypes = []
 *         self._block_shapes = []
 *         self._nodatavals = []             # <<<<<<<<<<<<<<
 *         self._crs = None
 *         self._crs_wkt = None
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_nodatavals);
  __Pyx_DECREF(__pyx_v_self->_nodatavals);
  __pyx_v_self->_nodatavals = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":168
 *         self._block_shapes = []
 *         self._nodatavals = []
 *         self._crs = None             # <<<<<<<<<<<<<<
 *         self._crs_wkt = None
 *         self._read = False
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_crs);
  __Pyx_DECREF(__pyx_v_self->_crs);
  __pyx_v_self->_crs = Py_None;

  /* "rasterio/_io.pyx":169
 *         self._nodatavals = []
 *         self._crs = None
 *         self._crs_wkt = None             # <<<<<<<<<<<<<<
 *         self._read = False
 *         self.env = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_crs_wkt);
  __Pyx_DECREF(__pyx_v_self->_crs_wkt);
  __pyx_v_self->_crs_wkt = Py_None;

  /* "rasterio/_io.pyx":170
 *         self._crs = None
 *         self._crs_wkt = None
 *         self._read = False             # <<<<<<<<<<<<<<
 *         self.env = None
 * 
 */
  __Pyx_INCREF(Py_False);
  __Pyx_GIVEREF(Py_False);
  __Pyx_GOTREF(__pyx_v_self->_read);
  __Pyx_DECREF(__pyx_v_self->_read);
  __pyx_v_self->_read = Py_False;

  /* "rasterio/_io.pyx":171
 *         self._crs_wkt = None
 *         self._read = False
 *         self.env = None             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->env);
  __Pyx_DECREF(__pyx_v_self->env);
  __pyx_v_self->env = Py_None;

  /* "rasterio/_io.pyx":159
 * cdef class RasterReader:
 * 
 *     def __init__(self, path):             # <<<<<<<<<<<<<<
 *         self.name = path
 *         self.mode = 'r'
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("rasterio._io.RasterReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":173
 *         self.env = None
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<%s RasterReader '%s' at %s>" % (
 *             self.closed and 'closed' or 'open',
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_3__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_3__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_2__repr__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_2__repr__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__repr__", 0);
  __Pyx_TraceCall("__repr__", __pyx_f[0], 173);

  /* "rasterio/_io.pyx":174
 * 
 *     def __repr__(self):
 *         return "<%s RasterReader '%s' at %s>" % (             # <<<<<<<<<<<<<<
 *             self.closed and 'closed' or 'open',
 *             self.name,
 */
  __Pyx_XDECREF(__pyx_r);

  /* "rasterio/_io.pyx":175
 *     def __repr__(self):
 *         return "<%s RasterReader '%s' at %s>" % (
 *             self.closed and 'closed' or 'open',             # <<<<<<<<<<<<<<
 *             self.name,
 *             hex(id(self)))
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_closed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_n_s_closed);
    __pyx_t_3 = __pyx_n_s_closed;
  } else {
    __pyx_t_3 = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!__pyx_t_2) {
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_INCREF(__pyx_n_s_open);
    __pyx_t_1 = __pyx_n_s_open;
  } else {
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
  }

  /* "rasterio/_io.pyx":177
 *             self.closed and 'closed' or 'open',
 *             self.name,
 *             hex(id(self)))             # <<<<<<<<<<<<<<
 * 
 *     def start(self):
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_4 = PyObject_Call(__pyx_builtin_id, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_builtin_hex, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "rasterio/_io.pyx":175
 *     def __repr__(self):
 *         return "<%s RasterReader '%s' at %s>" % (
 *             self.closed and 'closed' or 'open',             # <<<<<<<<<<<<<<
 *             self.name,
 *             hex(id(self)))
 */
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->name);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->name);
  __Pyx_GIVEREF(__pyx_v_self->name);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;

  /* "rasterio/_io.pyx":174
 * 
 *     def __repr__(self):
 *         return "<%s RasterReader '%s' at %s>" % (             # <<<<<<<<<<<<<<
 *             self.closed and 'closed' or 'open',
 *             self.name,
 */
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_RasterReader_s_at_s, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":173
 *         self.env = None
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<%s RasterReader '%s' at %s>" % (
 *             self.closed and 'closed' or 'open',
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("rasterio._io.RasterReader.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":179
 *             hex(id(self)))
 * 
 *     def start(self):             # <<<<<<<<<<<<<<
 *         # Is there not a driver manager already?
 *         if driver_count() == 0 and not self.env:
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_5start(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_5start(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("start (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_4start(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_4start(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_v_name_b = NULL;
  char const *__pyx_v_fname;
  void *__pyx_v_drv;
  char const *__pyx_v_drv_name;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  char const *__pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("start", 0);
  __Pyx_TraceCall("start", __pyx_f[0], 179);

  /* "rasterio/_io.pyx":181
 *     def start(self):
 *         # Is there not a driver manager already?
 *         if driver_count() == 0 and not self.env:             # <<<<<<<<<<<<<<
 *             # create a local manager and enter
 *             self.env = GDALEnv(True)
 */
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_self->env); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = (!__pyx_t_4);
    __pyx_t_4 = __pyx_t_5;
  } else {
    __pyx_t_4 = __pyx_t_3;
  }
  if (__pyx_t_4) {

    /* "rasterio/_io.pyx":183
 *         if driver_count() == 0 and not self.env:
 *             # create a local manager and enter
 *             self.env = GDALEnv(True)             # <<<<<<<<<<<<<<
 *         else:
 *             # create a local manager and enter
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_GDALEnv); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->env);
    __Pyx_DECREF(__pyx_v_self->env);
    __pyx_v_self->env = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":186
 *         else:
 *             # create a local manager and enter
 *             self.env = GDALEnv(False)             # <<<<<<<<<<<<<<
 *         self.env.start()
 * 
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_GDALEnv); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->env);
    __Pyx_DECREF(__pyx_v_self->env);
    __pyx_v_self->env = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":187
 *             # create a local manager and enter
 *             self.env = GDALEnv(False)
 *         self.env.start()             # <<<<<<<<<<<<<<
 * 
 *         name_b = self.name.encode('utf-8')
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->env, __pyx_n_s_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":189
 *         self.env.start()
 * 
 *         name_b = self.name.encode('utf-8')             # <<<<<<<<<<<<<<
 *         cdef const char *fname = name_b
 *         self._hds = _gdal.GDALOpen(fname, 0)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->name, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_name_b = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":190
 * 
 *         name_b = self.name.encode('utf-8')
 *         cdef const char *fname = name_b             # <<<<<<<<<<<<<<
 *         self._hds = _gdal.GDALOpen(fname, 0)
 *         if self._hds == NULL:
 */
  __pyx_t_6 = __Pyx_PyObject_AsString(__pyx_v_name_b); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_fname = __pyx_t_6;

  /* "rasterio/_io.pyx":191
 *         name_b = self.name.encode('utf-8')
 *         cdef const char *fname = name_b
 *         self._hds = _gdal.GDALOpen(fname, 0)             # <<<<<<<<<<<<<<
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")
 */
  __pyx_v_self->_hds = GDALOpen(__pyx_v_fname, 0);

  /* "rasterio/_io.pyx":192
 *         cdef const char *fname = name_b
 *         self._hds = _gdal.GDALOpen(fname, 0)
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("Null dataset")
 * 
 */
  __pyx_t_4 = ((__pyx_v_self->_hds == NULL) != 0);
  if (__pyx_t_4) {

    /* "rasterio/_io.pyx":193
 *         self._hds = _gdal.GDALOpen(fname, 0)
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")             # <<<<<<<<<<<<<<
 * 
 *         cdef void *drv
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":197
 *         cdef void *drv
 *         cdef const char *drv_name
 *         drv = _gdal.GDALGetDatasetDriver(self._hds)             # <<<<<<<<<<<<<<
 *         drv_name = _gdal.GDALGetDriverShortName(drv)
 *         self.driver = drv_name.decode('utf-8')
 */
  __pyx_v_drv = GDALGetDatasetDriver(__pyx_v_self->_hds);

  /* "rasterio/_io.pyx":198
 *         cdef const char *drv_name
 *         drv = _gdal.GDALGetDatasetDriver(self._hds)
 *         drv_name = _gdal.GDALGetDriverShortName(drv)             # <<<<<<<<<<<<<<
 *         self.driver = drv_name.decode('utf-8')
 * 
 */
  __pyx_v_drv_name = GDALGetDriverShortName(__pyx_v_drv);

  /* "rasterio/_io.pyx":199
 *         drv = _gdal.GDALGetDatasetDriver(self._hds)
 *         drv_name = _gdal.GDALGetDriverShortName(drv)
 *         self.driver = drv_name.decode('utf-8')             # <<<<<<<<<<<<<<
 * 
 *         self._count = _gdal.GDALGetRasterCount(self._hds)
 */
  __pyx_t_1 = __Pyx_decode_c_string(__pyx_v_drv_name, 0, strlen(__pyx_v_drv_name), NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->driver);
  __Pyx_DECREF(__pyx_v_self->driver);
  __pyx_v_self->driver = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":201
 *         self.driver = drv_name.decode('utf-8')
 * 
 *         self._count = _gdal.GDALGetRasterCount(self._hds)             # <<<<<<<<<<<<<<
 *         self.width = _gdal.GDALGetRasterXSize(self._hds)
 *         self.height = _gdal.GDALGetRasterYSize(self._hds)
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(GDALGetRasterCount(__pyx_v_self->_hds)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_count);
  __Pyx_DECREF(__pyx_v_self->_count);
  __pyx_v_self->_count = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":202
 * 
 *         self._count = _gdal.GDALGetRasterCount(self._hds)
 *         self.width = _gdal.GDALGetRasterXSize(self._hds)             # <<<<<<<<<<<<<<
 *         self.height = _gdal.GDALGetRasterYSize(self._hds)
 *         self.shape = (self.height, self.width)
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(GDALGetRasterXSize(__pyx_v_self->_hds)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->width);
  __Pyx_DECREF(__pyx_v_self->width);
  __pyx_v_self->width = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":203
 *         self._count = _gdal.GDALGetRasterCount(self._hds)
 *         self.width = _gdal.GDALGetRasterXSize(self._hds)
 *         self.height = _gdal.GDALGetRasterYSize(self._hds)             # <<<<<<<<<<<<<<
 *         self.shape = (self.height, self.width)
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_From_int(GDALGetRasterYSize(__pyx_v_self->_hds)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->height);
  __Pyx_DECREF(__pyx_v_self->height);
  __pyx_v_self->height = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":204
 *         self.width = _gdal.GDALGetRasterXSize(self._hds)
 *         self.height = _gdal.GDALGetRasterYSize(self._hds)
 *         self.shape = (self.height, self.width)             # <<<<<<<<<<<<<<
 * 
 *         self._transform = self.read_transform()
 */
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->height);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->height);
  __Pyx_GIVEREF(__pyx_v_self->height);
  __Pyx_INCREF(__pyx_v_self->width);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_self->width);
  __Pyx_GIVEREF(__pyx_v_self->width);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->shape);
  __Pyx_DECREF(__pyx_v_self->shape);
  __pyx_v_self->shape = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":206
 *         self.shape = (self.height, self.width)
 * 
 *         self._transform = self.read_transform()             # <<<<<<<<<<<<<<
 *         self._crs = self.read_crs()
 *         self._crs_wkt = self.read_crs_wkt()
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_transform); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->_transform);
  __Pyx_DECREF(__pyx_v_self->_transform);
  __pyx_v_self->_transform = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":207
 * 
 *         self._transform = self.read_transform()
 *         self._crs = self.read_crs()             # <<<<<<<<<<<<<<
 *         self._crs_wkt = self.read_crs_wkt()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_crs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_crs);
  __Pyx_DECREF(__pyx_v_self->_crs);
  __pyx_v_self->_crs = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":208
 *         self._transform = self.read_transform()
 *         self._crs = self.read_crs()
 *         self._crs_wkt = self.read_crs_wkt()             # <<<<<<<<<<<<<<
 * 
 *         # touch self.meta
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_crs_wkt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->_crs_wkt);
  __Pyx_DECREF(__pyx_v_self->_crs_wkt);
  __pyx_v_self->_crs_wkt = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":211
 * 
 *         # touch self.meta
 *         _ = self.meta             # <<<<<<<<<<<<<<
 * 
 *         self._closed = False
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_meta); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__ = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":213
 *         _ = self.meta
 * 
 *         self._closed = False             # <<<<<<<<<<<<<<
 * 
 *     cdef void *band(self, int bidx):
 */
  __Pyx_INCREF(Py_False);
  __Pyx_GIVEREF(Py_False);
  __Pyx_GOTREF(__pyx_v_self->_closed);
  __Pyx_DECREF(__pyx_v_self->_closed);
  __pyx_v_self->_closed = Py_False;

  /* "rasterio/_io.pyx":179
 *             hex(id(self)))
 * 
 *     def start(self):             # <<<<<<<<<<<<<<
 *         # Is there not a driver manager already?
 *         if driver_count() == 0 and not self.env:
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("rasterio._io.RasterReader.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name_b);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":215
 *         self._closed = False
 * 
 *     cdef void *band(self, int bidx):             # <<<<<<<<<<<<<<
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")
 */

static void *__pyx_f_8rasterio_3_io_12RasterReader_band(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, int __pyx_v_bidx) {
  void *__pyx_v_hband;
  void *__pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("band", 0);
  __Pyx_TraceCall("band", __pyx_f[0], 215);

  /* "rasterio/_io.pyx":216
 * 
 *     cdef void *band(self, int bidx):
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("Null dataset")
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 */
  __pyx_t_1 = ((__pyx_v_self->_hds == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":217
 *     cdef void *band(self, int bidx):
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")             # <<<<<<<<<<<<<<
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 *         if hband == NULL:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":218
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)             # <<<<<<<<<<<<<<
 *         if hband == NULL:
 *             raise ValueError("Null band")
 */
  __pyx_v_hband = GDALGetRasterBand(__pyx_v_self->_hds, __pyx_v_bidx);

  /* "rasterio/_io.pyx":219
 *             raise ValueError("Null dataset")
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 *         if hband == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("Null band")
 *         return hband
 */
  __pyx_t_1 = ((__pyx_v_hband == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":220
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 *         if hband == NULL:
 *             raise ValueError("Null band")             # <<<<<<<<<<<<<<
 *         return hband
 * 
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":221
 *         if hband == NULL:
 *             raise ValueError("Null band")
 *         return hband             # <<<<<<<<<<<<<<
 * 
 *     def read_crs(self):
 */
  __pyx_r = __pyx_v_hband;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":215
 *         self._closed = False
 * 
 *     cdef void *band(self, int bidx):             # <<<<<<<<<<<<<<
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_WriteUnraisable("rasterio._io.RasterReader.band", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":223
 *         return hband
 * 
 *     def read_crs(self):             # <<<<<<<<<<<<<<
 *         cdef char *proj_c = NULL
 *         cdef void *osr = NULL
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_7read_crs(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_7read_crs(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("read_crs (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_6read_crs(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_6read_crs(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  char *__pyx_v_proj_c;
  void *__pyx_v_osr;
  PyObject *__pyx_v_crs = NULL;
  char const *__pyx_v_proj;
  char *__pyx_v_proj_b;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_param = NULL;
  PyObject *__pyx_v_kv = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  Py_ssize_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  double __pyx_t_14;
  int __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("read_crs", 0);
  __Pyx_TraceCall("read_crs", __pyx_f[0], 223);

  /* "rasterio/_io.pyx":224
 * 
 *     def read_crs(self):
 *         cdef char *proj_c = NULL             # <<<<<<<<<<<<<<
 *         cdef void *osr = NULL
 *         if self._hds == NULL:
 */
  __pyx_v_proj_c = NULL;

  /* "rasterio/_io.pyx":225
 *     def read_crs(self):
 *         cdef char *proj_c = NULL
 *         cdef void *osr = NULL             # <<<<<<<<<<<<<<
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")
 */
  __pyx_v_osr = NULL;

  /* "rasterio/_io.pyx":226
 *         cdef char *proj_c = NULL
 *         cdef void *osr = NULL
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("Null dataset")
 *         crs = {}
 */
  __pyx_t_1 = ((__pyx_v_self->_hds == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":227
 *         cdef void *osr = NULL
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")             # <<<<<<<<<<<<<<
 *         crs = {}
 *         cdef const char *proj = _gdal.GDALGetProjectionRef(self._hds)
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":228
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")
 *         crs = {}             # <<<<<<<<<<<<<<
 *         cdef const char *proj = _gdal.GDALGetProjectionRef(self._hds)
 *         proj_b = proj
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_crs = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":229
 *             raise ValueError("Null dataset")
 *         crs = {}
 *         cdef const char *proj = _gdal.GDALGetProjectionRef(self._hds)             # <<<<<<<<<<<<<<
 *         proj_b = proj
 *         if len(proj_b) > 0:
 */
  __pyx_v_proj = GDALGetProjectionRef(__pyx_v_self->_hds);

  /* "rasterio/_io.pyx":230
 *         crs = {}
 *         cdef const char *proj = _gdal.GDALGetProjectionRef(self._hds)
 *         proj_b = proj             # <<<<<<<<<<<<<<
 *         if len(proj_b) > 0:
 *             osr = _gdal.OSRNewSpatialReference(proj)
 */
  __pyx_v_proj_b = __pyx_v_proj;

  /* "rasterio/_io.pyx":231
 *         cdef const char *proj = _gdal.GDALGetProjectionRef(self._hds)
 *         proj_b = proj
 *         if len(proj_b) > 0:             # <<<<<<<<<<<<<<
 *             osr = _gdal.OSRNewSpatialReference(proj)
 *             if osr == NULL:
 */
  __pyx_t_3 = strlen(__pyx_v_proj_b); 
  __pyx_t_1 = ((__pyx_t_3 > 0) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":232
 *         proj_b = proj
 *         if len(proj_b) > 0:
 *             osr = _gdal.OSRNewSpatialReference(proj)             # <<<<<<<<<<<<<<
 *             if osr == NULL:
 *                 raise ValueError("Unexpected NULL spatial reference")
 */
    __pyx_v_osr = OSRNewSpatialReference(__pyx_v_proj);

    /* "rasterio/_io.pyx":233
 *         if len(proj_b) > 0:
 *             osr = _gdal.OSRNewSpatialReference(proj)
 *             if osr == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Unexpected NULL spatial reference")
 *             log.debug("Got coordinate system")
 */
    __pyx_t_1 = ((__pyx_v_osr == NULL) != 0);
    if (__pyx_t_1) {

      /* "rasterio/_io.pyx":234
 *             osr = _gdal.OSRNewSpatialReference(proj)
 *             if osr == NULL:
 *                 raise ValueError("Unexpected NULL spatial reference")             # <<<<<<<<<<<<<<
 *             log.debug("Got coordinate system")
 *             _gdal.OSRExportToProj4(osr, &proj_c)
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":235
 *             if osr == NULL:
 *                 raise ValueError("Unexpected NULL spatial reference")
 *             log.debug("Got coordinate system")             # <<<<<<<<<<<<<<
 *             _gdal.OSRExportToProj4(osr, &proj_c)
 *             if proj_c == NULL:
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_4, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":236
 *                 raise ValueError("Unexpected NULL spatial reference")
 *             log.debug("Got coordinate system")
 *             _gdal.OSRExportToProj4(osr, &proj_c)             # <<<<<<<<<<<<<<
 *             if proj_c == NULL:
 *                 raise ValueError("Unexpected Null spatial reference")
 */
    OSRExportToProj4(__pyx_v_osr, (&__pyx_v_proj_c));

    /* "rasterio/_io.pyx":237
 *             log.debug("Got coordinate system")
 *             _gdal.OSRExportToProj4(osr, &proj_c)
 *             if proj_c == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Unexpected Null spatial reference")
 *             proj_b = proj_c
 */
    __pyx_t_1 = ((__pyx_v_proj_c == NULL) != 0);
    if (__pyx_t_1) {

      /* "rasterio/_io.pyx":238
 *             _gdal.OSRExportToProj4(osr, &proj_c)
 *             if proj_c == NULL:
 *                 raise ValueError("Unexpected Null spatial reference")             # <<<<<<<<<<<<<<
 *             proj_b = proj_c
 *             log.debug("Params: %s", proj_b)
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":239
 *             if proj_c == NULL:
 *                 raise ValueError("Unexpected Null spatial reference")
 *             proj_b = proj_c             # <<<<<<<<<<<<<<
 *             log.debug("Params: %s", proj_b)
 *             value = proj_b.decode()
 */
    __pyx_v_proj_b = __pyx_v_proj_c;

    /* "rasterio/_io.pyx":240
 *                 raise ValueError("Unexpected Null spatial reference")
 *             proj_b = proj_c
 *             log.debug("Params: %s", proj_b)             # <<<<<<<<<<<<<<
 *             value = proj_b.decode()
 *             value = value.strip()
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_proj_b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_kp_s_Params_s);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_s_Params_s);
    __Pyx_GIVEREF(__pyx_kp_s_Params_s);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":241
 *             proj_b = proj_c
 *             log.debug("Params: %s", proj_b)
 *             value = proj_b.decode()             # <<<<<<<<<<<<<<
 *             value = value.strip()
 *             for param in value.split():
 */
    __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_proj_b, 0, strlen(__pyx_v_proj_b), NULL, NULL, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_value = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":242
 *             log.debug("Params: %s", proj_b)
 *             value = proj_b.decode()
 *             value = value.strip()             # <<<<<<<<<<<<<<
 *             for param in value.split():
 *                 kv = param.split("=")
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_strip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "rasterio/_io.pyx":243
 *             value = proj_b.decode()
 *             value = value.strip()
 *             for param in value.split():             # <<<<<<<<<<<<<<
 *                 kv = param.split("=")
 *                 if len(kv) == 2:
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_split); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = PyObject_Call(__pyx_t_5, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
      __pyx_t_5 = __pyx_t_2; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    for (;;) {
      if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_5)) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_5)) {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_2 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_2 = __pyx_t_7(__pyx_t_5);
        if (unlikely(!__pyx_t_2)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XDECREF_SET(__pyx_v_param, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "rasterio/_io.pyx":244
 *             value = value.strip()
 *             for param in value.split():
 *                 kv = param.split("=")             # <<<<<<<<<<<<<<
 *                 if len(kv) == 2:
 *                     k, v = kv
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_param, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF_SET(__pyx_v_kv, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "rasterio/_io.pyx":245
 *             for param in value.split():
 *                 kv = param.split("=")
 *                 if len(kv) == 2:             # <<<<<<<<<<<<<<
 *                     k, v = kv
 *                     try:
 */
      __pyx_t_8 = PyObject_Length(__pyx_v_kv); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = ((__pyx_t_8 == 2) != 0);
      if (__pyx_t_1) {

        /* "rasterio/_io.pyx":246
 *                 kv = param.split("=")
 *                 if len(kv) == 2:
 *                     k, v = kv             # <<<<<<<<<<<<<<
 *                     try:
 *                         v = float(v)
 */
        if ((likely(PyTuple_CheckExact(__pyx_v_kv))) || (PyList_CheckExact(__pyx_v_kv))) {
          PyObject* sequence = __pyx_v_kv;
          #if CYTHON_COMPILING_IN_CPYTHON
          Py_ssize_t size = Py_SIZE(sequence);
          #else
          Py_ssize_t size = PySequence_Size(sequence);
          #endif
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          #if CYTHON_COMPILING_IN_CPYTHON
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
            __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
          } else {
            __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
            __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
          }
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_2);
          #else
          __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_2);
          #endif
        } else {
          Py_ssize_t index = -1;
          __pyx_t_9 = PyObject_GetIter(__pyx_v_kv); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
          index = 0; __pyx_t_4 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L10_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_4);
          index = 1; __pyx_t_2 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_2)) goto __pyx_L10_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_2);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_t_10 = NULL;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          goto __pyx_L11_unpacking_done;
          __pyx_L10_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_10 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __pyx_L11_unpacking_done:;
        }
        __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_4);
        __pyx_t_4 = 0;
        __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_2);
        __pyx_t_2 = 0;

        /* "rasterio/_io.pyx":247
 *                 if len(kv) == 2:
 *                     k, v = kv
 *                     try:             # <<<<<<<<<<<<<<
 *                         v = float(v)
 *                         if v % 1 == 0:
 */
        {
          __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          /*try:*/ {

            /* "rasterio/_io.pyx":248
 *                     k, v = kv
 *                     try:
 *                         v = float(v)             # <<<<<<<<<<<<<<
 *                         if v % 1 == 0:
 *                             v = int(v)
 */
            __pyx_t_14 = __Pyx_PyObject_AsDouble(__pyx_v_v); if (unlikely(__pyx_t_14 == ((double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
            __pyx_t_2 = PyFloat_FromDouble(__pyx_t_14); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_2);
            __pyx_t_2 = 0;

            /* "rasterio/_io.pyx":249
 *                     try:
 *                         v = float(v)
 *                         if v % 1 == 0:             # <<<<<<<<<<<<<<
 *                             v = int(v)
 *                     except ValueError:
 */
            __pyx_t_2 = PyNumber_Remainder(__pyx_v_v, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (__pyx_t_1) {

              /* "rasterio/_io.pyx":250
 *                         v = float(v)
 *                         if v % 1 == 0:
 *                             v = int(v)             # <<<<<<<<<<<<<<
 *                     except ValueError:
 *                         # Leave v as a string
 */
              __pyx_t_4 = PyNumber_Int(__pyx_v_v); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L12_error;}
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_4);
              __pyx_t_4 = 0;
              goto __pyx_L20;
            }
            __pyx_L20:;
          }
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          goto __pyx_L19_try_end;
          __pyx_L12_error:;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "rasterio/_io.pyx":251
 *                         if v % 1 == 0:
 *                             v = int(v)
 *                     except ValueError:             # <<<<<<<<<<<<<<
 *                         # Leave v as a string
 *                         pass
 */
          __pyx_t_15 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
          if (__pyx_t_15) {
            PyErr_Restore(0,0,0);
            goto __pyx_L13_exception_handled;
          }
          goto __pyx_L14_except_error;
          __pyx_L14_except_error:;
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          goto __pyx_L1_error;
          __pyx_L13_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          __pyx_L19_try_end:;
        }
        goto __pyx_L9;
      }

      /* "rasterio/_io.pyx":254
 *                         # Leave v as a string
 *                         pass
 *                 elif len(kv) == 1:             # <<<<<<<<<<<<<<
 *                     k, v = kv[0], True
 *                 else:
 */
      __pyx_t_8 = PyObject_Length(__pyx_v_kv); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = ((__pyx_t_8 == 1) != 0);
      if (__pyx_t_1) {

        /* "rasterio/_io.pyx":255
 *                         pass
 *                 elif len(kv) == 1:
 *                     k, v = kv[0], True             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError("Unexpected proj parameter %s" % param)
 */
        __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_kv, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = Py_True;
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_4);
        __pyx_t_4 = 0;
        __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_2);
        __pyx_t_2 = 0;
        goto __pyx_L9;
      }
      /*else*/ {

        /* "rasterio/_io.pyx":257
 *                     k, v = kv[0], True
 *                 else:
 *                     raise ValueError("Unexpected proj parameter %s" % param)             # <<<<<<<<<<<<<<
 *                 k = k.lstrip("+")
 *                 crs[k] = v
 */
        __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_Unexpected_proj_parameter_s, __pyx_v_param); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;
        __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_Raise(__pyx_t_2, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L9:;

      /* "rasterio/_io.pyx":258
 *                 else:
 *                     raise ValueError("Unexpected proj parameter %s" % param)
 *                 k = k.lstrip("+")             # <<<<<<<<<<<<<<
 *                 crs[k] = v
 *             _gdal.CPLFree(proj_c)
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_k, __pyx_n_s_lstrip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyObject_Call(__pyx_t_2, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "rasterio/_io.pyx":259
 *                     raise ValueError("Unexpected proj parameter %s" % param)
 *                 k = k.lstrip("+")
 *                 crs[k] = v             # <<<<<<<<<<<<<<
 *             _gdal.CPLFree(proj_c)
 *             _gdal.OSRDestroySpatialReference(osr)
 */
      if (unlikely(PyDict_SetItem(__pyx_v_crs, __pyx_v_k, __pyx_v_v) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "rasterio/_io.pyx":260
 *                 k = k.lstrip("+")
 *                 crs[k] = v
 *             _gdal.CPLFree(proj_c)             # <<<<<<<<<<<<<<
 *             _gdal.OSRDestroySpatialReference(osr)
 *         else:
 */
    CPLFree(__pyx_v_proj_c);

    /* "rasterio/_io.pyx":261
 *                 crs[k] = v
 *             _gdal.CPLFree(proj_c)
 *             _gdal.OSRDestroySpatialReference(osr)             # <<<<<<<<<<<<<<
 *         else:
 *             log.debug("Projection not found (cogr_crs was NULL)")
 */
    OSRDestroySpatialReference(__pyx_v_osr);
    goto __pyx_L4;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":263
 *             _gdal.OSRDestroySpatialReference(osr)
 *         else:
 *             log.debug("Projection not found (cogr_crs was NULL)")             # <<<<<<<<<<<<<<
 *         return crs
 * 
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_debug); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_L4:;

  /* "rasterio/_io.pyx":264
 *         else:
 *             log.debug("Projection not found (cogr_crs was NULL)")
 *         return crs             # <<<<<<<<<<<<<<
 * 
 *     def read_crs_wkt(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_crs);
  __pyx_r = __pyx_v_crs;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":223
 *         return hband
 * 
 *     def read_crs(self):             # <<<<<<<<<<<<<<
 *         cdef char *proj_c = NULL
 *         cdef void *osr = NULL
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("rasterio._io.RasterReader.read_crs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_crs);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_param);
  __Pyx_XDECREF(__pyx_v_kv);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":266
 *         return crs
 * 
 *     def read_crs_wkt(self):             # <<<<<<<<<<<<<<
 *         cdef char *proj_c = NULL
 *         if self._hds == NULL:
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_9read_crs_wkt(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_9read_crs_wkt(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("read_crs_wkt (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_8read_crs_wkt(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_8read_crs_wkt(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  char *__pyx_v_proj_c;
  void *__pyx_v_osr;
  CYTHON_UNUSED PyObject *__pyx_v_crs = NULL;
  char *__pyx_v_proj_b;
  PyObject *__pyx_v_crs_wkt = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("read_crs_wkt", 0);
  __Pyx_TraceCall("read_crs_wkt", __pyx_f[0], 266);

  /* "rasterio/_io.pyx":267
 * 
 *     def read_crs_wkt(self):
 *         cdef char *proj_c = NULL             # <<<<<<<<<<<<<<
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")
 */
  __pyx_v_proj_c = NULL;

  /* "rasterio/_io.pyx":268
 *     def read_crs_wkt(self):
 *         cdef char *proj_c = NULL
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("Null dataset")
 *         cdef void *osr = _gdal.OSRNewSpatialReference(
 */
  __pyx_t_1 = ((__pyx_v_self->_hds == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":269
 *         cdef char *proj_c = NULL
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")             # <<<<<<<<<<<<<<
 *         cdef void *osr = _gdal.OSRNewSpatialReference(
 *             _gdal.GDALGetProjectionRef(self._hds))
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":270
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")
 *         cdef void *osr = _gdal.OSRNewSpatialReference(             # <<<<<<<<<<<<<<
 *             _gdal.GDALGetProjectionRef(self._hds))
 *         log.debug("Got coordinate system")
 */
  __pyx_v_osr = OSRNewSpatialReference(GDALGetProjectionRef(__pyx_v_self->_hds));

  /* "rasterio/_io.pyx":272
 *         cdef void *osr = _gdal.OSRNewSpatialReference(
 *             _gdal.GDALGetProjectionRef(self._hds))
 *         log.debug("Got coordinate system")             # <<<<<<<<<<<<<<
 *         crs = {}
 *         if osr != NULL:
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":273
 *             _gdal.GDALGetProjectionRef(self._hds))
 *         log.debug("Got coordinate system")
 *         crs = {}             # <<<<<<<<<<<<<<
 *         if osr != NULL:
 *             _gdal.OSRExportToWkt(osr, &proj_c)
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_crs = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":274
 *         log.debug("Got coordinate system")
 *         crs = {}
 *         if osr != NULL:             # <<<<<<<<<<<<<<
 *             _gdal.OSRExportToWkt(osr, &proj_c)
 *             if proj_c == NULL:
 */
  __pyx_t_1 = ((__pyx_v_osr != NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":275
 *         crs = {}
 *         if osr != NULL:
 *             _gdal.OSRExportToWkt(osr, &proj_c)             # <<<<<<<<<<<<<<
 *             if proj_c == NULL:
 *                 raise ValueError("Null projection")
 */
    OSRExportToWkt(__pyx_v_osr, (&__pyx_v_proj_c));

    /* "rasterio/_io.pyx":276
 *         if osr != NULL:
 *             _gdal.OSRExportToWkt(osr, &proj_c)
 *             if proj_c == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Null projection")
 *             proj_b = proj_c
 */
    __pyx_t_1 = ((__pyx_v_proj_c == NULL) != 0);
    if (__pyx_t_1) {

      /* "rasterio/_io.pyx":277
 *             _gdal.OSRExportToWkt(osr, &proj_c)
 *             if proj_c == NULL:
 *                 raise ValueError("Null projection")             # <<<<<<<<<<<<<<
 *             proj_b = proj_c
 *             crs_wkt = proj_b.decode('utf-8')
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":278
 *             if proj_c == NULL:
 *                 raise ValueError("Null projection")
 *             proj_b = proj_c             # <<<<<<<<<<<<<<
 *             crs_wkt = proj_b.decode('utf-8')
 *             _gdal.CPLFree(proj_c)
 */
    __pyx_v_proj_b = __pyx_v_proj_c;

    /* "rasterio/_io.pyx":279
 *                 raise ValueError("Null projection")
 *             proj_b = proj_c
 *             crs_wkt = proj_b.decode('utf-8')             # <<<<<<<<<<<<<<
 *             _gdal.CPLFree(proj_c)
 *             _gdal.OSRDestroySpatialReference(osr)
 */
    __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_proj_b, 0, strlen(__pyx_v_proj_b), NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_crs_wkt = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":280
 *             proj_b = proj_c
 *             crs_wkt = proj_b.decode('utf-8')
 *             _gdal.CPLFree(proj_c)             # <<<<<<<<<<<<<<
 *             _gdal.OSRDestroySpatialReference(osr)
 *         else:
 */
    CPLFree(__pyx_v_proj_c);

    /* "rasterio/_io.pyx":281
 *             crs_wkt = proj_b.decode('utf-8')
 *             _gdal.CPLFree(proj_c)
 *             _gdal.OSRDestroySpatialReference(osr)             # <<<<<<<<<<<<<<
 *         else:
 *             log.debug("Projection not found (cogr_crs was NULL)")
 */
    OSRDestroySpatialReference(__pyx_v_osr);
    goto __pyx_L4;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":283
 *             _gdal.OSRDestroySpatialReference(osr)
 *         else:
 *             log.debug("Projection not found (cogr_crs was NULL)")             # <<<<<<<<<<<<<<
 *         return crs_wkt
 * 
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L4:;

  /* "rasterio/_io.pyx":284
 *         else:
 *             log.debug("Projection not found (cogr_crs was NULL)")
 *         return crs_wkt             # <<<<<<<<<<<<<<
 * 
 *     def read_transform(self):
 */
  __Pyx_XDECREF(__pyx_r);
  if (unlikely(!__pyx_v_crs_wkt)) { __Pyx_RaiseUnboundLocalError("crs_wkt"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  __Pyx_INCREF(__pyx_v_crs_wkt);
  __pyx_r = __pyx_v_crs_wkt;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":266
 *         return crs
 * 
 *     def read_crs_wkt(self):             # <<<<<<<<<<<<<<
 *         cdef char *proj_c = NULL
 *         if self._hds == NULL:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("rasterio._io.RasterReader.read_crs_wkt", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_crs);
  __Pyx_XDECREF(__pyx_v_crs_wkt);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":286
 *         return crs_wkt
 * 
 *     def read_transform(self):             # <<<<<<<<<<<<<<
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_11read_transform(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_11read_transform(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("read_transform (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_10read_transform(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_10read_transform(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  double __pyx_v_gt[6];
  PyObject *__pyx_v_transform = NULL;
  long __pyx_v_i;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  long __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("read_transform", 0);
  __Pyx_TraceCall("read_transform", __pyx_f[0], 286);

  /* "rasterio/_io.pyx":287
 * 
 *     def read_transform(self):
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("Null dataset")
 *         cdef double gt[6]
 */
  __pyx_t_1 = ((__pyx_v_self->_hds == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":288
 *     def read_transform(self):
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")             # <<<<<<<<<<<<<<
 *         cdef double gt[6]
 *         _gdal.GDALGetGeoTransform(self._hds, gt)
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":290
 *             raise ValueError("Null dataset")
 *         cdef double gt[6]
 *         _gdal.GDALGetGeoTransform(self._hds, gt)             # <<<<<<<<<<<<<<
 *         transform = [0]*6
 *         for i in range(6):
 */
  GDALGetGeoTransform(__pyx_v_self->_hds, __pyx_v_gt);

  /* "rasterio/_io.pyx":291
 *         cdef double gt[6]
 *         _gdal.GDALGetGeoTransform(self._hds, gt)
 *         transform = [0]*6             # <<<<<<<<<<<<<<
 *         for i in range(6):
 *             transform[i] = gt[i]
 */
  __pyx_t_2 = PyList_New(1 * 6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  { Py_ssize_t __pyx_temp;
    for (__pyx_temp=0; __pyx_temp < 6; __pyx_temp++) {
      __Pyx_INCREF(__pyx_int_0);
      PyList_SET_ITEM(__pyx_t_2, __pyx_temp, __pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
    }
  }
  __pyx_v_transform = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":292
 *         _gdal.GDALGetGeoTransform(self._hds, gt)
 *         transform = [0]*6
 *         for i in range(6):             # <<<<<<<<<<<<<<
 *             transform[i] = gt[i]
 *         return transform
 */
  for (__pyx_t_3 = 0; __pyx_t_3 < 6; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "rasterio/_io.pyx":293
 *         transform = [0]*6
 *         for i in range(6):
 *             transform[i] = gt[i]             # <<<<<<<<<<<<<<
 *         return transform
 * 
 */
    __pyx_t_2 = PyFloat_FromDouble((__pyx_v_gt[__pyx_v_i])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    if (unlikely(__Pyx_SetItemInt(__pyx_v_transform, __pyx_v_i, __pyx_t_2, long, 1, __Pyx_PyInt_From_long, 1, 1, 1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }

  /* "rasterio/_io.pyx":294
 *         for i in range(6):
 *             transform[i] = gt[i]
 *         return transform             # <<<<<<<<<<<<<<
 * 
 *     def stop(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_transform);
  __pyx_r = __pyx_v_transform;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":286
 *         return crs_wkt
 * 
 *     def read_transform(self):             # <<<<<<<<<<<<<<
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("rasterio._io.RasterReader.read_transform", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_transform);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":296
 *         return transform
 * 
 *     def stop(self):             # <<<<<<<<<<<<<<
 *         if self._hds != NULL:
 *             _gdal.GDALFlushCache(self._hds)
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_13stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_13stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_12stop(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_12stop(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("stop", 0);
  __Pyx_TraceCall("stop", __pyx_f[0], 296);

  /* "rasterio/_io.pyx":297
 * 
 *     def stop(self):
 *         if self._hds != NULL:             # <<<<<<<<<<<<<<
 *             _gdal.GDALFlushCache(self._hds)
 *             _gdal.GDALClose(self._hds)
 */
  __pyx_t_1 = ((__pyx_v_self->_hds != NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":298
 *     def stop(self):
 *         if self._hds != NULL:
 *             _gdal.GDALFlushCache(self._hds)             # <<<<<<<<<<<<<<
 *             _gdal.GDALClose(self._hds)
 *         if self.env:
 */
    GDALFlushCache(__pyx_v_self->_hds);

    /* "rasterio/_io.pyx":299
 *         if self._hds != NULL:
 *             _gdal.GDALFlushCache(self._hds)
 *             _gdal.GDALClose(self._hds)             # <<<<<<<<<<<<<<
 *         if self.env:
 *             self.env.stop()
 */
    GDALClose(__pyx_v_self->_hds);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":300
 *             _gdal.GDALFlushCache(self._hds)
 *             _gdal.GDALClose(self._hds)
 *         if self.env:             # <<<<<<<<<<<<<<
 *             self.env.stop()
 *         self._hds = NULL
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->env); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":301
 *             _gdal.GDALClose(self._hds)
 *         if self.env:
 *             self.env.stop()             # <<<<<<<<<<<<<<
 *         self._hds = NULL
 * 
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->env, __pyx_n_s_stop); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "rasterio/_io.pyx":302
 *         if self.env:
 *             self.env.stop()
 *         self._hds = NULL             # <<<<<<<<<<<<<<
 * 
 *     def close(self):
 */
  __pyx_v_self->_hds = NULL;

  /* "rasterio/_io.pyx":296
 *         return transform
 * 
 *     def stop(self):             # <<<<<<<<<<<<<<
 *         if self._hds != NULL:
 *             _gdal.GDALFlushCache(self._hds)
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("rasterio._io.RasterReader.stop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":304
 *         self._hds = NULL
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         self.stop()
 *         self._closed = True
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_15close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_15close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("close (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_14close(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_14close(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("close", 0);
  __Pyx_TraceCall("close", __pyx_f[0], 304);

  /* "rasterio/_io.pyx":305
 * 
 *     def close(self):
 *         self.stop()             # <<<<<<<<<<<<<<
 *         self._closed = True
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_stop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":306
 *     def close(self):
 *         self.stop()
 *         self._closed = True             # <<<<<<<<<<<<<<
 * 
 *     def __enter__(self):
 */
  __Pyx_INCREF(Py_True);
  __Pyx_GIVEREF(Py_True);
  __Pyx_GOTREF(__pyx_v_self->_closed);
  __Pyx_DECREF(__pyx_v_self->_closed);
  __pyx_v_self->_closed = Py_True;

  /* "rasterio/_io.pyx":304
 *         self._hds = NULL
 * 
 *     def close(self):             # <<<<<<<<<<<<<<
 *         self.stop()
 *         self._closed = True
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("rasterio._io.RasterReader.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":308
 *         self._closed = True
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_17__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_17__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_16__enter__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_16__enter__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__enter__", 0);
  __Pyx_TraceCall("__enter__", __pyx_f[0], 308);

  /* "rasterio/_io.pyx":309
 * 
 *     def __enter__(self):
 *         return self             # <<<<<<<<<<<<<<
 * 
 *     def __exit__(self, type, value, traceback):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  __pyx_r = ((PyObject *)__pyx_v_self);
  goto __pyx_L0;

  /* "rasterio/_io.pyx":308
 *         self._closed = True
 * 
 *     def __enter__(self):             # <<<<<<<<<<<<<<
 *         return self
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":311
 *         return self
 * 
 *     def __exit__(self, type, value, traceback):             # <<<<<<<<<<<<<<
 *         self.close()
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_19__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_19__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  CYTHON_UNUSED PyObject *__pyx_v_type = 0;
  CYTHON_UNUSED PyObject *__pyx_v_value = 0;
  CYTHON_UNUSED PyObject *__pyx_v_traceback = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_type,&__pyx_n_s_value,&__pyx_n_s_traceback,0};
    PyObject* values[3] = {0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_type)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_value)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_traceback)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
    }
    __pyx_v_type = values[0];
    __pyx_v_value = values[1];
    __pyx_v_traceback = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("rasterio._io.RasterReader.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_18__exit__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), __pyx_v_type, __pyx_v_value, __pyx_v_traceback);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_18__exit__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_type, CYTHON_UNUSED PyObject *__pyx_v_value, CYTHON_UNUSED PyObject *__pyx_v_traceback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__exit__", 0);
  __Pyx_TraceCall("__exit__", __pyx_f[0], 311);

  /* "rasterio/_io.pyx":312
 * 
 *     def __exit__(self, type, value, traceback):
 *         self.close()             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":311
 *         return self
 * 
 *     def __exit__(self, type, value, traceback):             # <<<<<<<<<<<<<<
 *         self.close()
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("rasterio._io.RasterReader.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":314
 *         self.close()
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._hds != NULL:
 *             _gdal.GDALClose(self._hds)
 */

/* Python wrapper */
static void __pyx_pw_8rasterio_3_io_12RasterReader_21__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_8rasterio_3_io_12RasterReader_21__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_8rasterio_3_io_12RasterReader_20__dealloc__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_8rasterio_3_io_12RasterReader_20__dealloc__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__dealloc__", 0);
  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 314);

  /* "rasterio/_io.pyx":315
 * 
 *     def __dealloc__(self):
 *         if self._hds != NULL:             # <<<<<<<<<<<<<<
 *             _gdal.GDALClose(self._hds)
 * 
 */
  __pyx_t_1 = ((__pyx_v_self->_hds != NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":316
 *     def __dealloc__(self):
 *         if self._hds != NULL:
 *             _gdal.GDALClose(self._hds)             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
    GDALClose(__pyx_v_self->_hds);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":314
 *         self.close()
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         if self._hds != NULL:
 *             _gdal.GDALClose(self._hds)
 */

  /* function exit code */
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
}

/* "rasterio/_io.pyx":319
 * 
 *     @property
 *     def closed(self):             # <<<<<<<<<<<<<<
 *         return self._closed
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_23closed(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_23closed(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("closed (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_22closed(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_22closed(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("closed", 0);
  __Pyx_TraceCall("closed", __pyx_f[0], 319);

  /* "rasterio/_io.pyx":320
 *     @property
 *     def closed(self):
 *         return self._closed             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_closed);
  __pyx_r = __pyx_v_self->_closed;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":319
 * 
 *     @property
 *     def closed(self):             # <<<<<<<<<<<<<<
 *         return self._closed
 * 
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":323
 * 
 *     @property
 *     def count(self):             # <<<<<<<<<<<<<<
 *         if not self._count:
 *             if self._hds == NULL:
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_25count(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_25count(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("count (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_24count(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_24count(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("count", 0);
  __Pyx_TraceCall("count", __pyx_f[0], 323);

  /* "rasterio/_io.pyx":324
 *     @property
 *     def count(self):
 *         if not self._count:             # <<<<<<<<<<<<<<
 *             if self._hds == NULL:
 *                 raise ValueError("Can't read closed raster file")
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_count); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "rasterio/_io.pyx":325
 *     def count(self):
 *         if not self._count:
 *             if self._hds == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Can't read closed raster file")
 *             self._count = _gdal.GDALGetRasterCount(self._hds)
 */
    __pyx_t_2 = ((__pyx_v_self->_hds == NULL) != 0);
    if (__pyx_t_2) {

      /* "rasterio/_io.pyx":326
 *         if not self._count:
 *             if self._hds == NULL:
 *                 raise ValueError("Can't read closed raster file")             # <<<<<<<<<<<<<<
 *             self._count = _gdal.GDALGetRasterCount(self._hds)
 *         return self._count
 */
      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":327
 *             if self._hds == NULL:
 *                 raise ValueError("Can't read closed raster file")
 *             self._count = _gdal.GDALGetRasterCount(self._hds)             # <<<<<<<<<<<<<<
 *         return self._count
 * 
 */
    __pyx_t_3 = __Pyx_PyInt_From_int(GDALGetRasterCount(__pyx_v_self->_hds)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __Pyx_GOTREF(__pyx_v_self->_count);
    __Pyx_DECREF(__pyx_v_self->_count);
    __pyx_v_self->_count = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":328
 *                 raise ValueError("Can't read closed raster file")
 *             self._count = _gdal.GDALGetRasterCount(self._hds)
 *         return self._count             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_count);
  __pyx_r = __pyx_v_self->_count;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":323
 * 
 *     @property
 *     def count(self):             # <<<<<<<<<<<<<<
 *         if not self._count:
 *             if self._hds == NULL:
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("rasterio._io.RasterReader.count", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":331
 * 
 *     @property
 *     def indexes(self):             # <<<<<<<<<<<<<<
 *         return list(range(1, self.count+1))
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_27indexes(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_27indexes(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("indexes (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_26indexes(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_26indexes(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("indexes", 0);
  __Pyx_TraceCall("indexes", __pyx_f[0], 331);

  /* "rasterio/_io.pyx":332
 *     @property
 *     def indexes(self):
 *         return list(range(1, self.count+1))             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":331
 * 
 *     @property
 *     def indexes(self):             # <<<<<<<<<<<<<<
 *         return list(range(1, self.count+1))
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("rasterio._io.RasterReader.indexes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":335
 * 
 *     @property
 *     def dtypes(self):             # <<<<<<<<<<<<<<
 *         """Returns an ordered list of all band data types."""
 *         cdef void *hband = NULL
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_29dtypes(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_8rasterio_3_io_12RasterReader_28dtypes[] = "Returns an ordered list of all band data types.";
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_29dtypes(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("dtypes (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_28dtypes(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_28dtypes(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  void *__pyx_v_hband;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("dtypes", 0);
  __Pyx_TraceCall("dtypes", __pyx_f[0], 335);

  /* "rasterio/_io.pyx":337
 *     def dtypes(self):
 *         """Returns an ordered list of all band data types."""
 *         cdef void *hband = NULL             # <<<<<<<<<<<<<<
 *         if not self._dtypes:
 *             if self._hds == NULL:
 */
  __pyx_v_hband = NULL;

  /* "rasterio/_io.pyx":338
 *         """Returns an ordered list of all band data types."""
 *         cdef void *hband = NULL
 *         if not self._dtypes:             # <<<<<<<<<<<<<<
 *             if self._hds == NULL:
 *                 raise ValueError("can't read closed raster file")
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_dtypes); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "rasterio/_io.pyx":339
 *         cdef void *hband = NULL
 *         if not self._dtypes:
 *             if self._hds == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("can't read closed raster file")
 *             for i in range(self._count):
 */
    __pyx_t_2 = ((__pyx_v_self->_hds == NULL) != 0);
    if (__pyx_t_2) {

      /* "rasterio/_io.pyx":340
 *         if not self._dtypes:
 *             if self._hds == NULL:
 *                 raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *             for i in range(self._count):
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 */
      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":341
 *             if self._hds == NULL:
 *                 raise ValueError("can't read closed raster file")
 *             for i in range(self._count):             # <<<<<<<<<<<<<<
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                 self._dtypes.append(
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_self->_count);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->_count);
    __Pyx_GIVEREF(__pyx_v_self->_count);
    __pyx_t_4 = PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) {
      __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (;;) {
      if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_3)) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_3)) {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_4 = __pyx_t_6(__pyx_t_3);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "rasterio/_io.pyx":342
 *                 raise ValueError("can't read closed raster file")
 *             for i in range(self._count):
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)             # <<<<<<<<<<<<<<
 *                 self._dtypes.append(
 *                     dtypes.dtype_fwd[_gdal.GDALGetRasterDataType(hband)])
 */
      __pyx_t_4 = PyNumber_Add(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_hband = GDALGetRasterBand(__pyx_v_self->_hds, __pyx_t_7);

      /* "rasterio/_io.pyx":344
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                 self._dtypes.append(
 *                     dtypes.dtype_fwd[_gdal.GDALGetRasterDataType(hband)])             # <<<<<<<<<<<<<<
 *         return self._dtypes
 * 
 */
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dtype_fwd); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = GDALGetRasterDataType(__pyx_v_hband);
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_8, __pyx_t_7, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "rasterio/_io.pyx":343
 *             for i in range(self._count):
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                 self._dtypes.append(             # <<<<<<<<<<<<<<
 *                     dtypes.dtype_fwd[_gdal.GDALGetRasterDataType(hband)])
 *         return self._dtypes
 */
      __pyx_t_9 = __Pyx_PyObject_Append(__pyx_v_self->_dtypes, __pyx_t_4); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":345
 *                 self._dtypes.append(
 *                     dtypes.dtype_fwd[_gdal.GDALGetRasterDataType(hband)])
 *         return self._dtypes             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_dtypes);
  __pyx_r = __pyx_v_self->_dtypes;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":335
 * 
 *     @property
 *     def dtypes(self):             # <<<<<<<<<<<<<<
 *         """Returns an ordered list of all band data types."""
 *         cdef void *hband = NULL
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("rasterio._io.RasterReader.dtypes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":348
 * 
 *     @property
 *     def block_shapes(self):             # <<<<<<<<<<<<<<
 *         """Returns an ordered list of block shapes for all bands.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_31block_shapes(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_8rasterio_3_io_12RasterReader_30block_shapes[] = "Returns an ordered list of block shapes for all bands.\n        \n        Shapes are tuples and have the same ordering as the dataset's\n        shape: (count of image rows, count of image columns).\n        ";
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_31block_shapes(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("block_shapes (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_30block_shapes(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_30block_shapes(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  void *__pyx_v_hband;
  int __pyx_v_xsize;
  int __pyx_v_ysize;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("block_shapes", 0);
  __Pyx_TraceCall("block_shapes", __pyx_f[0], 348);

  /* "rasterio/_io.pyx":354
 *         shape: (count of image rows, count of image columns).
 *         """
 *         cdef void *hband = NULL             # <<<<<<<<<<<<<<
 *         cdef int xsize, ysize
 *         if not self._block_shapes:
 */
  __pyx_v_hband = NULL;

  /* "rasterio/_io.pyx":356
 *         cdef void *hband = NULL
 *         cdef int xsize, ysize
 *         if not self._block_shapes:             # <<<<<<<<<<<<<<
 *             if self._hds == NULL:
 *                 raise ValueError("can't read closed raster file")
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_block_shapes); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "rasterio/_io.pyx":357
 *         cdef int xsize, ysize
 *         if not self._block_shapes:
 *             if self._hds == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("can't read closed raster file")
 *             for i in range(self._count):
 */
    __pyx_t_2 = ((__pyx_v_self->_hds == NULL) != 0);
    if (__pyx_t_2) {

      /* "rasterio/_io.pyx":358
 *         if not self._block_shapes:
 *             if self._hds == NULL:
 *                 raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *             for i in range(self._count):
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 */
      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":359
 *             if self._hds == NULL:
 *                 raise ValueError("can't read closed raster file")
 *             for i in range(self._count):             # <<<<<<<<<<<<<<
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                 if hband == NULL:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_self->_count);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->_count);
    __Pyx_GIVEREF(__pyx_v_self->_count);
    __pyx_t_4 = PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) {
      __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (;;) {
      if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_3)) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_3)) {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_4 = __pyx_t_6(__pyx_t_3);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "rasterio/_io.pyx":360
 *                 raise ValueError("can't read closed raster file")
 *             for i in range(self._count):
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)             # <<<<<<<<<<<<<<
 *                 if hband == NULL:
 *                     raise ValueError("Null band")
 */
      __pyx_t_4 = PyNumber_Add(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_hband = GDALGetRasterBand(__pyx_v_self->_hds, __pyx_t_7);

      /* "rasterio/_io.pyx":361
 *             for i in range(self._count):
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                 if hband == NULL:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Null band")
 *                 _gdal.GDALGetBlockSize(hband, &xsize, &ysize)
 */
      __pyx_t_2 = ((__pyx_v_hband == NULL) != 0);
      if (__pyx_t_2) {

        /* "rasterio/_io.pyx":362
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                 if hband == NULL:
 *                     raise ValueError("Null band")             # <<<<<<<<<<<<<<
 *                 _gdal.GDALGetBlockSize(hband, &xsize, &ysize)
 *                 self._block_shapes.append((ysize, xsize))
 */
        __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

      /* "rasterio/_io.pyx":363
 *                 if hband == NULL:
 *                     raise ValueError("Null band")
 *                 _gdal.GDALGetBlockSize(hband, &xsize, &ysize)             # <<<<<<<<<<<<<<
 *                 self._block_shapes.append((ysize, xsize))
 *         return self._block_shapes
 */
      GDALGetBlockSize(__pyx_v_hband, (&__pyx_v_xsize), (&__pyx_v_ysize));

      /* "rasterio/_io.pyx":364
 *                     raise ValueError("Null band")
 *                 _gdal.GDALGetBlockSize(hband, &xsize, &ysize)
 *                 self._block_shapes.append((ysize, xsize))             # <<<<<<<<<<<<<<
 *         return self._block_shapes
 * 
 */
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_ysize); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_xsize); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      __pyx_t_4 = 0;
      __pyx_t_8 = 0;
      __pyx_t_10 = __Pyx_PyObject_Append(__pyx_v_self->_block_shapes, __pyx_t_9); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":365
 *                 _gdal.GDALGetBlockSize(hband, &xsize, &ysize)
 *                 self._block_shapes.append((ysize, xsize))
 *         return self._block_shapes             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_block_shapes);
  __pyx_r = __pyx_v_self->_block_shapes;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":348
 * 
 *     @property
 *     def block_shapes(self):             # <<<<<<<<<<<<<<
 *         """Returns an ordered list of block shapes for all bands.
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("rasterio._io.RasterReader.block_shapes", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":368
 * 
 *     @property
 *     def nodatavals(self):             # <<<<<<<<<<<<<<
 *         """Returns a band-ordered list of nodata values."""
 *         cdef void *hband = NULL
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_33nodatavals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_8rasterio_3_io_12RasterReader_32nodatavals[] = "Returns a band-ordered list of nodata values.";
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_33nodatavals(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("nodatavals (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_32nodatavals(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_32nodatavals(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  void *__pyx_v_hband;
  PyObject *__pyx_v_val = 0;
  int __pyx_v_success;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("nodatavals", 0);
  __Pyx_TraceCall("nodatavals", __pyx_f[0], 368);

  /* "rasterio/_io.pyx":370
 *     def nodatavals(self):
 *         """Returns a band-ordered list of nodata values."""
 *         cdef void *hband = NULL             # <<<<<<<<<<<<<<
 *         cdef object val
 *         cdef int success
 */
  __pyx_v_hband = NULL;

  /* "rasterio/_io.pyx":373
 *         cdef object val
 *         cdef int success
 *         if not self._nodatavals:             # <<<<<<<<<<<<<<
 *             if self._hds == NULL:
 *                 raise ValueError("can't read closed raster file")
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_nodatavals); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "rasterio/_io.pyx":374
 *         cdef int success
 *         if not self._nodatavals:
 *             if self._hds == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("can't read closed raster file")
 *             for i in range(self._count):
 */
    __pyx_t_2 = ((__pyx_v_self->_hds == NULL) != 0);
    if (__pyx_t_2) {

      /* "rasterio/_io.pyx":375
 *         if not self._nodatavals:
 *             if self._hds == NULL:
 *                 raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *             for i in range(self._count):
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 */
      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":376
 *             if self._hds == NULL:
 *                 raise ValueError("can't read closed raster file")
 *             for i in range(self._count):             # <<<<<<<<<<<<<<
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                 if hband == NULL:
 */
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_v_self->_count);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->_count);
    __Pyx_GIVEREF(__pyx_v_self->_count);
    __pyx_t_4 = PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) {
      __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
    } else {
      __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    for (;;) {
      if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_3)) {
        if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_3)) {
        if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_4 = __pyx_t_6(__pyx_t_3);
        if (unlikely(!__pyx_t_4)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "rasterio/_io.pyx":377
 *                 raise ValueError("can't read closed raster file")
 *             for i in range(self._count):
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)             # <<<<<<<<<<<<<<
 *                 if hband == NULL:
 *                     raise ValueError("Null band")
 */
      __pyx_t_4 = PyNumber_Add(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_hband = GDALGetRasterBand(__pyx_v_self->_hds, __pyx_t_7);

      /* "rasterio/_io.pyx":378
 *             for i in range(self._count):
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                 if hband == NULL:             # <<<<<<<<<<<<<<
 *                     raise ValueError("Null band")
 *                 val = _gdal.GDALGetRasterNoDataValue(hband, &success)
 */
      __pyx_t_2 = ((__pyx_v_hband == NULL) != 0);
      if (__pyx_t_2) {

        /* "rasterio/_io.pyx":379
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                 if hband == NULL:
 *                     raise ValueError("Null band")             # <<<<<<<<<<<<<<
 *                 val = _gdal.GDALGetRasterNoDataValue(hband, &success)
 *                 if not success:
 */
        __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__26, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

      /* "rasterio/_io.pyx":380
 *                 if hband == NULL:
 *                     raise ValueError("Null band")
 *                 val = _gdal.GDALGetRasterNoDataValue(hband, &success)             # <<<<<<<<<<<<<<
 *                 if not success:
 *                     val = None
 */
      __pyx_t_4 = PyFloat_FromDouble(GDALGetRasterNoDataValue(__pyx_v_hband, (&__pyx_v_success))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "rasterio/_io.pyx":381
 *                     raise ValueError("Null band")
 *                 val = _gdal.GDALGetRasterNoDataValue(hband, &success)
 *                 if not success:             # <<<<<<<<<<<<<<
 *                     val = None
 *                 self._nodatavals.append(val)
 */
      __pyx_t_2 = ((!(__pyx_v_success != 0)) != 0);
      if (__pyx_t_2) {

        /* "rasterio/_io.pyx":382
 *                 val = _gdal.GDALGetRasterNoDataValue(hband, &success)
 *                 if not success:
 *                     val = None             # <<<<<<<<<<<<<<
 *                 self._nodatavals.append(val)
 *         return self._nodatavals
 */
        __Pyx_INCREF(Py_None);
        __Pyx_DECREF_SET(__pyx_v_val, Py_None);
        goto __pyx_L8;
      }
      __pyx_L8:;

      /* "rasterio/_io.pyx":383
 *                 if not success:
 *                     val = None
 *                 self._nodatavals.append(val)             # <<<<<<<<<<<<<<
 *         return self._nodatavals
 * 
 */
      __pyx_t_8 = __Pyx_PyObject_Append(__pyx_v_self->_nodatavals, __pyx_v_val); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":384
 *                     val = None
 *                 self._nodatavals.append(val)
 *         return self._nodatavals             # <<<<<<<<<<<<<<
 * 
 *     def block_windows(self, bdix):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_nodatavals);
  __pyx_r = __pyx_v_self->_nodatavals;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":368
 * 
 *     @property
 *     def nodatavals(self):             # <<<<<<<<<<<<<<
 *         """Returns a band-ordered list of nodata values."""
 *         cdef void *hband = NULL
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("rasterio._io.RasterReader.nodatavals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_val);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_8rasterio_3_io_12RasterReader_36generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */

/* "rasterio/_io.pyx":386
 *         return self._nodatavals
 * 
 *     def block_windows(self, bdix):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over a band's block windows and their
 *         indexes.
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_35block_windows(PyObject *__pyx_v_self, PyObject *__pyx_v_bdix); /*proto*/
static char __pyx_doc_8rasterio_3_io_12RasterReader_34block_windows[] = "Returns an iterator over a band's block windows and their\n        indexes.\n\n        The positional parameter `bidx` takes the index (starting at 1)\n        of the desired band. Block windows are tuples\n\n            ((row_start, row_stop), (col_start, col_stop))\n\n        For example, ((0, 2), (0, 2)) defines a 2 x 2 block at the upper\n        left corner of the raster dataset.\n\n        This iterator yields blocks \"left to right\" and \"top to bottom\"\n        and is similar to Python's enumerate() in that it also returns\n        indexes.\n\n        The primary use of this function is to obtain windows to pass to\n        read_band() for highly efficient access to raster block data.\n        ";
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_35block_windows(PyObject *__pyx_v_self, PyObject *__pyx_v_bdix) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("block_windows (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_34block_windows(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), ((PyObject *)__pyx_v_bdix));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_34block_windows(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_bdix) {
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("block_windows", 0);
  __pyx_cur_scope = (struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows *)__pyx_tp_new_8rasterio_3_io___pyx_scope_struct_2_block_windows(__pyx_ptype_8rasterio_3_io___pyx_scope_struct_2_block_windows, __pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __Pyx_GOTREF(__pyx_cur_scope);
  __Pyx_TraceCall("block_windows", __pyx_f[0], 386);
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_bdix = __pyx_v_bdix;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_bdix);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_bdix);
  {
    __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_8rasterio_3_io_12RasterReader_36generator, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("rasterio._io.RasterReader.block_windows", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_8rasterio_3_io_12RasterReader_36generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows *__pyx_cur_scope = ((struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *(*__pyx_t_5)(PyObject *);
  long __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  long __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("None", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L14_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "rasterio/_io.pyx":406
 *         """
 *         cdef int i, j
 *         h, w = self.block_shapes[bdix-1]             # <<<<<<<<<<<<<<
 *         d, m = divmod(self.height, h)
 *         nrows = d + int(m>0)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_block_shapes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_bdix, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetItem(__pyx_t_1, __pyx_t_2); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_1);
    #else
    __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    index = 1; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L4_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L5_unpacking_done;
    __pyx_L4_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L5_unpacking_done:;
  }
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_h = __pyx_t_2;
  __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_w = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":407
 *         cdef int i, j
 *         h, w = self.block_shapes[bdix-1]
 *         d, m = divmod(self.height, h)             # <<<<<<<<<<<<<<
 *         nrows = d + int(m>0)
 *         d, m = divmod(self.width, w)
 */
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_self->height;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_1 = PyNumber_Divmod(__pyx_t_3, __pyx_cur_scope->__pyx_v_h); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
    PyObject* sequence = __pyx_t_1;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    index = 1; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L6_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L7_unpacking_done;
    __pyx_L6_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L7_unpacking_done:;
  }
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_d = __pyx_t_3;
  __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_m = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":408
 *         h, w = self.block_shapes[bdix-1]
 *         d, m = divmod(self.height, h)
 *         nrows = d + int(m>0)             # <<<<<<<<<<<<<<
 *         d, m = divmod(self.width, w)
 *         ncols = d + int(m>0)
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_m, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(__pyx_cur_scope->__pyx_v_d, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_nrows = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":409
 *         d, m = divmod(self.height, h)
 *         nrows = d + int(m>0)
 *         d, m = divmod(self.width, w)             # <<<<<<<<<<<<<<
 *         ncols = d + int(m>0)
 *         for j in range(nrows):
 */
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->width;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Divmod(__pyx_t_1, __pyx_cur_scope->__pyx_v_w); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_3);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L8_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L8_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = NULL;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L9_unpacking_done;
    __pyx_L8_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L9_unpacking_done:;
  }
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_d);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_d, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_m);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_m, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "rasterio/_io.pyx":410
 *         nrows = d + int(m>0)
 *         d, m = divmod(self.width, w)
 *         ncols = d + int(m>0)             # <<<<<<<<<<<<<<
 *         for j in range(nrows):
 *             row = j * h
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_m, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_cur_scope->__pyx_v_d, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_ncols = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":411
 *         d, m = divmod(self.width, w)
 *         ncols = d + int(m>0)
 *         for j in range(nrows):             # <<<<<<<<<<<<<<
 *             row = j * h
 *             height = min(h, self.height - row)
 */
  __pyx_t_6 = __Pyx_PyInt_As_long(__pyx_cur_scope->__pyx_v_nrows); if (unlikely((__pyx_t_6 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
    __pyx_cur_scope->__pyx_v_j = __pyx_t_7;

    /* "rasterio/_io.pyx":412
 *         ncols = d + int(m>0)
 *         for j in range(nrows):
 *             row = j * h             # <<<<<<<<<<<<<<
 *             height = min(h, self.height - row)
 *             for i in range(ncols):
 */
    __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_j); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyNumber_Multiply(__pyx_t_2, __pyx_cur_scope->__pyx_v_h); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_row);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_row, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;

    /* "rasterio/_io.pyx":413
 *         for j in range(nrows):
 *             row = j * h
 *             height = min(h, self.height - row)             # <<<<<<<<<<<<<<
 *             for i in range(ncols):
 *                 col = i * w
 */
    __pyx_t_3 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_self->height, __pyx_cur_scope->__pyx_v_row); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_h);
    __pyx_t_2 = __pyx_cur_scope->__pyx_v_h;
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_8) {
      __Pyx_INCREF(__pyx_t_3);
      __pyx_t_1 = __pyx_t_3;
    } else {
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_1 = __pyx_t_2;
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __pyx_t_1;
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_height);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_height, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;

    /* "rasterio/_io.pyx":414
 *             row = j * h
 *             height = min(h, self.height - row)
 *             for i in range(ncols):             # <<<<<<<<<<<<<<
 *                 col = i * w
 *                 width = min(w, self.width - col)
 */
    __pyx_t_9 = __Pyx_PyInt_As_long(__pyx_cur_scope->__pyx_v_ncols); if (unlikely((__pyx_t_9 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
      __pyx_cur_scope->__pyx_v_i = __pyx_t_10;

      /* "rasterio/_io.pyx":415
 *             height = min(h, self.height - row)
 *             for i in range(ncols):
 *                 col = i * w             # <<<<<<<<<<<<<<
 *                 width = min(w, self.width - col)
 *                 yield (j, i), ((row, row+height), (col, col+width))
 */
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyNumber_Multiply(__pyx_t_3, __pyx_cur_scope->__pyx_v_w); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_col);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_col, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;

      /* "rasterio/_io.pyx":416
 *             for i in range(ncols):
 *                 col = i * w
 *                 width = min(w, self.width - col)             # <<<<<<<<<<<<<<
 *                 yield (j, i), ((row, row+height), (col, col+width))
 * 
 */
      __pyx_t_1 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_self->width, __pyx_cur_scope->__pyx_v_col); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_w);
      __pyx_t_3 = __pyx_cur_scope->__pyx_v_w;
      __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_8) {
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_2 = __pyx_t_1;
      } else {
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_2 = __pyx_t_3;
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __pyx_t_2;
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_width);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_width, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_t_1 = 0;

      /* "rasterio/_io.pyx":417
 *                 col = i * w
 *                 width = min(w, self.width - col)
 *                 yield (j, i), ((row, row+height), (col, col+width))             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_Add(__pyx_cur_scope->__pyx_v_row, __pyx_cur_scope->__pyx_v_height); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_row);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_row);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_row);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_Add(__pyx_cur_scope->__pyx_v_col, __pyx_cur_scope->__pyx_v_width); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_col);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_cur_scope->__pyx_v_col);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_col);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_t_1 = 0;
      __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_3 = 0;
      __pyx_t_2 = 0;
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
      __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
      __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
      __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      /* return from generator, yielding value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L14_resume_from_yield:;
      __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
      __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
      __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
      __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
      if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }

  /* "rasterio/_io.pyx":386
 *         return self._nodatavals
 * 
 *     def block_windows(self, bdix):             # <<<<<<<<<<<<<<
 *         """Returns an iterator over a band's block windows and their
 *         indexes.
 */

  /* function exit code */
  PyErr_SetNone(PyExc_StopIteration);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("block_windows", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_generator->resume_label = -1;
  __Pyx_Generator_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return NULL;
}

/* "rasterio/_io.pyx":420
 * 
 *     @property
 *     def bounds(self):             # <<<<<<<<<<<<<<
 *         """Returns the lower left and upper right bounds of the dataset
 *         in the units of its coordinate reference system.
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_38bounds(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_8rasterio_3_io_12RasterReader_37bounds[] = "Returns the lower left and upper right bounds of the dataset\n        in the units of its coordinate reference system.\n        \n        The returned value is a tuple:\n        (lower left x, lower left y, upper right x, upper right y)\n        ";
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_38bounds(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bounds (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_37bounds(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_37bounds(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("bounds", 0);
  __Pyx_TraceCall("bounds", __pyx_f[0], 420);

  /* "rasterio/_io.pyx":427
 *         (lower left x, lower left y, upper right x, upper right y)
 *         """
 *         t = self.transform             # <<<<<<<<<<<<<<
 *         return (t[0], t[3]+t[5]*self.height, t[0]+t[1]*self.width, t[3])
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_t = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":428
 *         """
 *         t = self.transform
 *         return (t[0], t[3]+t[5]*self.height, t[0]+t[1]*self.width, t[3])             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_t, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_t, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_t, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_v_self->height); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_t, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_t, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_2, __pyx_v_self->width); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_t, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":420
 * 
 *     @property
 *     def bounds(self):             # <<<<<<<<<<<<<<
 *         """Returns the lower left and upper right bounds of the dataset
 *         in the units of its coordinate reference system.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("rasterio._io.RasterReader.bounds", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":431
 * 
 *     @property
 *     def res(self):             # <<<<<<<<<<<<<<
 *         """Returns the (width, height) of pixels in the units of its
 *         coordinate reference system."""
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_40res(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_8rasterio_3_io_12RasterReader_39res[] = "Returns the (width, height) of pixels in the units of its\n        coordinate reference system.";
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_40res(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("res (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_39res(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_39res(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("res", 0);
  __Pyx_TraceCall("res", __pyx_f[0], 431);

  /* "rasterio/_io.pyx":434
 *         """Returns the (width, height) of pixels in the units of its
 *         coordinate reference system."""
 *         t = self.transform             # <<<<<<<<<<<<<<
 *         if t[2] == t[4] == 0:
 *             return t[1], -t[5]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_t = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":435
 *         coordinate reference system."""
 *         t = self.transform
 *         if t[2] == t[4] == 0:             # <<<<<<<<<<<<<<
 *             return t[1], -t[5]
 *         return math.sqrt(t[1]*t[1]+t[4]*t[4]), math.sqrt(t[2]*t[2]+t[5]*t[5])
 */
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_t, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_t, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_PyObject_IsTrue(__pyx_t_3)) {
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "rasterio/_io.pyx":436
 *         t = self.transform
 *         if t[2] == t[4] == 0:
 *             return t[1], -t[5]             # <<<<<<<<<<<<<<
 *         return math.sqrt(t[1]*t[1]+t[4]*t[4]), math.sqrt(t[2]*t[2]+t[5]*t[5])
 * 
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_t, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_t, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyNumber_Negative(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_3 = 0;
    __pyx_t_1 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }

  /* "rasterio/_io.pyx":437
 *         if t[2] == t[4] == 0:
 *             return t[1], -t[5]
 *         return math.sqrt(t[1]*t[1]+t[4]*t[4]), math.sqrt(t[2]*t[2]+t[5]*t[5])             # <<<<<<<<<<<<<<
 * 
 *     def ul(self, row, col):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_math); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_t, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_t, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_t, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_t, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyNumber_Multiply(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Add(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_math); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_t, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_t, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_t, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_t, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyNumber_Multiply(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Add(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_2 = 0;
  __pyx_t_6 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":431
 * 
 *     @property
 *     def res(self):             # <<<<<<<<<<<<<<
 *         """Returns the (width, height) of pixels in the units of its
 *         coordinate reference system."""
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("rasterio._io.RasterReader.res", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":439
 *         return math.sqrt(t[1]*t[1]+t[4]*t[4]), math.sqrt(t[2]*t[2]+t[5]*t[5])
 * 
 *     def ul(self, row, col):             # <<<<<<<<<<<<<<
 *         """Returns the coordinates (x, y) of the upper left corner of a
 *         pixel at `row` and `col` in the units of the dataset's
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_42ul(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8rasterio_3_io_12RasterReader_41ul[] = "Returns the coordinates (x, y) of the upper left corner of a \n        pixel at `row` and `col` in the units of the dataset's\n        coordinate reference system.\n        ";
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_42ul(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_row = 0;
  PyObject *__pyx_v_col = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ul (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_row,&__pyx_n_s_col,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_row)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_col)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("ul", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "ul") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_row = values[0];
    __pyx_v_col = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("ul", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("rasterio._io.RasterReader.ul", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_41ul(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), __pyx_v_row, __pyx_v_col);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_41ul(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_row, PyObject *__pyx_v_col) {
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("ul", 0);
  __Pyx_TraceCall("ul", __pyx_f[0], 439);
  __Pyx_INCREF(__pyx_v_row);
  __Pyx_INCREF(__pyx_v_col);

  /* "rasterio/_io.pyx":444
 *         coordinate reference system.
 *         """
 *         t = self.transform             # <<<<<<<<<<<<<<
 *         if col < 0:
 *             col += self.width
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_t = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":445
 *         """
 *         t = self.transform
 *         if col < 0:             # <<<<<<<<<<<<<<
 *             col += self.width
 *         if row < 0:
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_col, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "rasterio/_io.pyx":446
 *         t = self.transform
 *         if col < 0:
 *             col += self.width             # <<<<<<<<<<<<<<
 *         if row < 0:
 *             row += self.height
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_col, __pyx_v_self->width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_col, __pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":447
 *         if col < 0:
 *             col += self.width
 *         if row < 0:             # <<<<<<<<<<<<<<
 *             row += self.height
 *         return t[0]+t[1]*col, t[3]+t[5]*row
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_row, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "rasterio/_io.pyx":448
 *             col += self.width
 *         if row < 0:
 *             row += self.height             # <<<<<<<<<<<<<<
 *         return t[0]+t[1]*col, t[3]+t[5]*row
 * 
 */
    __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_row, __pyx_v_self->height); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_row, __pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "rasterio/_io.pyx":449
 *         if row < 0:
 *             row += self.height
 *         return t[0]+t[1]*col, t[3]+t[5]*row             # <<<<<<<<<<<<<<
 * 
 *     def index(self, x, y):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_t, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_t, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_v_col); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_t, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_t, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_1, __pyx_v_row); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_3 = 0;
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":439
 *         return math.sqrt(t[1]*t[1]+t[4]*t[4]), math.sqrt(t[2]*t[2]+t[5]*t[5])
 * 
 *     def ul(self, row, col):             # <<<<<<<<<<<<<<
 *         """Returns the coordinates (x, y) of the upper left corner of a
 *         pixel at `row` and `col` in the units of the dataset's
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("rasterio._io.RasterReader.ul", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XDECREF(__pyx_v_row);
  __Pyx_XDECREF(__pyx_v_col);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":451
 *         return t[0]+t[1]*col, t[3]+t[5]*row
 * 
 *     def index(self, x, y):             # <<<<<<<<<<<<<<
 *         """Returns the (row, col) index of the pixel containing (x, y)."""
 *         t = self.transform
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_44index(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8rasterio_3_io_12RasterReader_43index[] = "Returns the (row, col) index of the pixel containing (x, y).";
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_44index(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_x = 0;
  PyObject *__pyx_v_y = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("index (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("index", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_x = values[0];
    __pyx_v_y = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("index", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("rasterio._io.RasterReader.index", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_43index(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), __pyx_v_x, __pyx_v_y);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_43index(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y) {
  PyObject *__pyx_v_t = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("index", 0);
  __Pyx_TraceCall("index", __pyx_f[0], 451);

  /* "rasterio/_io.pyx":453
 *     def index(self, x, y):
 *         """Returns the (row, col) index of the pixel containing (x, y)."""
 *         t = self.transform             # <<<<<<<<<<<<<<
 *         return int((t[3]-y)/t[5]), int((x-t[0])/t[1])
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_t = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":454
 *         """Returns the (row, col) index of the pixel containing (x, y)."""
 *         t = self.transform
 *         return int((t[3]-y)/t[5]), int((x-t[0])/t[1])             # <<<<<<<<<<<<<<
 * 
 *     @property
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_t, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Subtract(__pyx_t_1, __pyx_v_y); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_t, 5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_t, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyNumber_Subtract(__pyx_v_x, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_t, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":451
 *         return t[0]+t[1]*col, t[3]+t[5]*row
 * 
 *     def index(self, x, y):             # <<<<<<<<<<<<<<
 *         """Returns the (row, col) index of the pixel containing (x, y)."""
 *         t = self.transform
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("rasterio._io.RasterReader.index", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":457
 * 
 *     @property
 *     def meta(self):             # <<<<<<<<<<<<<<
 *         m = {
 *             'driver': self.driver,
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_46meta(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_46meta(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("meta (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_45meta(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_45meta(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_v_m = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("meta", 0);
  __Pyx_TraceCall("meta", __pyx_f[0], 457);

  /* "rasterio/_io.pyx":458
 *     @property
 *     def meta(self):
 *         m = {             # <<<<<<<<<<<<<<
 *             'driver': self.driver,
 *             'dtype': set(self.dtypes).pop(),
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "rasterio/_io.pyx":459
 *     def meta(self):
 *         m = {
 *             'driver': self.driver,             # <<<<<<<<<<<<<<
 *             'dtype': set(self.dtypes).pop(),
 *             'nodata': set(self.nodatavals).pop(),
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_driver, __pyx_v_self->driver) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "rasterio/_io.pyx":460
 *         m = {
 *             'driver': self.driver,
 *             'dtype': set(self.dtypes).pop(),             # <<<<<<<<<<<<<<
 *             'nodata': set(self.nodatavals).pop(),
 *             'width': self.width,
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dtypes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PySet_Type))), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PySet_Pop(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "rasterio/_io.pyx":461
 *             'driver': self.driver,
 *             'dtype': set(self.dtypes).pop(),
 *             'nodata': set(self.nodatavals).pop(),             # <<<<<<<<<<<<<<
 *             'width': self.width,
 *             'height': self.height,
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_nodatavals); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PySet_Type))), __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PySet_Pop(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_nodata, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":462
 *             'dtype': set(self.dtypes).pop(),
 *             'nodata': set(self.nodatavals).pop(),
 *             'width': self.width,             # <<<<<<<<<<<<<<
 *             'height': self.height,
 *             'count': self.count,
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_width, __pyx_v_self->width) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "rasterio/_io.pyx":463
 *             'nodata': set(self.nodatavals).pop(),
 *             'width': self.width,
 *             'height': self.height,             # <<<<<<<<<<<<<<
 *             'count': self.count,
 *             'crs': self.crs,
 */
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_height, __pyx_v_self->height) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "rasterio/_io.pyx":464
 *             'width': self.width,
 *             'height': self.height,
 *             'count': self.count,             # <<<<<<<<<<<<<<
 *             'crs': self.crs,
 *             'transform': self.transform }
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_count, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":465
 *             'height': self.height,
 *             'count': self.count,
 *             'crs': self.crs,             # <<<<<<<<<<<<<<
 *             'transform': self.transform }
 *         self._read = True
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_crs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_crs, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":466
 *             'count': self.count,
 *             'crs': self.crs,
 *             'transform': self.transform }             # <<<<<<<<<<<<<<
 *         self._read = True
 *         return m
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_transform); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_transform, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_m = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":467
 *             'crs': self.crs,
 *             'transform': self.transform }
 *         self._read = True             # <<<<<<<<<<<<<<
 *         return m
 * 
 */
  __Pyx_INCREF(Py_True);
  __Pyx_GIVEREF(Py_True);
  __Pyx_GOTREF(__pyx_v_self->_read);
  __Pyx_DECREF(__pyx_v_self->_read);
  __pyx_v_self->_read = Py_True;

  /* "rasterio/_io.pyx":468
 *             'transform': self.transform }
 *         self._read = True
 *         return m             # <<<<<<<<<<<<<<
 * 
 *     def get_crs(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_m);
  __pyx_r = __pyx_v_m;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":457
 * 
 *     @property
 *     def meta(self):             # <<<<<<<<<<<<<<
 *         m = {
 *             'driver': self.driver,
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("rasterio._io.RasterReader.meta", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_m);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":470
 *         return m
 * 
 *     def get_crs(self):             # <<<<<<<<<<<<<<
 *         # _read tells us that the CRS was read before and really is
 *         # None.
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_48get_crs(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_48get_crs(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_crs (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_47get_crs(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_47get_crs(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("get_crs", 0);
  __Pyx_TraceCall("get_crs", __pyx_f[0], 470);

  /* "rasterio/_io.pyx":473
 *         # _read tells us that the CRS was read before and really is
 *         # None.
 *         if not self._read and self._crs is None:             # <<<<<<<<<<<<<<
 *             self._crs = self.read_crs()
 *         return self._crs
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_read); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {
    __pyx_t_1 = (__pyx_v_self->_crs == Py_None);
    __pyx_t_3 = (__pyx_t_1 != 0);
  } else {
    __pyx_t_3 = __pyx_t_2;
  }
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":474
 *         # None.
 *         if not self._read and self._crs is None:
 *             self._crs = self.read_crs()             # <<<<<<<<<<<<<<
 *         return self._crs
 *     crs = property(get_crs)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_crs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_v_self->_crs);
    __Pyx_DECREF(__pyx_v_self->_crs);
    __pyx_v_self->_crs = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":475
 *         if not self._read and self._crs is None:
 *             self._crs = self.read_crs()
 *         return self._crs             # <<<<<<<<<<<<<<
 *     crs = property(get_crs)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_crs);
  __pyx_r = __pyx_v_self->_crs;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":470
 *         return m
 * 
 *     def get_crs(self):             # <<<<<<<<<<<<<<
 *         # _read tells us that the CRS was read before and really is
 *         # None.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("rasterio._io.RasterReader.get_crs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":478
 *     crs = property(get_crs)
 * 
 *     def get_crs_wkt(self):             # <<<<<<<<<<<<<<
 *         if not self._read and self._crs_wkt is None:
 *             self._crs = self.read_crs_wkt()
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_50get_crs_wkt(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_50get_crs_wkt(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_crs_wkt (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_49get_crs_wkt(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_49get_crs_wkt(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("get_crs_wkt", 0);
  __Pyx_TraceCall("get_crs_wkt", __pyx_f[0], 478);

  /* "rasterio/_io.pyx":479
 * 
 *     def get_crs_wkt(self):
 *         if not self._read and self._crs_wkt is None:             # <<<<<<<<<<<<<<
 *             self._crs = self.read_crs_wkt()
 *         return self._crs_wkt
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_read); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {
    __pyx_t_1 = (__pyx_v_self->_crs_wkt == Py_None);
    __pyx_t_3 = (__pyx_t_1 != 0);
  } else {
    __pyx_t_3 = __pyx_t_2;
  }
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":480
 *     def get_crs_wkt(self):
 *         if not self._read and self._crs_wkt is None:
 *             self._crs = self.read_crs_wkt()             # <<<<<<<<<<<<<<
 *         return self._crs_wkt
 *     crs_wkt = property(get_crs_wkt)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_crs_wkt); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_v_self->_crs);
    __Pyx_DECREF(__pyx_v_self->_crs);
    __pyx_v_self->_crs = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":481
 *         if not self._read and self._crs_wkt is None:
 *             self._crs = self.read_crs_wkt()
 *         return self._crs_wkt             # <<<<<<<<<<<<<<
 *     crs_wkt = property(get_crs_wkt)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_crs_wkt);
  __pyx_r = __pyx_v_self->_crs_wkt;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":478
 *     crs = property(get_crs)
 * 
 *     def get_crs_wkt(self):             # <<<<<<<<<<<<<<
 *         if not self._read and self._crs_wkt is None:
 *             self._crs = self.read_crs_wkt()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("rasterio._io.RasterReader.get_crs_wkt", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":484
 *     crs_wkt = property(get_crs_wkt)
 * 
 *     def get_transform(self):             # <<<<<<<<<<<<<<
 *         """Get an affine transformation that maps pixel row/column
 *         coordinates to coordinates in the specified crs. The affine
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_52get_transform(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_8rasterio_3_io_12RasterReader_51get_transform[] = "Get an affine transformation that maps pixel row/column\n        coordinates to coordinates in the specified crs. The affine\n        transformation is represented by a six-element sequence.\n        Reference system coordinates can be calculated by the following\n        formula\n\n          X = Item 0 + Column * Item 1 + Row * Item 2\n          Y = Item 3 + Column * Item 4 + Row * Item 5\n\n        See also this class's ul() method.\n        ";
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_52get_transform(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_transform (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_51get_transform(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_51get_transform(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("get_transform", 0);
  __Pyx_TraceCall("get_transform", __pyx_f[0], 484);

  /* "rasterio/_io.pyx":496
 *         See also this class's ul() method.
 *         """
 *         if not self._read and self._transform is None:             # <<<<<<<<<<<<<<
 *             self._transform = self.read_transform()
 *         return self._transform
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->_read); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {
    __pyx_t_1 = (__pyx_v_self->_transform == Py_None);
    __pyx_t_3 = (__pyx_t_1 != 0);
  } else {
    __pyx_t_3 = __pyx_t_2;
  }
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":497
 *         """
 *         if not self._read and self._transform is None:
 *             self._transform = self.read_transform()             # <<<<<<<<<<<<<<
 *         return self._transform
 *     transform = property(get_transform)
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_transform); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GIVEREF(__pyx_t_5);
    __Pyx_GOTREF(__pyx_v_self->_transform);
    __Pyx_DECREF(__pyx_v_self->_transform);
    __pyx_v_self->_transform = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":498
 *         if not self._read and self._transform is None:
 *             self._transform = self.read_transform()
 *         return self._transform             # <<<<<<<<<<<<<<
 *     transform = property(get_transform)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_transform);
  __pyx_r = __pyx_v_self->_transform;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":484
 *     crs_wkt = property(get_crs_wkt)
 * 
 *     def get_transform(self):             # <<<<<<<<<<<<<<
 *         """Get an affine transformation that maps pixel row/column
 *         coordinates to coordinates in the specified crs. The affine
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("rasterio._io.RasterReader.get_transform", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":501
 *     transform = property(get_transform)
 * 
 *     def read_band(self, bidx, out=None, window=None):             # <<<<<<<<<<<<<<
 *         """Read the `bidx` band into an `out` array if provided,
 *         otherwise return a new array.
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_54read_band(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8rasterio_3_io_12RasterReader_53read_band[] = "Read the `bidx` band into an `out` array if provided, \n        otherwise return a new array.\n\n        Band indexes begin with 1: read_band(1) returns the first band.\n\n        The optional `window` argument is a 2 item tuple. The first item\n        is a tuple containing the indexes of the rows at which the\n        window starts and stops and the second is a tuple containing the\n        indexes of the columns at which the window starts and stops. For\n        example, ((0, 2), (0, 2)) defines a 2x2 window at the upper left\n        of the raster dataset.\n        ";
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_54read_band(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bidx = 0;
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_window = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("read_band (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bidx,&__pyx_n_s_out,&__pyx_n_s_window,0};
    PyObject* values[3] = {0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bidx)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_band") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_bidx = values[0];
    __pyx_v_out = values[1];
    __pyx_v_window = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("read_band", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("rasterio._io.RasterReader.read_band", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_53read_band(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), __pyx_v_bidx, __pyx_v_out, __pyx_v_window);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_53read_band(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_bidx, PyObject *__pyx_v_out, PyObject *__pyx_v_window) {
  PyObject *__pyx_v_i = NULL;
  void *__pyx_v_hband;
  PyObject *__pyx_v_dtype = NULL;
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_yoff = NULL;
  PyObject *__pyx_v_xoff = NULL;
  PyObject *__pyx_v_height = NULL;
  PyObject *__pyx_v_width = NULL;
  CYTHON_UNUSED int __pyx_v_retval;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("read_band", 0);
  __Pyx_TraceCall("read_band", __pyx_f[0], 501);
  __Pyx_INCREF(__pyx_v_out);
  __Pyx_INCREF(__pyx_v_window);

  /* "rasterio/_io.pyx":514
 *         of the raster dataset.
 *         """
 *         if bidx not in self.indexes:             # <<<<<<<<<<<<<<
 *             raise IndexError("band index out of range")
 *         i = self.indexes.index(bidx)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_indexes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_Contains(__pyx_v_bidx, __pyx_t_1, Py_NE)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":515
 *         """
 *         if bidx not in self.indexes:
 *             raise IndexError("band index out of range")             # <<<<<<<<<<<<<<
 *         i = self.indexes.index(bidx)
 *         if self._hds == NULL:
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":516
 *         if bidx not in self.indexes:
 *             raise IndexError("band index out of range")
 *         i = self.indexes.index(bidx)             # <<<<<<<<<<<<<<
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_indexes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_index); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_bidx);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_bidx);
  __Pyx_GIVEREF(__pyx_v_bidx);
  __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_i = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "rasterio/_io.pyx":517
 *             raise IndexError("band index out of range")
 *         i = self.indexes.index(bidx)
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("can't read closed raster file")
 *         if out is not None and out.dtype != self.dtypes[i]:
 */
  __pyx_t_3 = ((__pyx_v_self->_hds == NULL) != 0);
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":518
 *         i = self.indexes.index(bidx)
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *         if out is not None and out.dtype != self.dtypes[i]:
 *             raise ValueError(
 */
    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":519
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")
 *         if out is not None and out.dtype != self.dtypes[i]:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 "the array's dtype '%s' does not match "
 */
  __pyx_t_3 = (__pyx_v_out != Py_None);
  if (__pyx_t_3) {
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dtypes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_v_i); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_5, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __pyx_t_2;
  } else {
    __pyx_t_6 = __pyx_t_3;
  }
  if (__pyx_t_6) {

    /* "rasterio/_io.pyx":522
 *             raise ValueError(
 *                 "the array's dtype '%s' does not match "
 *                 "the file's dtype '%s'" % (out.dtype, self.dtypes[i]))             # <<<<<<<<<<<<<<
 * 
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_out, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_GetItem(__pyx_t_4, __pyx_v_i); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_the_array_s_dtype_s_does_not_mat, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "rasterio/_io.pyx":520
 *             raise ValueError("can't read closed raster file")
 *         if out is not None and out.dtype != self.dtypes[i]:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 "the array's dtype '%s' does not match "
 *                 "the file's dtype '%s'" % (out.dtype, self.dtypes[i]))
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":524
 *                 "the file's dtype '%s'" % (out.dtype, self.dtypes[i]))
 * 
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)             # <<<<<<<<<<<<<<
 *         if hband == NULL:
 *             raise ValueError("NULL band")
 */
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_bidx); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_hband = GDALGetRasterBand(__pyx_v_self->_hds, __pyx_t_7);

  /* "rasterio/_io.pyx":525
 * 
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 *         if hband == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("NULL band")
 * 
 */
  __pyx_t_6 = ((__pyx_v_hband == NULL) != 0);
  if (__pyx_t_6) {

    /* "rasterio/_io.pyx":526
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 *         if hband == NULL:
 *             raise ValueError("NULL band")             # <<<<<<<<<<<<<<
 * 
 *         dtype = self.dtypes[i]
 */
    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":528
 *             raise ValueError("NULL band")
 * 
 *         dtype = self.dtypes[i]             # <<<<<<<<<<<<<<
 *         if out is None:
 *             out_shape = (
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dtypes); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyObject_GetItem(__pyx_t_5, __pyx_v_i); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_dtype = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "rasterio/_io.pyx":529
 * 
 *         dtype = self.dtypes[i]
 *         if out is None:             # <<<<<<<<<<<<<<
 *             out_shape = (
 *                 window
 */
  __pyx_t_6 = (__pyx_v_out == Py_None);
  __pyx_t_3 = (__pyx_t_6 != 0);
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":532
 *             out_shape = (
 *                 window
 *                 and window_shape(window, self.height, self.width)             # <<<<<<<<<<<<<<
 *                 or self.shape)
 *             out = np.zeros(out_shape, dtype)
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_window); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_3) {
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_window_shape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_window);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_window);
      __Pyx_GIVEREF(__pyx_v_window);
      __Pyx_INCREF(__pyx_v_self->height);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_self->height);
      __Pyx_GIVEREF(__pyx_v_self->height);
      __Pyx_INCREF(__pyx_v_self->width);
      PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_self->width);
      __Pyx_GIVEREF(__pyx_v_self->width);
      __pyx_t_1 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __pyx_t_1;
      __pyx_t_1 = 0;
    } else {
      __Pyx_INCREF(__pyx_v_window);
      __pyx_t_5 = __pyx_v_window;
    }
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!__pyx_t_3) {
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "rasterio/_io.pyx":533
 *                 window
 *                 and window_shape(window, self.height, self.width)
 *                 or self.shape)             # <<<<<<<<<<<<<<
 *             out = np.zeros(out_shape, dtype)
 *         if window:
 */
      __Pyx_INCREF(__pyx_v_self->shape);
      __pyx_t_1 = __pyx_v_self->shape;
    } else {
      __pyx_t_1 = __pyx_t_5;
      __pyx_t_5 = 0;
    }
    __pyx_v_out_shape = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "rasterio/_io.pyx":534
 *                 and window_shape(window, self.height, self.width)
 *                 or self.shape)
 *             out = np.zeros(out_shape, dtype)             # <<<<<<<<<<<<<<
 *         if window:
 *             window = eval_window(window, self.height, self.width)
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_out_shape);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_out_shape);
    __Pyx_GIVEREF(__pyx_v_out_shape);
    __Pyx_INCREF(__pyx_v_dtype);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_dtype);
    __Pyx_GIVEREF(__pyx_v_dtype);
    __pyx_t_4 = PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF_SET(__pyx_v_out, __pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "rasterio/_io.pyx":535
 *                 or self.shape)
 *             out = np.zeros(out_shape, dtype)
 *         if window:             # <<<<<<<<<<<<<<
 *             window = eval_window(window, self.height, self.width)
 *             yoff = window[0][0]
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_window); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":536
 *             out = np.zeros(out_shape, dtype)
 *         if window:
 *             window = eval_window(window, self.height, self.width)             # <<<<<<<<<<<<<<
 *             yoff = window[0][0]
 *             xoff = window[1][0]
 */
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_self->height); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_self->width); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __pyx_f_8rasterio_3_io_eval_window(__pyx_v_window, __pyx_t_7, __pyx_t_8, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF_SET(__pyx_v_window, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "rasterio/_io.pyx":537
 *         if window:
 *             window = eval_window(window, self.height, self.width)
 *             yoff = window[0][0]             # <<<<<<<<<<<<<<
 *             xoff = window[1][0]
 *             height = window[0][1] - yoff
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_window, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_yoff = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "rasterio/_io.pyx":538
 *             window = eval_window(window, self.height, self.width)
 *             yoff = window[0][0]
 *             xoff = window[1][0]             # <<<<<<<<<<<<<<
 *             height = window[0][1] - yoff
 *             width = window[1][1] - xoff
 */
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_window, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_xoff = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "rasterio/_io.pyx":539
 *             yoff = window[0][0]
 *             xoff = window[1][0]
 *             height = window[0][1] - yoff             # <<<<<<<<<<<<<<
 *             width = window[1][1] - xoff
 *         else:
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_window, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Subtract(__pyx_t_1, __pyx_v_yoff); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_height = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "rasterio/_io.pyx":540
 *             xoff = window[1][0]
 *             height = window[0][1] - yoff
 *             width = window[1][1] - xoff             # <<<<<<<<<<<<<<
 *         else:
 *             xoff = yoff = 0
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_window, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Subtract(__pyx_t_1, __pyx_v_xoff); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_width = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L8;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":542
 *             width = window[1][1] - xoff
 *         else:
 *             xoff = yoff = 0             # <<<<<<<<<<<<<<
 *             width = self.width
 *             height = self.height
 */
    __pyx_t_4 = __Pyx_PyInt_From_long(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_xoff = __pyx_t_4;
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyInt_From_long(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_v_yoff = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "rasterio/_io.pyx":543
 *         else:
 *             xoff = yoff = 0
 *             width = self.width             # <<<<<<<<<<<<<<
 *             height = self.height
 *         if dtype == dtypes.ubyte:
 */
    __pyx_t_4 = __pyx_v_self->width;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_v_width = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "rasterio/_io.pyx":544
 *             xoff = yoff = 0
 *             width = self.width
 *             height = self.height             # <<<<<<<<<<<<<<
 *         if dtype == dtypes.ubyte:
 *             retval = io_ubyte(
 */
    __pyx_t_4 = __pyx_v_self->height;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_v_height = __pyx_t_4;
    __pyx_t_4 = 0;
  }
  __pyx_L8:;

  /* "rasterio/_io.pyx":545
 *             width = self.width
 *             height = self.height
 *         if dtype == dtypes.ubyte:             # <<<<<<<<<<<<<<
 *             retval = io_ubyte(
 *                 hband, 0, xoff, yoff, width, height, out)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ubyte); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":547
 *         if dtype == dtypes.ubyte:
 *             retval = io_ubyte(
 *                 hband, 0, xoff, yoff, width, height, out)             # <<<<<<<<<<<<<<
 *         elif dtype == dtypes.uint16:
 *             retval = io_uint16(
 */
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_out) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_out, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":546
 *             height = self.height
 *         if dtype == dtypes.ubyte:
 *             retval = io_ubyte(             # <<<<<<<<<<<<<<
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.uint16:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_ubyte(__pyx_v_hband, 0, __pyx_t_8, __pyx_t_7, __pyx_t_9, __pyx_t_10, ((PyArrayObject *)__pyx_v_out));
    goto __pyx_L9;
  }

  /* "rasterio/_io.pyx":548
 *             retval = io_ubyte(
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.uint16:             # <<<<<<<<<<<<<<
 *             retval = io_uint16(
 *                 hband, 0, xoff, yoff, width, height, out)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":550
 *         elif dtype == dtypes.uint16:
 *             retval = io_uint16(
 *                 hband, 0, xoff, yoff, width, height, out)             # <<<<<<<<<<<<<<
 *         elif dtype == dtypes.int16:
 *             retval = io_int16(
 */
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_out) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_out, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":549
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.uint16:
 *             retval = io_uint16(             # <<<<<<<<<<<<<<
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.int16:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_uint16(__pyx_v_hband, 0, __pyx_t_10, __pyx_t_9, __pyx_t_7, __pyx_t_8, ((PyArrayObject *)__pyx_v_out));
    goto __pyx_L9;
  }

  /* "rasterio/_io.pyx":551
 *             retval = io_uint16(
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.int16:             # <<<<<<<<<<<<<<
 *             retval = io_int16(
 *                 hband, 0, xoff, yoff, width, height, out)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int16); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":553
 *         elif dtype == dtypes.int16:
 *             retval = io_int16(
 *                 hband, 0, xoff, yoff, width, height, out)             # <<<<<<<<<<<<<<
 *         elif dtype == dtypes.uint32:
 *             retval = io_uint32(
 */
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_out) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_out, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":552
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.int16:
 *             retval = io_int16(             # <<<<<<<<<<<<<<
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.uint32:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_int16(__pyx_v_hband, 0, __pyx_t_8, __pyx_t_7, __pyx_t_9, __pyx_t_10, ((PyArrayObject *)__pyx_v_out));
    goto __pyx_L9;
  }

  /* "rasterio/_io.pyx":554
 *             retval = io_int16(
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.uint32:             # <<<<<<<<<<<<<<
 *             retval = io_uint32(
 *                 hband, 0, xoff, yoff, width, height, out)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":556
 *         elif dtype == dtypes.uint32:
 *             retval = io_uint32(
 *                 hband, 0, xoff, yoff, width, height, out)             # <<<<<<<<<<<<<<
 *         elif dtype == dtypes.int32:
 *             retval = io_int32(
 */
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_out) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_out, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":555
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.uint32:
 *             retval = io_uint32(             # <<<<<<<<<<<<<<
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.int32:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_uint32(__pyx_v_hband, 0, __pyx_t_10, __pyx_t_9, __pyx_t_7, __pyx_t_8, ((PyArrayObject *)__pyx_v_out));
    goto __pyx_L9;
  }

  /* "rasterio/_io.pyx":557
 *             retval = io_uint32(
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.int32:             # <<<<<<<<<<<<<<
 *             retval = io_int32(
 *                 hband, 0, xoff, yoff, width, height, out)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":559
 *         elif dtype == dtypes.int32:
 *             retval = io_int32(
 *                 hband, 0, xoff, yoff, width, height, out)             # <<<<<<<<<<<<<<
 *         elif dtype == dtypes.float32:
 *             retval = io_float32(
 */
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_out) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_out, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":558
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.int32:
 *             retval = io_int32(             # <<<<<<<<<<<<<<
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.float32:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_int32(__pyx_v_hband, 0, __pyx_t_8, __pyx_t_7, __pyx_t_9, __pyx_t_10, ((PyArrayObject *)__pyx_v_out));
    goto __pyx_L9;
  }

  /* "rasterio/_io.pyx":560
 *             retval = io_int32(
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.float32:             # <<<<<<<<<<<<<<
 *             retval = io_float32(
 *                 hband, 0, xoff, yoff, width, height, out)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":562
 *         elif dtype == dtypes.float32:
 *             retval = io_float32(
 *                 hband, 0, xoff, yoff, width, height, out)             # <<<<<<<<<<<<<<
 *         elif dtype == dtypes.float64:
 *             retval = io_float64(
 */
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_out) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_out, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":561
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.float32:
 *             retval = io_float32(             # <<<<<<<<<<<<<<
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.float64:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_float32(__pyx_v_hband, 0, __pyx_t_10, __pyx_t_9, __pyx_t_7, __pyx_t_8, ((PyArrayObject *)__pyx_v_out));
    goto __pyx_L9;
  }

  /* "rasterio/_io.pyx":563
 *             retval = io_float32(
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.float64:             # <<<<<<<<<<<<<<
 *             retval = io_float64(
 *                 hband, 0, xoff, yoff, width, height, out)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":565
 *         elif dtype == dtypes.float64:
 *             retval = io_float64(
 *                 hband, 0, xoff, yoff, width, height, out)             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("Invalid dtype")
 */
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_out) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_out, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":564
 *                 hband, 0, xoff, yoff, width, height, out)
 *         elif dtype == dtypes.float64:
 *             retval = io_float64(             # <<<<<<<<<<<<<<
 *                 hband, 0, xoff, yoff, width, height, out)
 *         else:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_float64(__pyx_v_hband, 0, __pyx_t_8, __pyx_t_7, __pyx_t_9, __pyx_t_10, ((PyArrayObject *)__pyx_v_out));
    goto __pyx_L9;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":567
 *                 hband, 0, xoff, yoff, width, height, out)
 *         else:
 *             raise ValueError("Invalid dtype")             # <<<<<<<<<<<<<<
 *         # TODO: handle errors (by retval).
 * 
 */
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L9:;

  /* "rasterio/_io.pyx":570
 *         # TODO: handle errors (by retval).
 * 
 *         return out             # <<<<<<<<<<<<<<
 * 
 *     def tags(self, bidx=0, ns=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_out);
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":501
 *     transform = property(get_transform)
 * 
 *     def read_band(self, bidx, out=None, window=None):             # <<<<<<<<<<<<<<
 *         """Read the `bidx` band into an `out` array if provided,
 *         otherwise return a new array.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("rasterio._io.RasterReader.read_band", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_yoff);
  __Pyx_XDECREF(__pyx_v_xoff);
  __Pyx_XDECREF(__pyx_v_height);
  __Pyx_XDECREF(__pyx_v_width);
  __Pyx_XDECREF(__pyx_v_out);
  __Pyx_XDECREF(__pyx_v_window);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":572
 *         return out
 * 
 *     def tags(self, bidx=0, ns=None):             # <<<<<<<<<<<<<<
 *         """Returns a dict containing copies of the dataset or band's
 *         tags.
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_56tags(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8rasterio_3_io_12RasterReader_55tags[] = "Returns a dict containing copies of the dataset or band's\n        tags.\n\n        Tags are pairs of key and value strings. Tags belong to\n        namespaces.  The standard namespaces are: default (None) and\n        'IMAGE_STRUCTURE'.  Applications can create their own additional\n        namespaces.\n\n        The optional bidx argument can be used to select the tags of\n        a specific band. The optional ns argument can be used to select\n        a namespace other than the default.\n        ";
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_56tags(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bidx = 0;
  PyObject *__pyx_v_ns = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("tags (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bidx,&__pyx_n_s_ns,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)__pyx_int_0);
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bidx);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ns);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "tags") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_bidx = values[0];
    __pyx_v_ns = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("tags", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("rasterio._io.RasterReader.tags", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_55tags(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), __pyx_v_bidx, __pyx_v_ns);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_55tags(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_bidx, PyObject *__pyx_v_ns) {
  char *__pyx_v_item_c;
  void *__pyx_v_hobj;
  char const *__pyx_v_domain_c;
  char **__pyx_v_papszStrList;
  PyObject *__pyx_v_domain_b = NULL;
  int __pyx_v_num_items;
  PyObject *__pyx_v_retval = NULL;
  int __pyx_v_i;
  char *__pyx_v_item_b;
  PyObject *__pyx_v_item = NULL;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  void *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  char const *__pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *(*__pyx_t_11)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("tags", 0);
  __Pyx_TraceCall("tags", __pyx_f[0], 572);

  /* "rasterio/_io.pyx":589
 *         cdef const char *domain_c
 *         cdef char **papszStrList
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("can't read closed raster file")
 *         if bidx > 0:
 */
  __pyx_t_1 = ((__pyx_v_self->_hds == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":590
 *         cdef char **papszStrList
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":591
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")
 *         if bidx > 0:             # <<<<<<<<<<<<<<
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_bidx, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":592
 *             raise ValueError("can't read closed raster file")
 *         if bidx > 0:
 *             if bidx not in self.indexes:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Invalid band index")
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_indexes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = (__Pyx_PySequence_Contains(__pyx_v_bidx, __pyx_t_2, Py_NE)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = (__pyx_t_1 != 0);
    if (__pyx_t_3) {

      /* "rasterio/_io.pyx":593
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")             # <<<<<<<<<<<<<<
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hobj == NULL:
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":594
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)             # <<<<<<<<<<<<<<
 *             if hobj == NULL:
 *                 raise ValueError("NULL band")
 */
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_bidx); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_hobj = GDALGetRasterBand(__pyx_v_self->_hds, __pyx_t_4);

    /* "rasterio/_io.pyx":595
 *                 raise ValueError("Invalid band index")
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hobj == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("NULL band")
 *         else:
 */
    __pyx_t_3 = ((__pyx_v_hobj == NULL) != 0);
    if (__pyx_t_3) {

      /* "rasterio/_io.pyx":596
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hobj == NULL:
 *                 raise ValueError("NULL band")             # <<<<<<<<<<<<<<
 *         else:
 *             hobj = self._hds
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    goto __pyx_L4;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":598
 *                 raise ValueError("NULL band")
 *         else:
 *             hobj = self._hds             # <<<<<<<<<<<<<<
 *         if ns:
 *             domain_b = ns.encode('utf-8')
 */
    __pyx_t_5 = __pyx_v_self->_hds;
    __pyx_v_hobj = __pyx_t_5;
  }
  __pyx_L4:;

  /* "rasterio/_io.pyx":599
 *         else:
 *             hobj = self._hds
 *         if ns:             # <<<<<<<<<<<<<<
 *             domain_b = ns.encode('utf-8')
 *             domain_c = domain_b
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_ns); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":600
 *             hobj = self._hds
 *         if ns:
 *             domain_b = ns.encode('utf-8')             # <<<<<<<<<<<<<<
 *             domain_c = domain_b
 *         else:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ns, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Call(__pyx_t_2, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_domain_b = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "rasterio/_io.pyx":601
 *         if ns:
 *             domain_b = ns.encode('utf-8')
 *             domain_c = domain_b             # <<<<<<<<<<<<<<
 *         else:
 *             domain_c = NULL
 */
    __pyx_t_7 = __Pyx_PyObject_AsString(__pyx_v_domain_b); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_domain_c = __pyx_t_7;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":603
 *             domain_c = domain_b
 *         else:
 *             domain_c = NULL             # <<<<<<<<<<<<<<
 *         papszStrList = _gdal.GDALGetMetadata(hobj, domain_c)
 *         num_items = _gdal.CSLCount(papszStrList)
 */
    __pyx_v_domain_c = NULL;
  }
  __pyx_L7:;

  /* "rasterio/_io.pyx":604
 *         else:
 *             domain_c = NULL
 *         papszStrList = _gdal.GDALGetMetadata(hobj, domain_c)             # <<<<<<<<<<<<<<
 *         num_items = _gdal.CSLCount(papszStrList)
 *         retval = {}
 */
  __pyx_v_papszStrList = GDALGetMetadata(__pyx_v_hobj, __pyx_v_domain_c);

  /* "rasterio/_io.pyx":605
 *             domain_c = NULL
 *         papszStrList = _gdal.GDALGetMetadata(hobj, domain_c)
 *         num_items = _gdal.CSLCount(papszStrList)             # <<<<<<<<<<<<<<
 *         retval = {}
 *         for i in range(num_items):
 */
  __pyx_v_num_items = CSLCount(__pyx_v_papszStrList);

  /* "rasterio/_io.pyx":606
 *         papszStrList = _gdal.GDALGetMetadata(hobj, domain_c)
 *         num_items = _gdal.CSLCount(papszStrList)
 *         retval = {}             # <<<<<<<<<<<<<<
 *         for i in range(num_items):
 *             item_c = papszStrList[i]
 */
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_v_retval = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "rasterio/_io.pyx":607
 *         num_items = _gdal.CSLCount(papszStrList)
 *         retval = {}
 *         for i in range(num_items):             # <<<<<<<<<<<<<<
 *             item_c = papszStrList[i]
 *             item_b = item_c
 */
  __pyx_t_4 = __pyx_v_num_items;
  for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_4; __pyx_t_8+=1) {
    __pyx_v_i = __pyx_t_8;

    /* "rasterio/_io.pyx":608
 *         retval = {}
 *         for i in range(num_items):
 *             item_c = papszStrList[i]             # <<<<<<<<<<<<<<
 *             item_b = item_c
 *             item = item_b.decode('utf-8')
 */
    __pyx_v_item_c = (__pyx_v_papszStrList[__pyx_v_i]);

    /* "rasterio/_io.pyx":609
 *         for i in range(num_items):
 *             item_c = papszStrList[i]
 *             item_b = item_c             # <<<<<<<<<<<<<<
 *             item = item_b.decode('utf-8')
 *             key, value = item.split('=')
 */
    __pyx_v_item_b = __pyx_v_item_c;

    /* "rasterio/_io.pyx":610
 *             item_c = papszStrList[i]
 *             item_b = item_c
 *             item = item_b.decode('utf-8')             # <<<<<<<<<<<<<<
 *             key, value = item.split('=')
 *             retval[key] = value
 */
    __pyx_t_6 = __Pyx_decode_c_string(__pyx_v_item_b, 0, strlen(__pyx_v_item_b), NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "rasterio/_io.pyx":611
 *             item_b = item_c
 *             item = item_b.decode('utf-8')
 *             key, value = item.split('=')             # <<<<<<<<<<<<<<
 *             retval[key] = value
 *         return retval
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_item, __pyx_n_s_split); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = PyObject_Call(__pyx_t_6, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_9);
      #else
      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
      index = 0; __pyx_t_6 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_6)) goto __pyx_L10_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L10_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_9);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L11_unpacking_done;
      __pyx_L10_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L11_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_9);
    __pyx_t_9 = 0;

    /* "rasterio/_io.pyx":612
 *             item = item_b.decode('utf-8')
 *             key, value = item.split('=')
 *             retval[key] = value             # <<<<<<<<<<<<<<
 *         return retval
 * 
 */
    if (unlikely(PyDict_SetItem(__pyx_v_retval, __pyx_v_key, __pyx_v_value) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":613
 *             key, value = item.split('=')
 *             retval[key] = value
 *         return retval             # <<<<<<<<<<<<<<
 * 
 *     def colormap(self, bidx):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_retval);
  __pyx_r = __pyx_v_retval;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":572
 *         return out
 * 
 *     def tags(self, bidx=0, ns=None):             # <<<<<<<<<<<<<<
 *         """Returns a dict containing copies of the dataset or band's
 *         tags.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("rasterio._io.RasterReader.tags", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_domain_b);
  __Pyx_XDECREF(__pyx_v_retval);
  __Pyx_XDECREF(__pyx_v_item);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":615
 *         return retval
 * 
 *     def colormap(self, bidx):             # <<<<<<<<<<<<<<
 *         """Returns a dict containing the colormap for a band or None."""
 *         cdef void *hBand
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_58colormap(PyObject *__pyx_v_self, PyObject *__pyx_v_bidx); /*proto*/
static char __pyx_doc_8rasterio_3_io_12RasterReader_57colormap[] = "Returns a dict containing the colormap for a band or None.";
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_58colormap(PyObject *__pyx_v_self, PyObject *__pyx_v_bidx) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("colormap (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_57colormap(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), ((PyObject *)__pyx_v_bidx));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_57colormap(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_bidx) {
  void *__pyx_v_hBand;
  void *__pyx_v_hTable;
  int __pyx_v_i;
  GDALColorEntry *__pyx_v_color;
  PyObject *__pyx_v_retval = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("colormap", 0);
  __Pyx_TraceCall("colormap", __pyx_f[0], 615);

  /* "rasterio/_io.pyx":621
 *         cdef int i
 *         cdef _gdal.GDALColorEntry *color
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("can't read closed raster file")
 *         if bidx > 0:
 */
  __pyx_t_1 = ((__pyx_v_self->_hds == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":622
 *         cdef _gdal.GDALColorEntry *color
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":623
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")
 *         if bidx > 0:             # <<<<<<<<<<<<<<
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_bidx, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":624
 *             raise ValueError("can't read closed raster file")
 *         if bidx > 0:
 *             if bidx not in self.indexes:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Invalid band index")
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_indexes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = (__Pyx_PySequence_Contains(__pyx_v_bidx, __pyx_t_2, Py_NE)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = (__pyx_t_1 != 0);
    if (__pyx_t_3) {

      /* "rasterio/_io.pyx":625
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")             # <<<<<<<<<<<<<<
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hBand == NULL:
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":626
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)             # <<<<<<<<<<<<<<
 *             if hBand == NULL:
 *                 raise ValueError("NULL band")
 */
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_bidx); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_hBand = GDALGetRasterBand(__pyx_v_self->_hds, __pyx_t_4);

    /* "rasterio/_io.pyx":627
 *                 raise ValueError("Invalid band index")
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hBand == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("NULL band")
 *         hTable = _gdal.GDALGetRasterColorTable(hBand)
 */
    __pyx_t_3 = ((__pyx_v_hBand == NULL) != 0);
    if (__pyx_t_3) {

      /* "rasterio/_io.pyx":628
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hBand == NULL:
 *                 raise ValueError("NULL band")             # <<<<<<<<<<<<<<
 *         hTable = _gdal.GDALGetRasterColorTable(hBand)
 *         if hTable == NULL:
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "rasterio/_io.pyx":629
 *             if hBand == NULL:
 *                 raise ValueError("NULL band")
 *         hTable = _gdal.GDALGetRasterColorTable(hBand)             # <<<<<<<<<<<<<<
 *         if hTable == NULL:
 *             raise ValueError("NULL color table")
 */
  __pyx_v_hTable = GDALGetRasterColorTable(__pyx_v_hBand);

  /* "rasterio/_io.pyx":630
 *                 raise ValueError("NULL band")
 *         hTable = _gdal.GDALGetRasterColorTable(hBand)
 *         if hTable == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("NULL color table")
 *         retval = {}
 */
  __pyx_t_3 = ((__pyx_v_hTable == NULL) != 0);
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":631
 *         hTable = _gdal.GDALGetRasterColorTable(hBand)
 *         if hTable == NULL:
 *             raise ValueError("NULL color table")             # <<<<<<<<<<<<<<
 *         retval = {}
 * 
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":632
 *         if hTable == NULL:
 *             raise ValueError("NULL color table")
 *         retval = {}             # <<<<<<<<<<<<<<
 * 
 *         for i in range(_gdal.GDALGetColorEntryCount(hTable)):
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_retval = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":634
 *         retval = {}
 * 
 *         for i in range(_gdal.GDALGetColorEntryCount(hTable)):             # <<<<<<<<<<<<<<
 *             color = _gdal.GDALGetColorEntry(hTable, i)
 *             if color == NULL:
 */
  __pyx_t_4 = GDALGetColorEntryCount(__pyx_v_hTable);
  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
    __pyx_v_i = __pyx_t_5;

    /* "rasterio/_io.pyx":635
 * 
 *         for i in range(_gdal.GDALGetColorEntryCount(hTable)):
 *             color = _gdal.GDALGetColorEntry(hTable, i)             # <<<<<<<<<<<<<<
 *             if color == NULL:
 *                 log.warn("NULL color at %d, skipping", i)
 */
    __pyx_v_color = GDALGetColorEntry(__pyx_v_hTable, __pyx_v_i);

    /* "rasterio/_io.pyx":636
 *         for i in range(_gdal.GDALGetColorEntryCount(hTable)):
 *             color = _gdal.GDALGetColorEntry(hTable, i)
 *             if color == NULL:             # <<<<<<<<<<<<<<
 *                 log.warn("NULL color at %d, skipping", i)
 *                 continue
 */
    __pyx_t_3 = ((__pyx_v_color == NULL) != 0);
    if (__pyx_t_3) {

      /* "rasterio/_io.pyx":637
 *             color = _gdal.GDALGetColorEntry(hTable, i)
 *             if color == NULL:
 *                 log.warn("NULL color at %d, skipping", i)             # <<<<<<<<<<<<<<
 *                 continue
 *             log.info("Color: (%d, %d, %d, %d)", color.c1, color.c2, color.c3, color.c4)
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warn); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_kp_s_NULL_color_at_d_skipping);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_s_NULL_color_at_d_skipping);
      __Pyx_GIVEREF(__pyx_kp_s_NULL_color_at_d_skipping);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "rasterio/_io.pyx":638
 *             if color == NULL:
 *                 log.warn("NULL color at %d, skipping", i)
 *                 continue             # <<<<<<<<<<<<<<
 *             log.info("Color: (%d, %d, %d, %d)", color.c1, color.c2, color.c3, color.c4)
 *             retval[i] = (color.c1, color.c2, color.c3, color.c4)
 */
      goto __pyx_L8_continue;
    }

    /* "rasterio/_io.pyx":639
 *                 log.warn("NULL color at %d, skipping", i)
 *                 continue
 *             log.info("Color: (%d, %d, %d, %d)", color.c1, color.c2, color.c3, color.c4)             # <<<<<<<<<<<<<<
 *             retval[i] = (color.c1, color.c2, color.c3, color.c4)
 *         return retval
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_info); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyInt_From_short(__pyx_v_color->c1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyInt_From_short(__pyx_v_color->c2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = __Pyx_PyInt_From_short(__pyx_v_color->c3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyInt_From_short(__pyx_v_color->c4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = PyTuple_New(5); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_kp_s_Color_d_d_d_d);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_s_Color_d_d_d_d);
    __Pyx_GIVEREF(__pyx_kp_s_Color_d_d_d_d);
    PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    __pyx_t_2 = 0;
    __pyx_t_6 = 0;
    __pyx_t_8 = 0;
    __pyx_t_9 = 0;
    __pyx_t_9 = PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "rasterio/_io.pyx":640
 *                 continue
 *             log.info("Color: (%d, %d, %d, %d)", color.c1, color.c2, color.c3, color.c4)
 *             retval[i] = (color.c1, color.c2, color.c3, color.c4)             # <<<<<<<<<<<<<<
 *         return retval
 * 
 */
    __pyx_t_9 = __Pyx_PyInt_From_short(__pyx_v_color->c1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = __Pyx_PyInt_From_short(__pyx_v_color->c2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_7 = __Pyx_PyInt_From_short(__pyx_v_color->c3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyInt_From_short(__pyx_v_color->c4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_8);
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    if (unlikely(PyDict_SetItem(__pyx_v_retval, __pyx_t_8, __pyx_t_6) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_L8_continue:;
  }

  /* "rasterio/_io.pyx":641
 *             log.info("Color: (%d, %d, %d, %d)", color.c1, color.c2, color.c3, color.c4)
 *             retval[i] = (color.c1, color.c2, color.c3, color.c4)
 *         return retval             # <<<<<<<<<<<<<<
 * 
 *     def read_mask(self, out=None, window=None):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_retval);
  __pyx_r = __pyx_v_retval;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":615
 *         return retval
 * 
 *     def colormap(self, bidx):             # <<<<<<<<<<<<<<
 *         """Returns a dict containing the colormap for a band or None."""
 *         cdef void *hBand
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("rasterio._io.RasterReader.colormap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_retval);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":643
 *         return retval
 * 
 *     def read_mask(self, out=None, window=None):             # <<<<<<<<<<<<<<
 *         """Read the mask band into an `out` array if provided,
 *         otherwise return a new array containing the dataset's
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_60read_mask(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8rasterio_3_io_12RasterReader_59read_mask[] = "Read the mask band into an `out` array if provided, \n        otherwise return a new array containing the dataset's\n        valid data mask.\n\n        The optional `window` argument takes a tuple like:\n        \n            ((row_start, row_stop), (col_start, col_stop))\n            \n        specifying a raster subset to write into.\n        ";
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_60read_mask(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_out = 0;
  PyObject *__pyx_v_window = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("read_mask (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_out,&__pyx_n_s_window,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_out);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_mask") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_out = values[0];
    __pyx_v_window = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("read_mask", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("rasterio._io.RasterReader.read_mask", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_59read_mask(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), __pyx_v_out, __pyx_v_window);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_59read_mask(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_out, PyObject *__pyx_v_window) {
  void *__pyx_v_hband;
  void *__pyx_v_hmask;
  PyObject *__pyx_v_out_shape = NULL;
  PyObject *__pyx_v_yoff = NULL;
  PyObject *__pyx_v_xoff = NULL;
  PyObject *__pyx_v_height = NULL;
  PyObject *__pyx_v_width = NULL;
  CYTHON_UNUSED int __pyx_v_retval;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("read_mask", 0);
  __Pyx_TraceCall("read_mask", __pyx_f[0], 643);
  __Pyx_INCREF(__pyx_v_out);
  __Pyx_INCREF(__pyx_v_window);

  /* "rasterio/_io.pyx":656
 *         cdef void *hband
 *         cdef void *hmask
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("can't write closed raster file")
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)
 */
  __pyx_t_1 = ((__pyx_v_self->_hds == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":657
 *         cdef void *hmask
 *         if self._hds == NULL:
 *             raise ValueError("can't write closed raster file")             # <<<<<<<<<<<<<<
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)
 *         if hband == NULL:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__40, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":658
 *         if self._hds == NULL:
 *             raise ValueError("can't write closed raster file")
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)             # <<<<<<<<<<<<<<
 *         if hband == NULL:
 *             raise ValueError("NULL band mask")
 */
  __pyx_v_hband = GDALGetRasterBand(__pyx_v_self->_hds, 1);

  /* "rasterio/_io.pyx":659
 *             raise ValueError("can't write closed raster file")
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)
 *         if hband == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("NULL band mask")
 *         hmask = _gdal.GDALGetMaskBand(hband)
 */
  __pyx_t_1 = ((__pyx_v_hband == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":660
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)
 *         if hband == NULL:
 *             raise ValueError("NULL band mask")             # <<<<<<<<<<<<<<
 *         hmask = _gdal.GDALGetMaskBand(hband)
 *         if hmask == NULL:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":661
 *         if hband == NULL:
 *             raise ValueError("NULL band mask")
 *         hmask = _gdal.GDALGetMaskBand(hband)             # <<<<<<<<<<<<<<
 *         if hmask == NULL:
 *             return None
 */
  __pyx_v_hmask = GDALGetMaskBand(__pyx_v_hband);

  /* "rasterio/_io.pyx":662
 *             raise ValueError("NULL band mask")
 *         hmask = _gdal.GDALGetMaskBand(hband)
 *         if hmask == NULL:             # <<<<<<<<<<<<<<
 *             return None
 *         if out is None:
 */
  __pyx_t_1 = ((__pyx_v_hmask == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":663
 *         hmask = _gdal.GDALGetMaskBand(hband)
 *         if hmask == NULL:
 *             return None             # <<<<<<<<<<<<<<
 *         if out is None:
 *             out_shape = (
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
  }

  /* "rasterio/_io.pyx":664
 *         if hmask == NULL:
 *             return None
 *         if out is None:             # <<<<<<<<<<<<<<
 *             out_shape = (
 *                 window
 */
  __pyx_t_1 = (__pyx_v_out == Py_None);
  __pyx_t_3 = (__pyx_t_1 != 0);
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":667
 *             out_shape = (
 *                 window
 *                 and window_shape(window, self.height, self.width)             # <<<<<<<<<<<<<<
 *                 or self.shape)
 *             out = np.zeros(out_shape, np.uint8)
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_window); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_3) {
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_window_shape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_v_window);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_window);
      __Pyx_GIVEREF(__pyx_v_window);
      __Pyx_INCREF(__pyx_v_self->height);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_self->height);
      __Pyx_GIVEREF(__pyx_v_self->height);
      __Pyx_INCREF(__pyx_v_self->width);
      PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_self->width);
      __Pyx_GIVEREF(__pyx_v_self->width);
      __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __pyx_t_5;
      __pyx_t_5 = 0;
    } else {
      __Pyx_INCREF(__pyx_v_window);
      __pyx_t_4 = __pyx_v_window;
    }
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!__pyx_t_3) {
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "rasterio/_io.pyx":668
 *                 window
 *                 and window_shape(window, self.height, self.width)
 *                 or self.shape)             # <<<<<<<<<<<<<<
 *             out = np.zeros(out_shape, np.uint8)
 *         if window:
 */
      __Pyx_INCREF(__pyx_v_self->shape);
      __pyx_t_5 = __pyx_v_self->shape;
    } else {
      __pyx_t_5 = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    __pyx_v_out_shape = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "rasterio/_io.pyx":669
 *                 and window_shape(window, self.height, self.width)
 *                 or self.shape)
 *             out = np.zeros(out_shape, np.uint8)             # <<<<<<<<<<<<<<
 *         if window:
 *             window = eval_window(window, self.height, self.width)
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_uint8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_v_out_shape);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_out_shape);
    __Pyx_GIVEREF(__pyx_v_out_shape);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF_SET(__pyx_v_out, __pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "rasterio/_io.pyx":670
 *                 or self.shape)
 *             out = np.zeros(out_shape, np.uint8)
 *         if window:             # <<<<<<<<<<<<<<
 *             window = eval_window(window, self.height, self.width)
 *             yoff = window[0][0]
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_window); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":671
 *             out = np.zeros(out_shape, np.uint8)
 *         if window:
 *             window = eval_window(window, self.height, self.width)             # <<<<<<<<<<<<<<
 *             yoff = window[0][0]
 *             xoff = window[1][0]
 */
    __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_self->height); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_self->width); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __pyx_f_8rasterio_3_io_eval_window(__pyx_v_window, __pyx_t_6, __pyx_t_7, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_window, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":672
 *         if window:
 *             window = eval_window(window, self.height, self.width)
 *             yoff = window[0][0]             # <<<<<<<<<<<<<<
 *             xoff = window[1][0]
 *             height = window[0][1] - yoff
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_window, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_yoff = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "rasterio/_io.pyx":673
 *             window = eval_window(window, self.height, self.width)
 *             yoff = window[0][0]
 *             xoff = window[1][0]             # <<<<<<<<<<<<<<
 *             height = window[0][1] - yoff
 *             width = window[1][1] - xoff
 */
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_window, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_xoff = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":674
 *             yoff = window[0][0]
 *             xoff = window[1][0]
 *             height = window[0][1] - yoff             # <<<<<<<<<<<<<<
 *             width = window[1][1] - xoff
 *         else:
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_window, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_yoff); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_height = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":675
 *             xoff = window[1][0]
 *             height = window[0][1] - yoff
 *             width = window[1][1] - xoff             # <<<<<<<<<<<<<<
 *         else:
 *             xoff = yoff = 0
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_window, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_5, __pyx_v_xoff); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_width = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":677
 *             width = window[1][1] - xoff
 *         else:
 *             xoff = yoff = 0             # <<<<<<<<<<<<<<
 *             width = self.width
 *             height = self.height
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_xoff = __pyx_t_2;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyInt_From_long(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_yoff = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":678
 *         else:
 *             xoff = yoff = 0
 *             width = self.width             # <<<<<<<<<<<<<<
 *             height = self.height
 *         retval = io_ubyte(
 */
    __pyx_t_2 = __pyx_v_self->width;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v_width = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":679
 *             xoff = yoff = 0
 *             width = self.width
 *             height = self.height             # <<<<<<<<<<<<<<
 *         retval = io_ubyte(
 *             hmask, 0, xoff, yoff, width, height, out)
 */
    __pyx_t_2 = __pyx_v_self->height;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v_height = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L7:;

  /* "rasterio/_io.pyx":681
 *             height = self.height
 *         retval = io_ubyte(
 *             hmask, 0, xoff, yoff, width, height, out)             # <<<<<<<<<<<<<<
 *         return out
 * 
 */
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(likely(((__pyx_v_out) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_out, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "rasterio/_io.pyx":680
 *             width = self.width
 *             height = self.height
 *         retval = io_ubyte(             # <<<<<<<<<<<<<<
 *             hmask, 0, xoff, yoff, width, height, out)
 *         return out
 */
  __pyx_v_retval = __pyx_f_8rasterio_3_io_io_ubyte(__pyx_v_hmask, 0, __pyx_t_7, __pyx_t_6, __pyx_t_8, __pyx_t_9, ((PyArrayObject *)__pyx_v_out));

  /* "rasterio/_io.pyx":682
 *         retval = io_ubyte(
 *             hmask, 0, xoff, yoff, width, height, out)
 *         return out             # <<<<<<<<<<<<<<
 * 
 * cdef class RasterUpdater(RasterReader):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_out);
  __pyx_r = __pyx_v_out;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":643
 *         return retval
 * 
 *     def read_mask(self, out=None, window=None):             # <<<<<<<<<<<<<<
 *         """Read the mask band into an `out` array if provided,
 *         otherwise return a new array containing the dataset's
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("rasterio._io.RasterReader.read_mask", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_out_shape);
  __Pyx_XDECREF(__pyx_v_yoff);
  __Pyx_XDECREF(__pyx_v_xoff);
  __Pyx_XDECREF(__pyx_v_height);
  __Pyx_XDECREF(__pyx_v_width);
  __Pyx_XDECREF(__pyx_v_out);
  __Pyx_XDECREF(__pyx_v_window);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":33
 *     cdef void *_hds
 * 
 *     cdef readonly object name             # <<<<<<<<<<<<<<
 *     cdef readonly object mode
 *     cdef readonly object width, height
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_4name_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_4name___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_4name___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 33);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->name);
  __pyx_r = __pyx_v_self->name;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":34
 * 
 *     cdef readonly object name
 *     cdef readonly object mode             # <<<<<<<<<<<<<<
 *     cdef readonly object width, height
 *     cdef readonly object shape
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_4mode_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_4mode_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_4mode___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_4mode___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 34);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->mode);
  __pyx_r = __pyx_v_self->mode;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":35
 *     cdef readonly object name
 *     cdef readonly object mode
 *     cdef readonly object width, height             # <<<<<<<<<<<<<<
 *     cdef readonly object shape
 *     cdef public object driver
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_5width_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_5width_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_5width___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_5width___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 35);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->width);
  __pyx_r = __pyx_v_self->width;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_6height_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_6height_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_6height___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_6height___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 35);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->height);
  __pyx_r = __pyx_v_self->height;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":36
 *     cdef readonly object mode
 *     cdef readonly object width, height
 *     cdef readonly object shape             # <<<<<<<<<<<<<<
 *     cdef public object driver
 *     cdef public object _count
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_5shape_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_5shape___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_5shape___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 36);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->shape);
  __pyx_r = __pyx_v_self->shape;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":37
 *     cdef readonly object width, height
 *     cdef readonly object shape
 *     cdef public object driver             # <<<<<<<<<<<<<<
 *     cdef public object _count
 *     cdef public object _dtypes
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_6driver_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_6driver_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_6driver___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_6driver___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 37);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->driver);
  __pyx_r = __pyx_v_self->driver;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_6driver_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_6driver_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_6driver_2__set__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_6driver_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[1], 37);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->driver);
  __Pyx_DECREF(__pyx_v_self->driver);
  __pyx_v_self->driver = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_6driver_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_6driver_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_6driver_4__del__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_6driver_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[1], 37);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->driver);
  __Pyx_DECREF(__pyx_v_self->driver);
  __pyx_v_self->driver = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":38
 *     cdef readonly object shape
 *     cdef public object driver
 *     cdef public object _count             # <<<<<<<<<<<<<<
 *     cdef public object _dtypes
 *     cdef public object _closed
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_6_count_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_6_count_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_6_count___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_6_count___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 38);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_count);
  __pyx_r = __pyx_v_self->_count;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_6_count_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_6_count_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_6_count_2__set__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_6_count_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[1], 38);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_count);
  __Pyx_DECREF(__pyx_v_self->_count);
  __pyx_v_self->_count = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_6_count_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_6_count_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_6_count_4__del__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_6_count_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[1], 38);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_count);
  __Pyx_DECREF(__pyx_v_self->_count);
  __pyx_v_self->_count = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":39
 *     cdef public object driver
 *     cdef public object _count
 *     cdef public object _dtypes             # <<<<<<<<<<<<<<
 *     cdef public object _closed
 *     cdef public object _crs
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_7_dtypes_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_7_dtypes_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_7_dtypes___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_7_dtypes___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 39);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_dtypes);
  __pyx_r = __pyx_v_self->_dtypes;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_7_dtypes_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_7_dtypes_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_7_dtypes_2__set__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_7_dtypes_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[1], 39);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_dtypes);
  __Pyx_DECREF(__pyx_v_self->_dtypes);
  __pyx_v_self->_dtypes = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_7_dtypes_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_7_dtypes_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_7_dtypes_4__del__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_7_dtypes_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[1], 39);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_dtypes);
  __Pyx_DECREF(__pyx_v_self->_dtypes);
  __pyx_v_self->_dtypes = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":40
 *     cdef public object _count
 *     cdef public object _dtypes
 *     cdef public object _closed             # <<<<<<<<<<<<<<
 *     cdef public object _crs
 *     cdef public object _crs_wkt
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_7_closed_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_7_closed_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_7_closed___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_7_closed___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 40);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_closed);
  __pyx_r = __pyx_v_self->_closed;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_7_closed_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_7_closed_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_7_closed_2__set__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_7_closed_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[1], 40);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_closed);
  __Pyx_DECREF(__pyx_v_self->_closed);
  __pyx_v_self->_closed = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_7_closed_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_7_closed_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_7_closed_4__del__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_7_closed_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[1], 40);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_closed);
  __Pyx_DECREF(__pyx_v_self->_closed);
  __pyx_v_self->_closed = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":41
 *     cdef public object _dtypes
 *     cdef public object _closed
 *     cdef public object _crs             # <<<<<<<<<<<<<<
 *     cdef public object _crs_wkt
 *     cdef public object _transform
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_4_crs_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_4_crs_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_4_crs___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_4_crs___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 41);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_crs);
  __pyx_r = __pyx_v_self->_crs;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_4_crs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_4_crs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_4_crs_2__set__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_4_crs_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[1], 41);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_crs);
  __Pyx_DECREF(__pyx_v_self->_crs);
  __pyx_v_self->_crs = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_4_crs_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_4_crs_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_4_crs_4__del__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_4_crs_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[1], 41);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_crs);
  __Pyx_DECREF(__pyx_v_self->_crs);
  __pyx_v_self->_crs = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":42
 *     cdef public object _closed
 *     cdef public object _crs
 *     cdef public object _crs_wkt             # <<<<<<<<<<<<<<
 *     cdef public object _transform
 *     cdef public object _block_shapes
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_8_crs_wkt_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_8_crs_wkt_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_8_crs_wkt___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_8_crs_wkt___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 42);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_crs_wkt);
  __pyx_r = __pyx_v_self->_crs_wkt;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_8_crs_wkt_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_8_crs_wkt_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_8_crs_wkt_2__set__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_8_crs_wkt_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[1], 42);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_crs_wkt);
  __Pyx_DECREF(__pyx_v_self->_crs_wkt);
  __pyx_v_self->_crs_wkt = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_8_crs_wkt_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_8_crs_wkt_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_8_crs_wkt_4__del__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_8_crs_wkt_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[1], 42);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_crs_wkt);
  __Pyx_DECREF(__pyx_v_self->_crs_wkt);
  __pyx_v_self->_crs_wkt = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":43
 *     cdef public object _crs
 *     cdef public object _crs_wkt
 *     cdef public object _transform             # <<<<<<<<<<<<<<
 *     cdef public object _block_shapes
 *     cdef public object _nodatavals
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_10_transform_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_10_transform_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_10_transform___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_10_transform___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 43);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_transform);
  __pyx_r = __pyx_v_self->_transform;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_10_transform_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_10_transform_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_10_transform_2__set__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_10_transform_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[1], 43);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_transform);
  __Pyx_DECREF(__pyx_v_self->_transform);
  __pyx_v_self->_transform = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_10_transform_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_10_transform_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_10_transform_4__del__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_10_transform_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[1], 43);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_transform);
  __Pyx_DECREF(__pyx_v_self->_transform);
  __pyx_v_self->_transform = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":44
 *     cdef public object _crs_wkt
 *     cdef public object _transform
 *     cdef public object _block_shapes             # <<<<<<<<<<<<<<
 *     cdef public object _nodatavals
 *     cdef public object _read
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_13_block_shapes_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_13_block_shapes_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_13_block_shapes___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_13_block_shapes___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 44);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_block_shapes);
  __pyx_r = __pyx_v_self->_block_shapes;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_13_block_shapes_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_13_block_shapes_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_13_block_shapes_2__set__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_13_block_shapes_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[1], 44);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_block_shapes);
  __Pyx_DECREF(__pyx_v_self->_block_shapes);
  __pyx_v_self->_block_shapes = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_13_block_shapes_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_13_block_shapes_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_13_block_shapes_4__del__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_13_block_shapes_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[1], 44);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_block_shapes);
  __Pyx_DECREF(__pyx_v_self->_block_shapes);
  __pyx_v_self->_block_shapes = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":45
 *     cdef public object _transform
 *     cdef public object _block_shapes
 *     cdef public object _nodatavals             # <<<<<<<<<<<<<<
 *     cdef public object _read
 *     cdef object env
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_11_nodatavals_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_11_nodatavals_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_11_nodatavals___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_11_nodatavals___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 45);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_nodatavals);
  __pyx_r = __pyx_v_self->_nodatavals;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_11_nodatavals_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_11_nodatavals_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_11_nodatavals_2__set__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_11_nodatavals_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[1], 45);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_nodatavals);
  __Pyx_DECREF(__pyx_v_self->_nodatavals);
  __pyx_v_self->_nodatavals = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_11_nodatavals_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_11_nodatavals_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_11_nodatavals_4__del__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_11_nodatavals_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[1], 45);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_nodatavals);
  __Pyx_DECREF(__pyx_v_self->_nodatavals);
  __pyx_v_self->_nodatavals = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":46
 *     cdef public object _block_shapes
 *     cdef public object _nodatavals
 *     cdef public object _read             # <<<<<<<<<<<<<<
 *     cdef object env
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_5_read_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_12RasterReader_5_read_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_5_read___get__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_12RasterReader_5_read___get__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 46);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_read);
  __pyx_r = __pyx_v_self->_read;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_5_read_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_5_read_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_5_read_2__set__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_5_read_2__set__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self, PyObject *__pyx_v_value) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);
  __Pyx_TraceCall("__set__", __pyx_f[1], 46);
  __Pyx_INCREF(__pyx_v_value);
  __Pyx_GIVEREF(__pyx_v_value);
  __Pyx_GOTREF(__pyx_v_self->_read);
  __Pyx_DECREF(__pyx_v_self->_read);
  __pyx_v_self->_read = __pyx_v_value;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_12RasterReader_5_read_5__del__(PyObject *__pyx_v_self); /*proto*/
static int __pyx_pw_8rasterio_3_io_12RasterReader_5_read_5__del__(PyObject *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_12RasterReader_5_read_4__del__(((struct __pyx_obj_8rasterio_3_io_RasterReader *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_12RasterReader_5_read_4__del__(struct __pyx_obj_8rasterio_3_io_RasterReader *__pyx_v_self) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__del__", 0);
  __Pyx_TraceCall("__del__", __pyx_f[1], 46);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_read);
  __Pyx_DECREF(__pyx_v_self->_read);
  __pyx_v_self->_read = Py_None;

  /* function exit code */
  __pyx_r = 0;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":688
 *     # TODO: the r+ mode.
 * 
 *     def __init__(             # <<<<<<<<<<<<<<
 *             self, path, mode, driver=None,
 *             width=None, height=None, count=None,
 */

/* Python wrapper */
static int __pyx_pw_8rasterio_3_io_13RasterUpdater_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_8rasterio_3_io_13RasterUpdater_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_path = 0;
  PyObject *__pyx_v_mode = 0;
  PyObject *__pyx_v_driver = 0;
  PyObject *__pyx_v_width = 0;
  PyObject *__pyx_v_height = 0;
  PyObject *__pyx_v_count = 0;
  PyObject *__pyx_v_crs = 0;
  PyObject *__pyx_v_transform = 0;
  PyObject *__pyx_v_dtype = 0;
  PyObject *__pyx_v_nodata = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
  __Pyx_GOTREF(__pyx_v_kwargs);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path,&__pyx_n_s_mode,&__pyx_n_s_driver,&__pyx_n_s_width,&__pyx_n_s_height,&__pyx_n_s_count,&__pyx_n_s_crs,&__pyx_n_s_transform,&__pyx_n_s_dtype,&__pyx_n_s_nodata,0};
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};

    /* "rasterio/_io.pyx":689
 * 
 *     def __init__(
 *             self, path, mode, driver=None,             # <<<<<<<<<<<<<<
 *             width=None, height=None, count=None,
 *             crs=None, transform=None, dtype=None,
 */
    values[2] = ((PyObject *)Py_None);

    /* "rasterio/_io.pyx":690
 *     def __init__(
 *             self, path, mode, driver=None,
 *             width=None, height=None, count=None,             # <<<<<<<<<<<<<<
 *             crs=None, transform=None, dtype=None,
 *             nodata=None,
 */
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)Py_None);
    values[5] = ((PyObject *)Py_None);

    /* "rasterio/_io.pyx":691
 *             self, path, mode, driver=None,
 *             width=None, height=None, count=None,
 *             crs=None, transform=None, dtype=None,             # <<<<<<<<<<<<<<
 *             nodata=None,
 *             **kwargs):
 */
    values[6] = ((PyObject *)Py_None);
    values[7] = ((PyObject *)Py_None);
    values[8] = ((PyObject *)Py_None);

    /* "rasterio/_io.pyx":692
 *             width=None, height=None, count=None,
 *             crs=None, transform=None, dtype=None,
 *             nodata=None,             # <<<<<<<<<<<<<<
 *             **kwargs):
 *         self.name = path
 */
    values[9] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_mode)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 10, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_driver);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_width);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_height);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_count);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_crs);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_transform);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dtype);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_nodata);
          if (value) { values[9] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_path = values[0];
    __pyx_v_mode = values[1];
    __pyx_v_driver = values[2];
    __pyx_v_width = values[3];
    __pyx_v_height = values[4];
    __pyx_v_count = values[5];
    __pyx_v_crs = values[6];
    __pyx_v_transform = values[7];
    __pyx_v_dtype = values[8];
    __pyx_v_nodata = values[9];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 10, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 688; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater___init__(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self), __pyx_v_path, __pyx_v_mode, __pyx_v_driver, __pyx_v_width, __pyx_v_height, __pyx_v_count, __pyx_v_crs, __pyx_v_transform, __pyx_v_dtype, __pyx_v_nodata, __pyx_v_kwargs);

  /* "rasterio/_io.pyx":688
 *     # TODO: the r+ mode.
 * 
 *     def __init__(             # <<<<<<<<<<<<<<
 *             self, path, mode, driver=None,
 *             width=None, height=None, count=None,
 */

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_8rasterio_3_io_13RasterUpdater___init__(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_path, PyObject *__pyx_v_mode, PyObject *__pyx_v_driver, PyObject *__pyx_v_width, PyObject *__pyx_v_height, PyObject *__pyx_v_count, PyObject *__pyx_v_crs, PyObject *__pyx_v_transform, PyObject *__pyx_v_dtype, PyObject *__pyx_v_nodata, PyObject *__pyx_v_kwargs) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__init__", 0);
  __Pyx_TraceCall("__init__", __pyx_f[0], 688);

  /* "rasterio/_io.pyx":694
 *             nodata=None,
 *             **kwargs):
 *         self.name = path             # <<<<<<<<<<<<<<
 *         self.mode = mode
 *         self.driver = driver
 */
  __Pyx_INCREF(__pyx_v_path);
  __Pyx_GIVEREF(__pyx_v_path);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.name);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.name);
  __pyx_v_self->__pyx_base.name = __pyx_v_path;

  /* "rasterio/_io.pyx":695
 *             **kwargs):
 *         self.name = path
 *         self.mode = mode             # <<<<<<<<<<<<<<
 *         self.driver = driver
 *         self.width = width
 */
  __Pyx_INCREF(__pyx_v_mode);
  __Pyx_GIVEREF(__pyx_v_mode);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.mode);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.mode);
  __pyx_v_self->__pyx_base.mode = __pyx_v_mode;

  /* "rasterio/_io.pyx":696
 *         self.name = path
 *         self.mode = mode
 *         self.driver = driver             # <<<<<<<<<<<<<<
 *         self.width = width
 *         self.height = height
 */
  __Pyx_INCREF(__pyx_v_driver);
  __Pyx_GIVEREF(__pyx_v_driver);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.driver);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.driver);
  __pyx_v_self->__pyx_base.driver = __pyx_v_driver;

  /* "rasterio/_io.pyx":697
 *         self.mode = mode
 *         self.driver = driver
 *         self.width = width             # <<<<<<<<<<<<<<
 *         self.height = height
 *         self._count = count
 */
  __Pyx_INCREF(__pyx_v_width);
  __Pyx_GIVEREF(__pyx_v_width);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.width);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.width);
  __pyx_v_self->__pyx_base.width = __pyx_v_width;

  /* "rasterio/_io.pyx":698
 *         self.driver = driver
 *         self.width = width
 *         self.height = height             # <<<<<<<<<<<<<<
 *         self._count = count
 *         self._init_dtype = dtype
 */
  __Pyx_INCREF(__pyx_v_height);
  __Pyx_GIVEREF(__pyx_v_height);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.height);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.height);
  __pyx_v_self->__pyx_base.height = __pyx_v_height;

  /* "rasterio/_io.pyx":699
 *         self.width = width
 *         self.height = height
 *         self._count = count             # <<<<<<<<<<<<<<
 *         self._init_dtype = dtype
 *         self._init_nodata = nodata
 */
  __Pyx_INCREF(__pyx_v_count);
  __Pyx_GIVEREF(__pyx_v_count);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._count);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._count);
  __pyx_v_self->__pyx_base._count = __pyx_v_count;

  /* "rasterio/_io.pyx":700
 *         self.height = height
 *         self._count = count
 *         self._init_dtype = dtype             # <<<<<<<<<<<<<<
 *         self._init_nodata = nodata
 *         self._hds = NULL
 */
  __Pyx_INCREF(__pyx_v_dtype);
  __Pyx_GIVEREF(__pyx_v_dtype);
  __Pyx_GOTREF(__pyx_v_self->_init_dtype);
  __Pyx_DECREF(__pyx_v_self->_init_dtype);
  __pyx_v_self->_init_dtype = __pyx_v_dtype;

  /* "rasterio/_io.pyx":701
 *         self._count = count
 *         self._init_dtype = dtype
 *         self._init_nodata = nodata             # <<<<<<<<<<<<<<
 *         self._hds = NULL
 *         self._count = count
 */
  __Pyx_INCREF(__pyx_v_nodata);
  __Pyx_GIVEREF(__pyx_v_nodata);
  __Pyx_GOTREF(__pyx_v_self->_init_nodata);
  __Pyx_DECREF(__pyx_v_self->_init_nodata);
  __pyx_v_self->_init_nodata = __pyx_v_nodata;

  /* "rasterio/_io.pyx":702
 *         self._init_dtype = dtype
 *         self._init_nodata = nodata
 *         self._hds = NULL             # <<<<<<<<<<<<<<
 *         self._count = count
 *         self._crs = crs
 */
  __pyx_v_self->__pyx_base._hds = NULL;

  /* "rasterio/_io.pyx":703
 *         self._init_nodata = nodata
 *         self._hds = NULL
 *         self._count = count             # <<<<<<<<<<<<<<
 *         self._crs = crs
 *         self._transform = transform
 */
  __Pyx_INCREF(__pyx_v_count);
  __Pyx_GIVEREF(__pyx_v_count);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._count);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._count);
  __pyx_v_self->__pyx_base._count = __pyx_v_count;

  /* "rasterio/_io.pyx":704
 *         self._hds = NULL
 *         self._count = count
 *         self._crs = crs             # <<<<<<<<<<<<<<
 *         self._transform = transform
 *         self._closed = True
 */
  __Pyx_INCREF(__pyx_v_crs);
  __Pyx_GIVEREF(__pyx_v_crs);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._crs);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._crs);
  __pyx_v_self->__pyx_base._crs = __pyx_v_crs;

  /* "rasterio/_io.pyx":705
 *         self._count = count
 *         self._crs = crs
 *         self._transform = transform             # <<<<<<<<<<<<<<
 *         self._closed = True
 *         self._dtypes = []
 */
  __Pyx_INCREF(__pyx_v_transform);
  __Pyx_GIVEREF(__pyx_v_transform);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._transform);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._transform);
  __pyx_v_self->__pyx_base._transform = __pyx_v_transform;

  /* "rasterio/_io.pyx":706
 *         self._crs = crs
 *         self._transform = transform
 *         self._closed = True             # <<<<<<<<<<<<<<
 *         self._dtypes = []
 *         self._nodatavals = []
 */
  __Pyx_INCREF(Py_True);
  __Pyx_GIVEREF(Py_True);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._closed);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._closed);
  __pyx_v_self->__pyx_base._closed = Py_True;

  /* "rasterio/_io.pyx":707
 *         self._transform = transform
 *         self._closed = True
 *         self._dtypes = []             # <<<<<<<<<<<<<<
 *         self._nodatavals = []
 *         self._options = kwargs.copy()
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._dtypes);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._dtypes);
  __pyx_v_self->__pyx_base._dtypes = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":708
 *         self._closed = True
 *         self._dtypes = []
 *         self._nodatavals = []             # <<<<<<<<<<<<<<
 *         self._options = kwargs.copy()
 * 
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._nodatavals);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._nodatavals);
  __pyx_v_self->__pyx_base._nodatavals = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":709
 *         self._dtypes = []
 *         self._nodatavals = []
 *         self._options = kwargs.copy()             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_t_1 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(__pyx_v_self->_options);
  __Pyx_DECREF(__pyx_v_self->_options);
  __pyx_v_self->_options = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":688
 *     # TODO: the r+ mode.
 * 
 *     def __init__(             # <<<<<<<<<<<<<<
 *             self, path, mode, driver=None,
 *             width=None, height=None, count=None,
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":711
 *         self._options = kwargs.copy()
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<%s RasterUpdater '%s' at %s>" % (
 *             self.closed and 'closed' or 'open',
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_3__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_3__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater_2__repr__(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_2__repr__(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__repr__", 0);
  __Pyx_TraceCall("__repr__", __pyx_f[0], 711);

  /* "rasterio/_io.pyx":712
 * 
 *     def __repr__(self):
 *         return "<%s RasterUpdater '%s' at %s>" % (             # <<<<<<<<<<<<<<
 *             self.closed and 'closed' or 'open',
 *             self.name,
 */
  __Pyx_XDECREF(__pyx_r);

  /* "rasterio/_io.pyx":713
 *     def __repr__(self):
 *         return "<%s RasterUpdater '%s' at %s>" % (
 *             self.closed and 'closed' or 'open',             # <<<<<<<<<<<<<<
 *             self.name,
 *             hex(id(self)))
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_closed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_INCREF(__pyx_n_s_closed);
    __pyx_t_3 = __pyx_n_s_closed;
  } else {
    __pyx_t_3 = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!__pyx_t_2) {
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_INCREF(__pyx_n_s_open);
    __pyx_t_1 = __pyx_n_s_open;
  } else {
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
  }

  /* "rasterio/_io.pyx":715
 *             self.closed and 'closed' or 'open',
 *             self.name,
 *             hex(id(self)))             # <<<<<<<<<<<<<<
 * 
 *     def start(self):
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_4 = PyObject_Call(__pyx_builtin_id, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_builtin_hex, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "rasterio/_io.pyx":713
 *     def __repr__(self):
 *         return "<%s RasterUpdater '%s' at %s>" % (
 *             self.closed and 'closed' or 'open',             # <<<<<<<<<<<<<<
 *             self.name,
 *             hex(id(self)))
 */
  __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.name);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self->__pyx_base.name);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.name);
  PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_4 = 0;

  /* "rasterio/_io.pyx":712
 * 
 *     def __repr__(self):
 *         return "<%s RasterUpdater '%s' at %s>" % (             # <<<<<<<<<<<<<<
 *             self.closed and 'closed' or 'open',
 *             self.name,
 */
  __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_s_RasterUpdater_s_at_s, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":711
 *         self._options = kwargs.copy()
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "<%s RasterUpdater '%s' at %s>" % (
 *             self.closed and 'closed' or 'open',
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":717
 *             hex(id(self)))
 * 
 *     def start(self):             # <<<<<<<<<<<<<<
 *         cdef const char *drv_name = NULL
 *         cdef char **options = NULL
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_5start(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_5start(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("start (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater_4start(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_4start(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self) {
  char const *__pyx_v_drv_name;
  char **__pyx_v_options;
  char *__pyx_v_key_c;
  char *__pyx_v_val_c;
  void *__pyx_v_drv;
  void *__pyx_v_hband;
  CYTHON_UNUSED int __pyx_v_success;
  PyObject *__pyx_v_name_b = NULL;
  char const *__pyx_v_fname;
  PyObject *__pyx_v_driver_b = NULL;
  PyObject *__pyx_v_tp = NULL;
  PyObject *__pyx_v_gdal_dtype = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_v_key_b = NULL;
  PyObject *__pyx_v_val_b = NULL;
  PyObject *__pyx_v_i = NULL;
  CYTHON_UNUSED PyObject *__pyx_v__ = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  char const *__pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  char const *__pyx_t_8;
  Py_ssize_t __pyx_t_9;
  PyObject *(*__pyx_t_10)(PyObject *);
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  char *__pyx_t_14;
  int __pyx_t_15;
  int __pyx_t_16;
  int __pyx_t_17;
  GDALDataType __pyx_t_18;
  double __pyx_t_19;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("start", 0);
  __Pyx_TraceCall("start", __pyx_f[0], 717);

  /* "rasterio/_io.pyx":718
 * 
 *     def start(self):
 *         cdef const char *drv_name = NULL             # <<<<<<<<<<<<<<
 *         cdef char **options = NULL
 *         cdef char *key_c, *val_c = NULL
 */
  __pyx_v_drv_name = NULL;

  /* "rasterio/_io.pyx":719
 *     def start(self):
 *         cdef const char *drv_name = NULL
 *         cdef char **options = NULL             # <<<<<<<<<<<<<<
 *         cdef char *key_c, *val_c = NULL
 *         cdef void *drv = NULL
 */
  __pyx_v_options = NULL;

  /* "rasterio/_io.pyx":720
 *         cdef const char *drv_name = NULL
 *         cdef char **options = NULL
 *         cdef char *key_c, *val_c = NULL             # <<<<<<<<<<<<<<
 *         cdef void *drv = NULL
 *         cdef void *hband = NULL
 */
  __pyx_v_val_c = NULL;

  /* "rasterio/_io.pyx":721
 *         cdef char **options = NULL
 *         cdef char *key_c, *val_c = NULL
 *         cdef void *drv = NULL             # <<<<<<<<<<<<<<
 *         cdef void *hband = NULL
 *         cdef int success
 */
  __pyx_v_drv = NULL;

  /* "rasterio/_io.pyx":722
 *         cdef char *key_c, *val_c = NULL
 *         cdef void *drv = NULL
 *         cdef void *hband = NULL             # <<<<<<<<<<<<<<
 *         cdef int success
 *         name_b = self.name.encode('utf-8')
 */
  __pyx_v_hband = NULL;

  /* "rasterio/_io.pyx":724
 *         cdef void *hband = NULL
 *         cdef int success
 *         name_b = self.name.encode('utf-8')             # <<<<<<<<<<<<<<
 *         cdef const char *fname = name_b
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.name, __pyx_n_s_encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_name_b = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":725
 *         cdef int success
 *         name_b = self.name.encode('utf-8')
 *         cdef const char *fname = name_b             # <<<<<<<<<<<<<<
 * 
 *         # Is there not a driver manager already?
 */
  __pyx_t_3 = __Pyx_PyObject_AsString(__pyx_v_name_b); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_fname = __pyx_t_3;

  /* "rasterio/_io.pyx":728
 * 
 *         # Is there not a driver manager already?
 *         if driver_count() == 0 and not self.env:             # <<<<<<<<<<<<<<
 *             # create a local manager and enter
 *             self.env = GDALEnv(True)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_driver_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_self->__pyx_base.env); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_6 = (!__pyx_t_5);
    __pyx_t_5 = __pyx_t_6;
  } else {
    __pyx_t_5 = __pyx_t_4;
  }
  if (__pyx_t_5) {

    /* "rasterio/_io.pyx":730
 *         if driver_count() == 0 and not self.env:
 *             # create a local manager and enter
 *             self.env = GDALEnv(True)             # <<<<<<<<<<<<<<
 *         else:
 *             self.env = GDALEnv(False)
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_GDALEnv); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GIVEREF(__pyx_t_1);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.env);
    __Pyx_DECREF(__pyx_v_self->__pyx_base.env);
    __pyx_v_self->__pyx_base.env = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":732
 *             self.env = GDALEnv(True)
 *         else:
 *             self.env = GDALEnv(False)             # <<<<<<<<<<<<<<
 *         self.env.start()
 * 
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_GDALEnv); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_tuple__44, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base.env);
    __Pyx_DECREF(__pyx_v_self->__pyx_base.env);
    __pyx_v_self->__pyx_base.env = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":733
 *         else:
 *             self.env = GDALEnv(False)
 *         self.env.start()             # <<<<<<<<<<<<<<
 * 
 *         if self.mode == 'w':
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.env, __pyx_n_s_start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":735
 *         self.env.start()
 * 
 *         if self.mode == 'w':             # <<<<<<<<<<<<<<
 *             # GDAL can Create() GTiffs. Many other formats only support
 *             # CreateCopy(). Rasterio lets you write GTiffs *only* for now.
 */
  __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_self->__pyx_base.mode, __pyx_n_s_w, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_5) {

    /* "rasterio/_io.pyx":738
 *             # GDAL can Create() GTiffs. Many other formats only support
 *             # CreateCopy(). Rasterio lets you write GTiffs *only* for now.
 *             if self.driver not in ['GTiff']:             # <<<<<<<<<<<<<<
 *                 raise ValueError("only GTiffs can be opened in 'w' mode")
 * 
 */
    __Pyx_INCREF(__pyx_v_self->__pyx_base.driver);
    __pyx_t_1 = __pyx_v_self->__pyx_base.driver;
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_n_s_GTiff, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = (((int)__pyx_t_5) != 0);
    if (__pyx_t_4) {

      /* "rasterio/_io.pyx":739
 *             # CreateCopy(). Rasterio lets you write GTiffs *only* for now.
 *             if self.driver not in ['GTiff']:
 *                 raise ValueError("only GTiffs can be opened in 'w' mode")             # <<<<<<<<<<<<<<
 * 
 *             # Delete existing file, create.
 */
      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":742
 * 
 *             # Delete existing file, create.
 *             if os.path.exists(self.name):             # <<<<<<<<<<<<<<
 *                 os.unlink(self.name)
 * 
 */
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_v_self->__pyx_base.name);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->__pyx_base.name);
    __Pyx_GIVEREF(__pyx_v_self->__pyx_base.name);
    __pyx_t_7 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_4) {

      /* "rasterio/_io.pyx":743
 *             # Delete existing file, create.
 *             if os.path.exists(self.name):
 *                 os.unlink(self.name)             # <<<<<<<<<<<<<<
 * 
 *             driver_b = self.driver.encode('utf-8')
 */
      __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_os); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_unlink); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_self->__pyx_base.name);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self->__pyx_base.name);
      __Pyx_GIVEREF(__pyx_v_self->__pyx_base.name);
      __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "rasterio/_io.pyx":745
 *                 os.unlink(self.name)
 * 
 *             driver_b = self.driver.encode('utf-8')             # <<<<<<<<<<<<<<
 *             drv_name = driver_b
 *             drv = _gdal.GDALGetDriverByName(drv_name)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->__pyx_base.driver, __pyx_n_s_encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = PyObject_Call(__pyx_t_1, __pyx_tuple__46, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_v_driver_b = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "rasterio/_io.pyx":746
 * 
 *             driver_b = self.driver.encode('utf-8')
 *             drv_name = driver_b             # <<<<<<<<<<<<<<
 *             drv = _gdal.GDALGetDriverByName(drv_name)
 *             if drv == NULL:
 */
    __pyx_t_8 = __Pyx_PyObject_AsString(__pyx_v_driver_b); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_drv_name = __pyx_t_8;

    /* "rasterio/_io.pyx":747
 *             driver_b = self.driver.encode('utf-8')
 *             drv_name = driver_b
 *             drv = _gdal.GDALGetDriverByName(drv_name)             # <<<<<<<<<<<<<<
 *             if drv == NULL:
 *                 raise ValueError("NULL driver for %s", self.driver)
 */
    __pyx_v_drv = GDALGetDriverByName(__pyx_v_drv_name);

    /* "rasterio/_io.pyx":748
 *             drv_name = driver_b
 *             drv = _gdal.GDALGetDriverByName(drv_name)
 *             if drv == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("NULL driver for %s", self.driver)
 * 
 */
    __pyx_t_4 = ((__pyx_v_drv == NULL) != 0);
    if (__pyx_t_4) {

      /* "rasterio/_io.pyx":749
 *             drv = _gdal.GDALGetDriverByName(drv_name)
 *             if drv == NULL:
 *                 raise ValueError("NULL driver for %s", self.driver)             # <<<<<<<<<<<<<<
 * 
 *             # Find the equivalent GDAL data type or raise an exception
 */
      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_kp_s_NULL_driver_for_s);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_s_NULL_driver_for_s);
      __Pyx_GIVEREF(__pyx_kp_s_NULL_driver_for_s);
      __Pyx_INCREF(__pyx_v_self->__pyx_base.driver);
      PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_self->__pyx_base.driver);
      __Pyx_GIVEREF(__pyx_v_self->__pyx_base.driver);
      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_1, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":754
 *             # We've mapped numpy scalar types to GDAL types so see
 *             # if we can crosswalk those.
 *             if hasattr(self._init_dtype, 'type'):             # <<<<<<<<<<<<<<
 *                 tp = self._init_dtype.type
 *                 if tp not in dtypes.dtype_rev:
 */
    __pyx_t_1 = __pyx_v_self->_init_dtype;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_4 = PyObject_HasAttr(__pyx_t_1, __pyx_n_s_type); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = (__pyx_t_4 != 0);
    if (__pyx_t_5) {

      /* "rasterio/_io.pyx":755
 *             # if we can crosswalk those.
 *             if hasattr(self._init_dtype, 'type'):
 *                 tp = self._init_dtype.type             # <<<<<<<<<<<<<<
 *                 if tp not in dtypes.dtype_rev:
 *                     raise ValueError(
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_init_dtype, __pyx_n_s_type); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_v_tp = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "rasterio/_io.pyx":756
 *             if hasattr(self._init_dtype, 'type'):
 *                 tp = self._init_dtype.type
 *                 if tp not in dtypes.dtype_rev:             # <<<<<<<<<<<<<<
 *                     raise ValueError(
 *                         "Unsupported dtype: %s" % self._init_dtype)
 */
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dtype_rev); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = (__Pyx_PySequence_Contains(__pyx_v_tp, __pyx_t_7, Py_NE)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_4 = (__pyx_t_5 != 0);
      if (__pyx_t_4) {

        /* "rasterio/_io.pyx":758
 *                 if tp not in dtypes.dtype_rev:
 *                     raise ValueError(
 *                         "Unsupported dtype: %s" % self._init_dtype)             # <<<<<<<<<<<<<<
 *                 else:
 *                     gdal_dtype = dtypes.dtype_rev.get(tp)
 */
        __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Unsupported_dtype_s, __pyx_v_self->_init_dtype); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);

        /* "rasterio/_io.pyx":757
 *                 tp = self._init_dtype.type
 *                 if tp not in dtypes.dtype_rev:
 *                     raise ValueError(             # <<<<<<<<<<<<<<
 *                         "Unsupported dtype: %s" % self._init_dtype)
 *                 else:
 */
        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_t_7 = 0;
        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_Raise(__pyx_t_7, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      /*else*/ {

        /* "rasterio/_io.pyx":760
 *                         "Unsupported dtype: %s" % self._init_dtype)
 *                 else:
 *                     gdal_dtype = dtypes.dtype_rev.get(tp)             # <<<<<<<<<<<<<<
 *             else:
 *                 gdal_dtype = dtypes.dtype_rev.get(self._init_dtype)
 */
        __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dtype_rev); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_v_tp);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_tp);
        __Pyx_GIVEREF(__pyx_v_tp);
        __pyx_t_2 = PyObject_Call(__pyx_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_v_gdal_dtype = __pyx_t_2;
        __pyx_t_2 = 0;
      }
      goto __pyx_L8;
    }
    /*else*/ {

      /* "rasterio/_io.pyx":762
 *                     gdal_dtype = dtypes.dtype_rev.get(tp)
 *             else:
 *                 gdal_dtype = dtypes.dtype_rev.get(self._init_dtype)             # <<<<<<<<<<<<<<
 * 
 *             # Creation options
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dtype_rev); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_self->_init_dtype);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->_init_dtype);
      __Pyx_GIVEREF(__pyx_v_self->_init_dtype);
      __pyx_t_7 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_gdal_dtype = __pyx_t_7;
      __pyx_t_7 = 0;
    }
    __pyx_L8:;

    /* "rasterio/_io.pyx":765
 * 
 *             # Creation options
 *             for k, v in self._options.items():             # <<<<<<<<<<<<<<
 *                 k, v = k.upper(), v.upper()
 *                 key_b = k.encode('utf-8')
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_options, __pyx_n_s_items); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = PyObject_Call(__pyx_t_7, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_7 = __pyx_t_1; __Pyx_INCREF(__pyx_t_7); __pyx_t_9 = 0;
      __pyx_t_10 = NULL;
    } else {
      __pyx_t_9 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_10 = Py_TYPE(__pyx_t_7)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (!__pyx_t_10 && PyList_CheckExact(__pyx_t_7)) {
        if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_7, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_10 && PyTuple_CheckExact(__pyx_t_7)) {
        if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_7, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_1 = __pyx_t_10(__pyx_t_7);
        if (unlikely(!__pyx_t_1)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_11);
        #else
        __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_12 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
        index = 0; __pyx_t_2 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_2)) goto __pyx_L12_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_2);
        index = 1; __pyx_t_11 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L12_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_11);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_13 = NULL;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L13_unpacking_done;
        __pyx_L12_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_13 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L13_unpacking_done:;
      }
      __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_2);
      __pyx_t_2 = 0;
      __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_11);
      __pyx_t_11 = 0;

      /* "rasterio/_io.pyx":766
 *             # Creation options
 *             for k, v in self._options.items():
 *                 k, v = k.upper(), v.upper()             # <<<<<<<<<<<<<<
 *                 key_b = k.encode('utf-8')
 *                 val_b = v.encode('utf-8')
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_k, __pyx_n_s_upper); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_upper); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF_SET(__pyx_v_k, __pyx_t_11);
      __pyx_t_11 = 0;
      __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "rasterio/_io.pyx":767
 *             for k, v in self._options.items():
 *                 k, v = k.upper(), v.upper()
 *                 key_b = k.encode('utf-8')             # <<<<<<<<<<<<<<
 *                 val_b = v.encode('utf-8')
 *                 key_c = key_b
 */
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_k, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_11 = PyObject_Call(__pyx_t_2, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF_SET(__pyx_v_key_b, __pyx_t_11);
      __pyx_t_11 = 0;

      /* "rasterio/_io.pyx":768
 *                 k, v = k.upper(), v.upper()
 *                 key_b = k.encode('utf-8')
 *                 val_b = v.encode('utf-8')             # <<<<<<<<<<<<<<
 *                 key_c = key_b
 *                 val_c = val_b
 */
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_encode); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_2 = PyObject_Call(__pyx_t_11, __pyx_tuple__48, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF_SET(__pyx_v_val_b, __pyx_t_2);
      __pyx_t_2 = 0;

      /* "rasterio/_io.pyx":769
 *                 key_b = k.encode('utf-8')
 *                 val_b = v.encode('utf-8')
 *                 key_c = key_b             # <<<<<<<<<<<<<<
 *                 val_c = val_b
 *                 options = _gdal.CSLSetNameValue(options, key_c, val_c)
 */
      __pyx_t_14 = __Pyx_PyObject_AsString(__pyx_v_key_b); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_key_c = __pyx_t_14;

      /* "rasterio/_io.pyx":770
 *                 val_b = v.encode('utf-8')
 *                 key_c = key_b
 *                 val_c = val_b             # <<<<<<<<<<<<<<
 *                 options = _gdal.CSLSetNameValue(options, key_c, val_c)
 *                 log.debug("Option: %r\n", (k, v))
 */
      __pyx_t_14 = __Pyx_PyObject_AsString(__pyx_v_val_b); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_val_c = __pyx_t_14;

      /* "rasterio/_io.pyx":771
 *                 key_c = key_b
 *                 val_c = val_b
 *                 options = _gdal.CSLSetNameValue(options, key_c, val_c)             # <<<<<<<<<<<<<<
 *                 log.debug("Option: %r\n", (k, v))
 * 
 */
      __pyx_v_options = CSLSetNameValue(__pyx_v_options, __pyx_v_key_c, __pyx_v_val_c);

      /* "rasterio/_io.pyx":772
 *                 val_c = val_b
 *                 options = _gdal.CSLSetNameValue(options, key_c, val_c)
 *                 log.debug("Option: %r\n", (k, v))             # <<<<<<<<<<<<<<
 * 
 *             self._hds = _gdal.GDALCreate(
 */
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_k);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_k);
      __Pyx_GIVEREF(__pyx_v_k);
      __Pyx_INCREF(__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_v);
      __Pyx_GIVEREF(__pyx_v_v);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_kp_s_Option_r);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_s_Option_r);
      __Pyx_GIVEREF(__pyx_kp_s_Option_r);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_11, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "rasterio/_io.pyx":775
 * 
 *             self._hds = _gdal.GDALCreate(
 *                 drv, fname, self.width, self.height, self._count,             # <<<<<<<<<<<<<<
 *                 gdal_dtype, options)
 *             if self._hds == NULL:
 */
    __pyx_t_15 = __Pyx_PyInt_As_int(__pyx_v_self->__pyx_base.width); if (unlikely((__pyx_t_15 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_16 = __Pyx_PyInt_As_int(__pyx_v_self->__pyx_base.height); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_17 = __Pyx_PyInt_As_int(__pyx_v_self->__pyx_base._count); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":776
 *             self._hds = _gdal.GDALCreate(
 *                 drv, fname, self.width, self.height, self._count,
 *                 gdal_dtype, options)             # <<<<<<<<<<<<<<
 *             if self._hds == NULL:
 *                 raise ValueError("NULL dataset")
 */
    __pyx_t_18 = ((GDALDataType)PyInt_AsLong(__pyx_v_gdal_dtype)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":774
 *                 log.debug("Option: %r\n", (k, v))
 * 
 *             self._hds = _gdal.GDALCreate(             # <<<<<<<<<<<<<<
 *                 drv, fname, self.width, self.height, self._count,
 *                 gdal_dtype, options)
 */
    __pyx_v_self->__pyx_base._hds = GDALCreate(__pyx_v_drv, __pyx_v_fname, __pyx_t_15, __pyx_t_16, __pyx_t_17, __pyx_t_18, __pyx_v_options);

    /* "rasterio/_io.pyx":777
 *                 drv, fname, self.width, self.height, self._count,
 *                 gdal_dtype, options)
 *             if self._hds == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("NULL dataset")
 * 
 */
    __pyx_t_4 = ((__pyx_v_self->__pyx_base._hds == NULL) != 0);
    if (__pyx_t_4) {

      /* "rasterio/_io.pyx":778
 *                 gdal_dtype, options)
 *             if self._hds == NULL:
 *                 raise ValueError("NULL dataset")             # <<<<<<<<<<<<<<
 * 
 *             if self._init_nodata is not None:
 */
      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":780
 *                 raise ValueError("NULL dataset")
 * 
 *             if self._init_nodata is not None:             # <<<<<<<<<<<<<<
 *                 for i in range(self._count):
 *                     hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 */
    __pyx_t_4 = (__pyx_v_self->_init_nodata != Py_None);
    __pyx_t_5 = (__pyx_t_4 != 0);
    if (__pyx_t_5) {

      /* "rasterio/_io.pyx":781
 * 
 *             if self._init_nodata is not None:
 *                 for i in range(self._count):             # <<<<<<<<<<<<<<
 *                     hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                     success = _gdal.GDALSetRasterNoDataValue(
 */
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_self->__pyx_base._count);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self->__pyx_base._count);
      __Pyx_GIVEREF(__pyx_v_self->__pyx_base._count);
      __pyx_t_2 = PyObject_Call(__pyx_builtin_range, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
        __pyx_t_7 = __pyx_t_2; __Pyx_INCREF(__pyx_t_7); __pyx_t_9 = 0;
        __pyx_t_10 = NULL;
      } else {
        __pyx_t_9 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_10 = Py_TYPE(__pyx_t_7)->tp_iternext;
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      for (;;) {
        if (!__pyx_t_10 && PyList_CheckExact(__pyx_t_7)) {
          if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_2 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_7, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else if (!__pyx_t_10 && PyTuple_CheckExact(__pyx_t_7)) {
          if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
          #if CYTHON_COMPILING_IN_CPYTHON
          __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #else
          __pyx_t_2 = PySequence_ITEM(__pyx_t_7, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          #endif
        } else {
          __pyx_t_2 = __pyx_t_10(__pyx_t_7);
          if (unlikely(!__pyx_t_2)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
            }
            break;
          }
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_2);
        __pyx_t_2 = 0;

        /* "rasterio/_io.pyx":782
 *             if self._init_nodata is not None:
 *                 for i in range(self._count):
 *                     hband = _gdal.GDALGetRasterBand(self._hds, i+1)             # <<<<<<<<<<<<<<
 *                     success = _gdal.GDALSetRasterNoDataValue(
 *                                     hband, self._init_nodata)
 */
        __pyx_t_2 = PyNumber_Add(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_17 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_v_hband = GDALGetRasterBand(__pyx_v_self->__pyx_base._hds, __pyx_t_17);

        /* "rasterio/_io.pyx":784
 *                     hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                     success = _gdal.GDALSetRasterNoDataValue(
 *                                     hband, self._init_nodata)             # <<<<<<<<<<<<<<
 * 
 *             if self._transform:
 */
        __pyx_t_19 = __pyx_PyFloat_AsDouble(__pyx_v_self->_init_nodata); if (unlikely((__pyx_t_19 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

        /* "rasterio/_io.pyx":783
 *                 for i in range(self._count):
 *                     hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                     success = _gdal.GDALSetRasterNoDataValue(             # <<<<<<<<<<<<<<
 *                                     hband, self._init_nodata)
 * 
 */
        __pyx_v_success = GDALSetRasterNoDataValue(__pyx_v_hband, __pyx_t_19);
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L15;
    }
    __pyx_L15:;

    /* "rasterio/_io.pyx":786
 *                                     hband, self._init_nodata)
 * 
 *             if self._transform:             # <<<<<<<<<<<<<<
 *                 self.write_transform(self._transform)
 *             if self._crs:
 */
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_self->__pyx_base._transform); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_5) {

      /* "rasterio/_io.pyx":787
 * 
 *             if self._transform:
 *                 self.write_transform(self._transform)             # <<<<<<<<<<<<<<
 *             if self._crs:
 *                 self.write_crs(self._crs)
 */
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write_transform); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_self->__pyx_base._transform);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->__pyx_base._transform);
      __Pyx_GIVEREF(__pyx_v_self->__pyx_base._transform);
      __pyx_t_1 = PyObject_Call(__pyx_t_7, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L18;
    }
    __pyx_L18:;

    /* "rasterio/_io.pyx":788
 *             if self._transform:
 *                 self.write_transform(self._transform)
 *             if self._crs:             # <<<<<<<<<<<<<<
 *                 self.write_crs(self._crs)
 * 
 */
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_self->__pyx_base._crs); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_5) {

      /* "rasterio/_io.pyx":789
 *                 self.write_transform(self._transform)
 *             if self._crs:
 *                 self.write_crs(self._crs)             # <<<<<<<<<<<<<<
 * 
 *         elif self.mode == 'r+':
 */
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write_crs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_self->__pyx_base._crs);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->__pyx_base._crs);
      __Pyx_GIVEREF(__pyx_v_self->__pyx_base._crs);
      __pyx_t_7 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L19;
    }
    __pyx_L19:;
    goto __pyx_L4;
  }

  /* "rasterio/_io.pyx":791
 *                 self.write_crs(self._crs)
 * 
 *         elif self.mode == 'r+':             # <<<<<<<<<<<<<<
 *             self._hds = _gdal.GDALOpen(fname, 1)
 *             if self._hds == NULL:
 */
  __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_v_self->__pyx_base.mode, __pyx_kp_s_r_2, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_5) {

    /* "rasterio/_io.pyx":792
 * 
 *         elif self.mode == 'r+':
 *             self._hds = _gdal.GDALOpen(fname, 1)             # <<<<<<<<<<<<<<
 *             if self._hds == NULL:
 *                 raise ValueError("NULL dataset")
 */
    __pyx_v_self->__pyx_base._hds = GDALOpen(__pyx_v_fname, 1);

    /* "rasterio/_io.pyx":793
 *         elif self.mode == 'r+':
 *             self._hds = _gdal.GDALOpen(fname, 1)
 *             if self._hds == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("NULL dataset")
 * 
 */
    __pyx_t_5 = ((__pyx_v_self->__pyx_base._hds == NULL) != 0);
    if (__pyx_t_5) {

      /* "rasterio/_io.pyx":794
 *             self._hds = _gdal.GDALOpen(fname, 1)
 *             if self._hds == NULL:
 *                 raise ValueError("NULL dataset")             # <<<<<<<<<<<<<<
 * 
 *         drv = _gdal.GDALGetDatasetDriver(self._hds)
 */
      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "rasterio/_io.pyx":796
 *                 raise ValueError("NULL dataset")
 * 
 *         drv = _gdal.GDALGetDatasetDriver(self._hds)             # <<<<<<<<<<<<<<
 *         drv_name = _gdal.GDALGetDriverShortName(drv)
 *         self.driver = drv_name.decode('utf-8')
 */
  __pyx_v_drv = GDALGetDatasetDriver(__pyx_v_self->__pyx_base._hds);

  /* "rasterio/_io.pyx":797
 * 
 *         drv = _gdal.GDALGetDatasetDriver(self._hds)
 *         drv_name = _gdal.GDALGetDriverShortName(drv)             # <<<<<<<<<<<<<<
 *         self.driver = drv_name.decode('utf-8')
 * 
 */
  __pyx_v_drv_name = GDALGetDriverShortName(__pyx_v_drv);

  /* "rasterio/_io.pyx":798
 *         drv = _gdal.GDALGetDatasetDriver(self._hds)
 *         drv_name = _gdal.GDALGetDriverShortName(drv)
 *         self.driver = drv_name.decode('utf-8')             # <<<<<<<<<<<<<<
 * 
 *         self._count = _gdal.GDALGetRasterCount(self._hds)
 */
  __pyx_t_7 = __Pyx_decode_c_string(__pyx_v_drv_name, 0, strlen(__pyx_v_drv_name), NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.driver);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.driver);
  __pyx_v_self->__pyx_base.driver = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "rasterio/_io.pyx":800
 *         self.driver = drv_name.decode('utf-8')
 * 
 *         self._count = _gdal.GDALGetRasterCount(self._hds)             # <<<<<<<<<<<<<<
 *         self.width = _gdal.GDALGetRasterXSize(self._hds)
 *         self.height = _gdal.GDALGetRasterYSize(self._hds)
 */
  __pyx_t_7 = __Pyx_PyInt_From_int(GDALGetRasterCount(__pyx_v_self->__pyx_base._hds)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._count);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._count);
  __pyx_v_self->__pyx_base._count = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "rasterio/_io.pyx":801
 * 
 *         self._count = _gdal.GDALGetRasterCount(self._hds)
 *         self.width = _gdal.GDALGetRasterXSize(self._hds)             # <<<<<<<<<<<<<<
 *         self.height = _gdal.GDALGetRasterYSize(self._hds)
 *         self.shape = (self.height, self.width)
 */
  __pyx_t_7 = __Pyx_PyInt_From_int(GDALGetRasterXSize(__pyx_v_self->__pyx_base._hds)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.width);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.width);
  __pyx_v_self->__pyx_base.width = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "rasterio/_io.pyx":802
 *         self._count = _gdal.GDALGetRasterCount(self._hds)
 *         self.width = _gdal.GDALGetRasterXSize(self._hds)
 *         self.height = _gdal.GDALGetRasterYSize(self._hds)             # <<<<<<<<<<<<<<
 *         self.shape = (self.height, self.width)
 * 
 */
  __pyx_t_7 = __Pyx_PyInt_From_int(GDALGetRasterYSize(__pyx_v_self->__pyx_base._hds)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.height);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.height);
  __pyx_v_self->__pyx_base.height = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "rasterio/_io.pyx":803
 *         self.width = _gdal.GDALGetRasterXSize(self._hds)
 *         self.height = _gdal.GDALGetRasterYSize(self._hds)
 *         self.shape = (self.height, self.width)             # <<<<<<<<<<<<<<
 * 
 *         self._transform = self.read_transform()
 */
  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.height);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self->__pyx_base.height);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.height);
  __Pyx_INCREF(__pyx_v_self->__pyx_base.width);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_self->__pyx_base.width);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base.width);
  __Pyx_GIVEREF(__pyx_t_7);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base.shape);
  __Pyx_DECREF(__pyx_v_self->__pyx_base.shape);
  __pyx_v_self->__pyx_base.shape = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "rasterio/_io.pyx":805
 *         self.shape = (self.height, self.width)
 * 
 *         self._transform = self.read_transform()             # <<<<<<<<<<<<<<
 *         self._crs = self.read_crs()
 *         self._crs_wkt = self.read_crs_wkt()
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_transform); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = PyObject_Call(__pyx_t_7, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._transform);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._transform);
  __pyx_v_self->__pyx_base._transform = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":806
 * 
 *         self._transform = self.read_transform()
 *         self._crs = self.read_crs()             # <<<<<<<<<<<<<<
 *         self._crs_wkt = self.read_crs_wkt()
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_crs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GIVEREF(__pyx_t_7);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._crs);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._crs);
  __pyx_v_self->__pyx_base._crs = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "rasterio/_io.pyx":807
 *         self._transform = self.read_transform()
 *         self._crs = self.read_crs()
 *         self._crs_wkt = self.read_crs_wkt()             # <<<<<<<<<<<<<<
 * 
 *         if options != NULL:
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_crs_wkt); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = PyObject_Call(__pyx_t_7, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._crs_wkt);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._crs_wkt);
  __pyx_v_self->__pyx_base._crs_wkt = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":809
 *         self._crs_wkt = self.read_crs_wkt()
 * 
 *         if options != NULL:             # <<<<<<<<<<<<<<
 *             _gdal.CSLDestroy(options)
 * 
 */
  __pyx_t_5 = ((__pyx_v_options != NULL) != 0);
  if (__pyx_t_5) {

    /* "rasterio/_io.pyx":810
 * 
 *         if options != NULL:
 *             _gdal.CSLDestroy(options)             # <<<<<<<<<<<<<<
 * 
 *         # touch self.meta
 */
    CSLDestroy(__pyx_v_options);
    goto __pyx_L21;
  }
  __pyx_L21:;

  /* "rasterio/_io.pyx":813
 * 
 *         # touch self.meta
 *         _ = self.meta             # <<<<<<<<<<<<<<
 * 
 *         self._closed = False
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_meta); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v__ = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":815
 *         _ = self.meta
 * 
 *         self._closed = False             # <<<<<<<<<<<<<<
 * 
 *     def get_crs(self):
 */
  __Pyx_INCREF(Py_False);
  __Pyx_GIVEREF(Py_False);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._closed);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._closed);
  __pyx_v_self->__pyx_base._closed = Py_False;

  /* "rasterio/_io.pyx":717
 *             hex(id(self)))
 * 
 *     def start(self):             # <<<<<<<<<<<<<<
 *         cdef const char *drv_name = NULL
 *         cdef char **options = NULL
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_name_b);
  __Pyx_XDECREF(__pyx_v_driver_b);
  __Pyx_XDECREF(__pyx_v_tp);
  __Pyx_XDECREF(__pyx_v_gdal_dtype);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_key_b);
  __Pyx_XDECREF(__pyx_v_val_b);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v__);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":817
 *         self._closed = False
 * 
 *     def get_crs(self):             # <<<<<<<<<<<<<<
 *         if not self._crs:
 *             self._crs = self.read_crs()
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_7get_crs(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_7get_crs(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_crs (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater_6get_crs(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_6get_crs(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("get_crs", 0);
  __Pyx_TraceCall("get_crs", __pyx_f[0], 817);

  /* "rasterio/_io.pyx":818
 * 
 *     def get_crs(self):
 *         if not self._crs:             # <<<<<<<<<<<<<<
 *             self._crs = self.read_crs()
 *         return self._crs
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->__pyx_base._crs); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "rasterio/_io.pyx":819
 *     def get_crs(self):
 *         if not self._crs:
 *             self._crs = self.read_crs()             # <<<<<<<<<<<<<<
 *         return self._crs
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_crs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base._crs);
    __Pyx_DECREF(__pyx_v_self->__pyx_base._crs);
    __pyx_v_self->__pyx_base._crs = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":820
 *         if not self._crs:
 *             self._crs = self.read_crs()
 *         return self._crs             # <<<<<<<<<<<<<<
 * 
 *     def write_crs(self, crs):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->__pyx_base._crs);
  __pyx_r = __pyx_v_self->__pyx_base._crs;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":817
 *         self._closed = False
 * 
 *     def get_crs(self):             # <<<<<<<<<<<<<<
 *         if not self._crs:
 *             self._crs = self.read_crs()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.get_crs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":822
 *         return self._crs
 * 
 *     def write_crs(self, crs):             # <<<<<<<<<<<<<<
 *         if self._hds == NULL:
 *             raise ValueError("Can't read closed raster file")
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_9write_crs(PyObject *__pyx_v_self, PyObject *__pyx_v_crs); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_9write_crs(PyObject *__pyx_v_self, PyObject *__pyx_v_crs) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_crs (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater_8write_crs(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self), ((PyObject *)__pyx_v_crs));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_8write_crs(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_crs) {
  void *__pyx_v_osr;
  PyObject *__pyx_v_params = NULL;
  PyObject *__pyx_v_k = NULL;
  PyObject *__pyx_v_v = NULL;
  PyObject *__pyx_v_proj = NULL;
  PyObject *__pyx_v_proj_b = NULL;
  char const *__pyx_v_proj_c;
  char *__pyx_v_wkt;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  int __pyx_t_13;
  char const *__pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_crs", 0);
  __Pyx_TraceCall("write_crs", __pyx_f[0], 822);

  /* "rasterio/_io.pyx":823
 * 
 *     def write_crs(self, crs):
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("Can't read closed raster file")
 *         cdef void *osr = _gdal.OSRNewSpatialReference(NULL)
 */
  __pyx_t_1 = ((__pyx_v_self->__pyx_base._hds == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":824
 *     def write_crs(self, crs):
 *         if self._hds == NULL:
 *             raise ValueError("Can't read closed raster file")             # <<<<<<<<<<<<<<
 *         cdef void *osr = _gdal.OSRNewSpatialReference(NULL)
 *         if osr == NULL:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":825
 *         if self._hds == NULL:
 *             raise ValueError("Can't read closed raster file")
 *         cdef void *osr = _gdal.OSRNewSpatialReference(NULL)             # <<<<<<<<<<<<<<
 *         if osr == NULL:
 *             raise ValueError("Null spatial reference")
 */
  __pyx_v_osr = OSRNewSpatialReference(NULL);

  /* "rasterio/_io.pyx":826
 *             raise ValueError("Can't read closed raster file")
 *         cdef void *osr = _gdal.OSRNewSpatialReference(NULL)
 *         if osr == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("Null spatial reference")
 *         params = []
 */
  __pyx_t_1 = ((__pyx_v_osr == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":827
 *         cdef void *osr = _gdal.OSRNewSpatialReference(NULL)
 *         if osr == NULL:
 *             raise ValueError("Null spatial reference")             # <<<<<<<<<<<<<<
 *         params = []
 *         for k, v in crs.items():
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__52, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":828
 *         if osr == NULL:
 *             raise ValueError("Null spatial reference")
 *         params = []             # <<<<<<<<<<<<<<
 *         for k, v in crs.items():
 *             if v is True or (k == 'no_defs' and v):
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_params = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":829
 *             raise ValueError("Null spatial reference")
 *         params = []
 *         for k, v in crs.items():             # <<<<<<<<<<<<<<
 *             if v is True or (k == 'no_defs' and v):
 *                 params.append("+%s" % k)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_crs, __pyx_n_s_items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
    __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0;
    __pyx_t_5 = NULL;
  } else {
    __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  for (;;) {
    if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_3 = __pyx_t_5(__pyx_t_2);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
      PyObject* sequence = __pyx_t_3;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_6 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_7 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      #else
      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      #endif
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
      index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = NULL;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L8_unpacking_done;
      __pyx_L7_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L8_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_6);
    __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "rasterio/_io.pyx":830
 *         params = []
 *         for k, v in crs.items():
 *             if v is True or (k == 'no_defs' and v):             # <<<<<<<<<<<<<<
 *                 params.append("+%s" % k)
 *             else:
 */
    __pyx_t_1 = (__pyx_v_v == Py_True);
    if (!__pyx_t_1) {
      __pyx_t_10 = (__Pyx_PyString_Equals(__pyx_v_k, __pyx_n_s_no_defs, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      if (__pyx_t_10) {
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_v); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_12 = __pyx_t_11;
      } else {
        __pyx_t_12 = __pyx_t_10;
      }
      __pyx_t_10 = __pyx_t_12;
    } else {
      __pyx_t_10 = __pyx_t_1;
    }
    if (__pyx_t_10) {

      /* "rasterio/_io.pyx":831
 *         for k, v in crs.items():
 *             if v is True or (k == 'no_defs' and v):
 *                 params.append("+%s" % k)             # <<<<<<<<<<<<<<
 *             else:
 *                 params.append("+%s=%s" % (k, v))
 */
      __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_s, __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_params, __pyx_t_3); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L9;
    }
    /*else*/ {

      /* "rasterio/_io.pyx":833
 *                 params.append("+%s" % k)
 *             else:
 *                 params.append("+%s=%s" % (k, v))             # <<<<<<<<<<<<<<
 *         proj = " ".join(params)
 *         proj_b = proj.encode()
 */
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_k);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_k);
      __Pyx_GIVEREF(__pyx_v_k);
      __Pyx_INCREF(__pyx_v_v);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_v);
      __Pyx_GIVEREF(__pyx_v_v);
      __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_s_s, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_params, __pyx_t_7); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    }
    __pyx_L9:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":834
 *             else:
 *                 params.append("+%s=%s" % (k, v))
 *         proj = " ".join(params)             # <<<<<<<<<<<<<<
 *         proj_b = proj.encode()
 *         cdef const char *proj_c = proj_b
 */
  __pyx_t_2 = __Pyx_PyString_Join(__pyx_kp_s__53, __pyx_v_params); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_proj = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":835
 *                 params.append("+%s=%s" % (k, v))
 *         proj = " ".join(params)
 *         proj_b = proj.encode()             # <<<<<<<<<<<<<<
 *         cdef const char *proj_c = proj_b
 *         _gdal.OSRImportFromProj4(osr, proj_c)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_proj, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_proj_b = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "rasterio/_io.pyx":836
 *         proj = " ".join(params)
 *         proj_b = proj.encode()
 *         cdef const char *proj_c = proj_b             # <<<<<<<<<<<<<<
 *         _gdal.OSRImportFromProj4(osr, proj_c)
 *         cdef char *wkt
 */
  __pyx_t_14 = __Pyx_PyObject_AsString(__pyx_v_proj_b); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_proj_c = __pyx_t_14;

  /* "rasterio/_io.pyx":837
 *         proj_b = proj.encode()
 *         cdef const char *proj_c = proj_b
 *         _gdal.OSRImportFromProj4(osr, proj_c)             # <<<<<<<<<<<<<<
 *         cdef char *wkt
 *         _gdal.OSRExportToWkt(osr, &wkt)
 */
  OSRImportFromProj4(__pyx_v_osr, __pyx_v_proj_c);

  /* "rasterio/_io.pyx":839
 *         _gdal.OSRImportFromProj4(osr, proj_c)
 *         cdef char *wkt
 *         _gdal.OSRExportToWkt(osr, &wkt)             # <<<<<<<<<<<<<<
 *         _gdal.GDALSetProjection(self._hds, wkt)
 *         _gdal.CPLFree(wkt)
 */
  OSRExportToWkt(__pyx_v_osr, (&__pyx_v_wkt));

  /* "rasterio/_io.pyx":840
 *         cdef char *wkt
 *         _gdal.OSRExportToWkt(osr, &wkt)
 *         _gdal.GDALSetProjection(self._hds, wkt)             # <<<<<<<<<<<<<<
 *         _gdal.CPLFree(wkt)
 *         _gdal.OSRDestroySpatialReference(osr)
 */
  GDALSetProjection(__pyx_v_self->__pyx_base._hds, __pyx_v_wkt);

  /* "rasterio/_io.pyx":841
 *         _gdal.OSRExportToWkt(osr, &wkt)
 *         _gdal.GDALSetProjection(self._hds, wkt)
 *         _gdal.CPLFree(wkt)             # <<<<<<<<<<<<<<
 *         _gdal.OSRDestroySpatialReference(osr)
 * 
 */
  CPLFree(__pyx_v_wkt);

  /* "rasterio/_io.pyx":842
 *         _gdal.GDALSetProjection(self._hds, wkt)
 *         _gdal.CPLFree(wkt)
 *         _gdal.OSRDestroySpatialReference(osr)             # <<<<<<<<<<<<<<
 * 
 *         self._crs = crs
 */
  OSRDestroySpatialReference(__pyx_v_osr);

  /* "rasterio/_io.pyx":844
 *         _gdal.OSRDestroySpatialReference(osr)
 * 
 *         self._crs = crs             # <<<<<<<<<<<<<<
 * 
 *     crs = property(get_crs, write_crs)
 */
  __Pyx_INCREF(__pyx_v_crs);
  __Pyx_GIVEREF(__pyx_v_crs);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._crs);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._crs);
  __pyx_v_self->__pyx_base._crs = __pyx_v_crs;

  /* "rasterio/_io.pyx":822
 *         return self._crs
 * 
 *     def write_crs(self, crs):             # <<<<<<<<<<<<<<
 *         if self._hds == NULL:
 *             raise ValueError("Can't read closed raster file")
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.write_crs", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_params);
  __Pyx_XDECREF(__pyx_v_k);
  __Pyx_XDECREF(__pyx_v_v);
  __Pyx_XDECREF(__pyx_v_proj);
  __Pyx_XDECREF(__pyx_v_proj_b);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":848
 *     crs = property(get_crs, write_crs)
 * 
 *     def write_transform(self, transform):             # <<<<<<<<<<<<<<
 *         if self._hds == NULL:
 *             raise ValueError("Can't read closed raster file")
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_11write_transform(PyObject *__pyx_v_self, PyObject *__pyx_v_transform); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_11write_transform(PyObject *__pyx_v_self, PyObject *__pyx_v_transform) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_transform (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater_10write_transform(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self), ((PyObject *)__pyx_v_transform));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_10write_transform(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_transform) {
  double __pyx_v_gt[6];
  long __pyx_v_i;
  CYTHON_UNUSED int __pyx_v_retval;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  long __pyx_t_3;
  double __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_transform", 0);
  __Pyx_TraceCall("write_transform", __pyx_f[0], 848);

  /* "rasterio/_io.pyx":849
 * 
 *     def write_transform(self, transform):
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("Can't read closed raster file")
 *         cdef double gt[6]
 */
  __pyx_t_1 = ((__pyx_v_self->__pyx_base._hds == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":850
 *     def write_transform(self, transform):
 *         if self._hds == NULL:
 *             raise ValueError("Can't read closed raster file")             # <<<<<<<<<<<<<<
 *         cdef double gt[6]
 *         for i in range(6):
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__54, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":852
 *             raise ValueError("Can't read closed raster file")
 *         cdef double gt[6]
 *         for i in range(6):             # <<<<<<<<<<<<<<
 *             gt[i] = transform[i]
 *         retval = _gdal.GDALSetGeoTransform(self._hds, gt)
 */
  for (__pyx_t_3 = 0; __pyx_t_3 < 6; __pyx_t_3+=1) {
    __pyx_v_i = __pyx_t_3;

    /* "rasterio/_io.pyx":853
 *         cdef double gt[6]
 *         for i in range(6):
 *             gt[i] = transform[i]             # <<<<<<<<<<<<<<
 *         retval = _gdal.GDALSetGeoTransform(self._hds, gt)
 *         self._transform = transform
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_transform, __pyx_v_i, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    (__pyx_v_gt[__pyx_v_i]) = __pyx_t_4;
  }

  /* "rasterio/_io.pyx":854
 *         for i in range(6):
 *             gt[i] = transform[i]
 *         retval = _gdal.GDALSetGeoTransform(self._hds, gt)             # <<<<<<<<<<<<<<
 *         self._transform = transform
 * 
 */
  __pyx_v_retval = GDALSetGeoTransform(__pyx_v_self->__pyx_base._hds, __pyx_v_gt);

  /* "rasterio/_io.pyx":855
 *             gt[i] = transform[i]
 *         retval = _gdal.GDALSetGeoTransform(self._hds, gt)
 *         self._transform = transform             # <<<<<<<<<<<<<<
 * 
 *     def get_transform(self):
 */
  __Pyx_INCREF(__pyx_v_transform);
  __Pyx_GIVEREF(__pyx_v_transform);
  __Pyx_GOTREF(__pyx_v_self->__pyx_base._transform);
  __Pyx_DECREF(__pyx_v_self->__pyx_base._transform);
  __pyx_v_self->__pyx_base._transform = __pyx_v_transform;

  /* "rasterio/_io.pyx":848
 *     crs = property(get_crs, write_crs)
 * 
 *     def write_transform(self, transform):             # <<<<<<<<<<<<<<
 *         if self._hds == NULL:
 *             raise ValueError("Can't read closed raster file")
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.write_transform", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":857
 *         self._transform = transform
 * 
 *     def get_transform(self):             # <<<<<<<<<<<<<<
 *         if not self._transform:
 *             self._transform = self.read_transform()
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_13get_transform(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_13get_transform(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_transform (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater_12get_transform(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_12get_transform(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("get_transform", 0);
  __Pyx_TraceCall("get_transform", __pyx_f[0], 857);

  /* "rasterio/_io.pyx":858
 * 
 *     def get_transform(self):
 *         if not self._transform:             # <<<<<<<<<<<<<<
 *             self._transform = self.read_transform()
 *         return self._transform
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_self->__pyx_base._transform); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = ((!__pyx_t_1) != 0);
  if (__pyx_t_2) {

    /* "rasterio/_io.pyx":859
 *     def get_transform(self):
 *         if not self._transform:
 *             self._transform = self.read_transform()             # <<<<<<<<<<<<<<
 *         return self._transform
 * 
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_transform); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GIVEREF(__pyx_t_4);
    __Pyx_GOTREF(__pyx_v_self->__pyx_base._transform);
    __Pyx_DECREF(__pyx_v_self->__pyx_base._transform);
    __pyx_v_self->__pyx_base._transform = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "rasterio/_io.pyx":860
 *         if not self._transform:
 *             self._transform = self.read_transform()
 *         return self._transform             # <<<<<<<<<<<<<<
 * 
 *     transform = property(get_transform, write_transform)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->__pyx_base._transform);
  __pyx_r = __pyx_v_self->__pyx_base._transform;
  goto __pyx_L0;

  /* "rasterio/_io.pyx":857
 *         self._transform = transform
 * 
 *     def get_transform(self):             # <<<<<<<<<<<<<<
 *         if not self._transform:
 *             self._transform = self.read_transform()
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.get_transform", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":864
 *     transform = property(get_transform, write_transform)
 * 
 *     def write_band(self, bidx, src, window=None):             # <<<<<<<<<<<<<<
 *         """Write the src array into the `bidx` band.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_15write_band(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8rasterio_3_io_13RasterUpdater_14write_band[] = "Write the src array into the `bidx` band.\n\n        Band indexes begin with 1: read_band(1) returns the first band.\n\n        The optional `window` argument takes a tuple like:\n        \n            ((row_start, row_stop), (col_start, col_stop))\n            \n        specifying a raster subset to write into.\n        ";
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_15write_band(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bidx = 0;
  PyObject *__pyx_v_src = 0;
  PyObject *__pyx_v_window = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_band (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bidx,&__pyx_n_s_src,&__pyx_n_s_window,0};
    PyObject* values[3] = {0,0,0};
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bidx)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_src)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_band", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window);
          if (value) { values[2] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_band") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_bidx = values[0];
    __pyx_v_src = values[1];
    __pyx_v_window = values[2];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_band", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.write_band", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater_14write_band(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self), __pyx_v_bidx, __pyx_v_src, __pyx_v_window);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_14write_band(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_bidx, PyObject *__pyx_v_src, PyObject *__pyx_v_window) {
  PyObject *__pyx_v_i = NULL;
  void *__pyx_v_hband;
  PyObject *__pyx_v_yoff = NULL;
  PyObject *__pyx_v_xoff = NULL;
  PyObject *__pyx_v_height = NULL;
  PyObject *__pyx_v_width = NULL;
  PyObject *__pyx_v_dtype = NULL;
  CYTHON_UNUSED int __pyx_v_retval;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_band", 0);
  __Pyx_TraceCall("write_band", __pyx_f[0], 864);
  __Pyx_INCREF(__pyx_v_window);

  /* "rasterio/_io.pyx":875
 *         specifying a raster subset to write into.
 *         """
 *         if bidx not in self.indexes:             # <<<<<<<<<<<<<<
 *             raise IndexError("band index out of range")
 *         i = self.indexes.index(bidx)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_indexes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = (__Pyx_PySequence_Contains(__pyx_v_bidx, __pyx_t_1, Py_NE)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":876
 *         """
 *         if bidx not in self.indexes:
 *             raise IndexError("band index out of range")             # <<<<<<<<<<<<<<
 *         i = self.indexes.index(bidx)
 *         if self._hds == NULL:
 */
    __pyx_t_1 = PyObject_Call(__pyx_builtin_IndexError, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":877
 *         if bidx not in self.indexes:
 *             raise IndexError("band index out of range")
 *         i = self.indexes.index(bidx)             # <<<<<<<<<<<<<<
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_indexes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_index); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_bidx);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_bidx);
  __Pyx_GIVEREF(__pyx_v_bidx);
  __pyx_t_5 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_i = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "rasterio/_io.pyx":878
 *             raise IndexError("band index out of range")
 *         i = self.indexes.index(bidx)
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("can't read closed raster file")
 *         if src is not None and src.dtype != self.dtypes[i]:
 */
  __pyx_t_3 = ((__pyx_v_self->__pyx_base._hds == NULL) != 0);
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":879
 *         i = self.indexes.index(bidx)
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *         if src is not None and src.dtype != self.dtypes[i]:
 *             raise ValueError(
 */
    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__56, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":880
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")
 *         if src is not None and src.dtype != self.dtypes[i]:             # <<<<<<<<<<<<<<
 *             raise ValueError(
 *                 "the array's dtype '%s' does not match "
 */
  __pyx_t_3 = (__pyx_v_src != Py_None);
  if (__pyx_t_3) {
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dtypes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyObject_GetItem(__pyx_t_1, __pyx_v_i); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_5, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __pyx_t_2;
  } else {
    __pyx_t_6 = __pyx_t_3;
  }
  if (__pyx_t_6) {

    /* "rasterio/_io.pyx":883
 *             raise ValueError(
 *                 "the array's dtype '%s' does not match "
 *                 "the file's dtype '%s'" % (src.dtype, self.dtypes[i]))             # <<<<<<<<<<<<<<
 * 
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_dtype); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_GetItem(__pyx_t_4, __pyx_v_i); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_1 = 0;
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_the_array_s_dtype_s_does_not_mat, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "rasterio/_io.pyx":881
 *             raise ValueError("can't read closed raster file")
 *         if src is not None and src.dtype != self.dtypes[i]:
 *             raise ValueError(             # <<<<<<<<<<<<<<
 *                 "the array's dtype '%s' does not match "
 *                 "the file's dtype '%s'" % (src.dtype, self.dtypes[i]))
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":885
 *                 "the file's dtype '%s'" % (src.dtype, self.dtypes[i]))
 * 
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)             # <<<<<<<<<<<<<<
 *         if hband == NULL:
 *             raise ValueError("NULL band")
 */
  __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_bidx); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_hband = GDALGetRasterBand(__pyx_v_self->__pyx_base._hds, __pyx_t_7);

  /* "rasterio/_io.pyx":886
 * 
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 *         if hband == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("NULL band")
 * 
 */
  __pyx_t_6 = ((__pyx_v_hband == NULL) != 0);
  if (__pyx_t_6) {

    /* "rasterio/_io.pyx":887
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 *         if hband == NULL:
 *             raise ValueError("NULL band")             # <<<<<<<<<<<<<<
 * 
 *         if window:
 */
    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":889
 *             raise ValueError("NULL band")
 * 
 *         if window:             # <<<<<<<<<<<<<<
 *             window = eval_window(window, self.height, self.width)
 *             yoff = window[0][0]
 */
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_window); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_6) {

    /* "rasterio/_io.pyx":890
 * 
 *         if window:
 *             window = eval_window(window, self.height, self.width)             # <<<<<<<<<<<<<<
 *             yoff = window[0][0]
 *             xoff = window[1][0]
 */
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_self->__pyx_base.height); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_self->__pyx_base.width); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __pyx_f_8rasterio_3_io_eval_window(__pyx_v_window, __pyx_t_7, __pyx_t_8, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF_SET(__pyx_v_window, __pyx_t_5);
    __pyx_t_5 = 0;

    /* "rasterio/_io.pyx":891
 *         if window:
 *             window = eval_window(window, self.height, self.width)
 *             yoff = window[0][0]             # <<<<<<<<<<<<<<
 *             xoff = window[1][0]
 *             height = window[0][1] - yoff
 */
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_window, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_v_yoff = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "rasterio/_io.pyx":892
 *             window = eval_window(window, self.height, self.width)
 *             yoff = window[0][0]
 *             xoff = window[1][0]             # <<<<<<<<<<<<<<
 *             height = window[0][1] - yoff
 *             width = window[1][1] - xoff
 */
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_window, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_xoff = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "rasterio/_io.pyx":893
 *             yoff = window[0][0]
 *             xoff = window[1][0]
 *             height = window[0][1] - yoff             # <<<<<<<<<<<<<<
 *             width = window[1][1] - xoff
 *         else:
 */
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_window, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_5, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Subtract(__pyx_t_4, __pyx_v_yoff); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_height = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "rasterio/_io.pyx":894
 *             xoff = window[1][0]
 *             height = window[0][1] - yoff
 *             width = window[1][1] - xoff             # <<<<<<<<<<<<<<
 *         else:
 *             xoff = yoff = 0
 */
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_window, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_5, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyNumber_Subtract(__pyx_t_4, __pyx_v_xoff); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_width = __pyx_t_5;
    __pyx_t_5 = 0;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":896
 *             width = window[1][1] - xoff
 *         else:
 *             xoff = yoff = 0             # <<<<<<<<<<<<<<
 *             width = self.width
 *             height = self.height
 */
    __pyx_t_5 = __Pyx_PyInt_From_long(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_v_xoff = __pyx_t_5;
    __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyInt_From_long(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_v_yoff = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "rasterio/_io.pyx":897
 *         else:
 *             xoff = yoff = 0
 *             width = self.width             # <<<<<<<<<<<<<<
 *             height = self.height
 *         dtype = self.dtypes[i]
 */
    __pyx_t_5 = __pyx_v_self->__pyx_base.width;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_v_width = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "rasterio/_io.pyx":898
 *             xoff = yoff = 0
 *             width = self.width
 *             height = self.height             # <<<<<<<<<<<<<<
 *         dtype = self.dtypes[i]
 *         if dtype == dtypes.ubyte:
 */
    __pyx_t_5 = __pyx_v_self->__pyx_base.height;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_v_height = __pyx_t_5;
    __pyx_t_5 = 0;
  }
  __pyx_L7:;

  /* "rasterio/_io.pyx":899
 *             width = self.width
 *             height = self.height
 *         dtype = self.dtypes[i]             # <<<<<<<<<<<<<<
 *         if dtype == dtypes.ubyte:
 *             retval = io_ubyte(
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dtypes); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyObject_GetItem(__pyx_t_5, __pyx_v_i); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_dtype = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "rasterio/_io.pyx":900
 *             height = self.height
 *         dtype = self.dtypes[i]
 *         if dtype == dtypes.ubyte:             # <<<<<<<<<<<<<<
 *             retval = io_ubyte(
 *                 hband, 1, xoff, yoff, width, height, src)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ubyte); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "rasterio/_io.pyx":902
 *         if dtype == dtypes.ubyte:
 *             retval = io_ubyte(
 *                 hband, 1, xoff, yoff, width, height, src)             # <<<<<<<<<<<<<<
 *         elif dtype == dtypes.uint16:
 *             retval = io_uint16(
 */
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":901
 *         dtype = self.dtypes[i]
 *         if dtype == dtypes.ubyte:
 *             retval = io_ubyte(             # <<<<<<<<<<<<<<
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.uint16:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_ubyte(__pyx_v_hband, 1, __pyx_t_8, __pyx_t_7, __pyx_t_9, __pyx_t_10, ((PyArrayObject *)__pyx_v_src));
    goto __pyx_L8;
  }

  /* "rasterio/_io.pyx":903
 *             retval = io_ubyte(
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.uint16:             # <<<<<<<<<<<<<<
 *             retval = io_uint16(
 *                 hband, 1, xoff, yoff, width, height, src)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint16); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "rasterio/_io.pyx":905
 *         elif dtype == dtypes.uint16:
 *             retval = io_uint16(
 *                 hband, 1, xoff, yoff, width, height, src)             # <<<<<<<<<<<<<<
 *         elif dtype == dtypes.int16:
 *             retval = io_int16(
 */
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":904
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.uint16:
 *             retval = io_uint16(             # <<<<<<<<<<<<<<
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.int16:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_uint16(__pyx_v_hband, 1, __pyx_t_10, __pyx_t_9, __pyx_t_7, __pyx_t_8, ((PyArrayObject *)__pyx_v_src));
    goto __pyx_L8;
  }

  /* "rasterio/_io.pyx":906
 *             retval = io_uint16(
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.int16:             # <<<<<<<<<<<<<<
 *             retval = io_int16(
 *                 hband, 1, xoff, yoff, width, height, src)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int16); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "rasterio/_io.pyx":908
 *         elif dtype == dtypes.int16:
 *             retval = io_int16(
 *                 hband, 1, xoff, yoff, width, height, src)             # <<<<<<<<<<<<<<
 *         elif dtype == dtypes.uint32:
 *             retval = io_uint32(
 */
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":907
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.int16:
 *             retval = io_int16(             # <<<<<<<<<<<<<<
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.uint32:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_int16(__pyx_v_hband, 1, __pyx_t_8, __pyx_t_7, __pyx_t_9, __pyx_t_10, ((PyArrayObject *)__pyx_v_src));
    goto __pyx_L8;
  }

  /* "rasterio/_io.pyx":909
 *             retval = io_int16(
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.uint32:             # <<<<<<<<<<<<<<
 *             retval = io_uint32(
 *                 hband, 1, xoff, yoff, width, height, src)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_uint32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "rasterio/_io.pyx":911
 *         elif dtype == dtypes.uint32:
 *             retval = io_uint32(
 *                 hband, 1, xoff, yoff, width, height, src)             # <<<<<<<<<<<<<<
 *         elif dtype == dtypes.int32:
 *             retval = io_int32(
 */
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":910
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.uint32:
 *             retval = io_uint32(             # <<<<<<<<<<<<<<
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.int32:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_uint32(__pyx_v_hband, 1, __pyx_t_10, __pyx_t_9, __pyx_t_7, __pyx_t_8, ((PyArrayObject *)__pyx_v_src));
    goto __pyx_L8;
  }

  /* "rasterio/_io.pyx":912
 *             retval = io_uint32(
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.int32:             # <<<<<<<<<<<<<<
 *             retval = io_int32(
 *                 hband, 1, xoff, yoff, width, height, src)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "rasterio/_io.pyx":914
 *         elif dtype == dtypes.int32:
 *             retval = io_int32(
 *                 hband, 1, xoff, yoff, width, height, src)             # <<<<<<<<<<<<<<
 *         elif dtype == dtypes.float32:
 *             retval = io_float32(
 */
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":913
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.int32:
 *             retval = io_int32(             # <<<<<<<<<<<<<<
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.float32:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_int32(__pyx_v_hband, 1, __pyx_t_8, __pyx_t_7, __pyx_t_9, __pyx_t_10, ((PyArrayObject *)__pyx_v_src));
    goto __pyx_L8;
  }

  /* "rasterio/_io.pyx":915
 *             retval = io_int32(
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.float32:             # <<<<<<<<<<<<<<
 *             retval = io_float32(
 *                 hband, 1, xoff, yoff, width, height, src)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float32); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "rasterio/_io.pyx":917
 *         elif dtype == dtypes.float32:
 *             retval = io_float32(
 *                 hband, 1, xoff, yoff, width, height, src)             # <<<<<<<<<<<<<<
 *         elif dtype == dtypes.float64:
 *             retval = io_float64(
 */
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":916
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.float32:
 *             retval = io_float32(             # <<<<<<<<<<<<<<
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.float64:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_float32(__pyx_v_hband, 1, __pyx_t_10, __pyx_t_9, __pyx_t_7, __pyx_t_8, ((PyArrayObject *)__pyx_v_src));
    goto __pyx_L8;
  }

  /* "rasterio/_io.pyx":918
 *             retval = io_float32(
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.float64:             # <<<<<<<<<<<<<<
 *             retval = io_float64(
 *                 hband, 1, xoff, yoff, width, height, src)
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_dtypes); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_RichCompare(__pyx_v_dtype, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_6) {

    /* "rasterio/_io.pyx":920
 *         elif dtype == dtypes.float64:
 *             retval = io_float64(
 *                 hband, 1, xoff, yoff, width, height, src)             # <<<<<<<<<<<<<<
 *         else:
 *             raise ValueError("Invalid dtype")
 */
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":919
 *                 hband, 1, xoff, yoff, width, height, src)
 *         elif dtype == dtypes.float64:
 *             retval = io_float64(             # <<<<<<<<<<<<<<
 *                 hband, 1, xoff, yoff, width, height, src)
 *         else:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_float64(__pyx_v_hband, 1, __pyx_t_8, __pyx_t_7, __pyx_t_9, __pyx_t_10, ((PyArrayObject *)__pyx_v_src));
    goto __pyx_L8;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":922
 *                 hband, 1, xoff, yoff, width, height, src)
 *         else:
 *             raise ValueError("Invalid dtype")             # <<<<<<<<<<<<<<
 *         # TODO: handle errors (by retval).
 * 
 */
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__58, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L8:;

  /* "rasterio/_io.pyx":864
 *     transform = property(get_transform, write_transform)
 * 
 *     def write_band(self, bidx, src, window=None):             # <<<<<<<<<<<<<<
 *         """Write the src array into the `bidx` band.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.write_band", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_yoff);
  __Pyx_XDECREF(__pyx_v_xoff);
  __Pyx_XDECREF(__pyx_v_height);
  __Pyx_XDECREF(__pyx_v_width);
  __Pyx_XDECREF(__pyx_v_dtype);
  __Pyx_XDECREF(__pyx_v_window);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":925
 *         # TODO: handle errors (by retval).
 * 
 *     def update_tags(self, bidx=0, ns=None, **kwargs):             # <<<<<<<<<<<<<<
 *         """Updates the tags of a dataset or one of its bands.
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_17update_tags(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8rasterio_3_io_13RasterUpdater_16update_tags[] = "Updates the tags of a dataset or one of its bands.\n\n        Tags are pairs of key and value strings. Tags belong to\n        namespaces.  The standard namespaces are: default (None) and\n        'IMAGE_STRUCTURE'.  Applications can create their own additional\n        namespaces.\n\n        The optional bidx argument can be used to select the dataset\n        band. The optional ns argument can be used to select a namespace\n        other than the default.\n        ";
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_17update_tags(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bidx = 0;
  PyObject *__pyx_v_ns = 0;
  PyObject *__pyx_v_kwargs = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update_tags (wrapper)", 0);
  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
  __Pyx_GOTREF(__pyx_v_kwargs);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bidx,&__pyx_n_s_ns,0};
    PyObject* values[2] = {0,0};
    values[0] = ((PyObject *)__pyx_int_0);
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bidx);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ns);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "update_tags") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_bidx = values[0];
    __pyx_v_ns = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("update_tags", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.update_tags", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater_16update_tags(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self), __pyx_v_bidx, __pyx_v_ns, __pyx_v_kwargs);

  /* function exit code */
  __Pyx_XDECREF(__pyx_v_kwargs);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_16update_tags(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_bidx, PyObject *__pyx_v_ns, PyObject *__pyx_v_kwargs) {
  char *__pyx_v_key_c;
  char *__pyx_v_value_c;
  void *__pyx_v_hobj;
  char const *__pyx_v_domain_c;
  PyObject *__pyx_v_domain_b = NULL;
  char **__pyx_v_papszStrList;
  PyObject *__pyx_v_key = NULL;
  PyObject *__pyx_v_value = NULL;
  PyObject *__pyx_v_key_b = NULL;
  PyObject *__pyx_v_value_b = NULL;
  int __pyx_v_i;
  CYTHON_UNUSED int __pyx_v_retval;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  void *__pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  char const *__pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *(*__pyx_t_13)(PyObject *);
  char *__pyx_t_14;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("update_tags", 0);
  __Pyx_TraceCall("update_tags", __pyx_f[0], 925);

  /* "rasterio/_io.pyx":940
 *         cdef void *hobj
 *         cdef const char *domain_c
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("can't read closed raster file")
 *         if bidx > 0:
 */
  __pyx_t_1 = ((__pyx_v_self->__pyx_base._hds == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":941
 *         cdef const char *domain_c
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":942
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")
 *         if bidx > 0:             # <<<<<<<<<<<<<<
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_bidx, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":943
 *             raise ValueError("can't read closed raster file")
 *         if bidx > 0:
 *             if bidx not in self.indexes:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Invalid band index")
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_indexes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = (__Pyx_PySequence_Contains(__pyx_v_bidx, __pyx_t_2, Py_NE)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = (__pyx_t_1 != 0);
    if (__pyx_t_3) {

      /* "rasterio/_io.pyx":944
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")             # <<<<<<<<<<<<<<
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hobj == NULL:
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__60, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":945
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)             # <<<<<<<<<<<<<<
 *             if hobj == NULL:
 *                 raise ValueError("NULL band")
 */
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_bidx); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_hobj = GDALGetRasterBand(__pyx_v_self->__pyx_base._hds, __pyx_t_4);

    /* "rasterio/_io.pyx":946
 *                 raise ValueError("Invalid band index")
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hobj == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("NULL band")
 *         else:
 */
    __pyx_t_3 = ((__pyx_v_hobj == NULL) != 0);
    if (__pyx_t_3) {

      /* "rasterio/_io.pyx":947
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hobj == NULL:
 *                 raise ValueError("NULL band")             # <<<<<<<<<<<<<<
 *         else:
 *             hobj = self._hds
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    goto __pyx_L4;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":949
 *                 raise ValueError("NULL band")
 *         else:
 *             hobj = self._hds             # <<<<<<<<<<<<<<
 *         if ns:
 *             domain_b = ns.encode('utf-8')
 */
    __pyx_t_5 = __pyx_v_self->__pyx_base._hds;
    __pyx_v_hobj = __pyx_t_5;
  }
  __pyx_L4:;

  /* "rasterio/_io.pyx":950
 *         else:
 *             hobj = self._hds
 *         if ns:             # <<<<<<<<<<<<<<
 *             domain_b = ns.encode('utf-8')
 *             domain_c = domain_b
 */
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_ns); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {

    /* "rasterio/_io.pyx":951
 *             hobj = self._hds
 *         if ns:
 *             domain_b = ns.encode('utf-8')             # <<<<<<<<<<<<<<
 *             domain_c = domain_b
 *         else:
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ns, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyObject_Call(__pyx_t_2, __pyx_tuple__62, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_domain_b = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "rasterio/_io.pyx":952
 *         if ns:
 *             domain_b = ns.encode('utf-8')
 *             domain_c = domain_b             # <<<<<<<<<<<<<<
 *         else:
 *             domain_c = NULL
 */
    __pyx_t_7 = __Pyx_PyObject_AsString(__pyx_v_domain_b); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_domain_c = __pyx_t_7;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":954
 *             domain_c = domain_b
 *         else:
 *             domain_c = NULL             # <<<<<<<<<<<<<<
 *         cdef char **papszStrList = _gdal.GDALGetMetadata(hobj, domain_c)
 *         for key, value in kwargs.items():
 */
    __pyx_v_domain_c = NULL;
  }
  __pyx_L7:;

  /* "rasterio/_io.pyx":955
 *         else:
 *             domain_c = NULL
 *         cdef char **papszStrList = _gdal.GDALGetMetadata(hobj, domain_c)             # <<<<<<<<<<<<<<
 *         for key, value in kwargs.items():
 *             key_b = text_type(key).encode('utf-8')
 */
  __pyx_v_papszStrList = GDALGetMetadata(__pyx_v_hobj, __pyx_v_domain_c);

  /* "rasterio/_io.pyx":956
 *             domain_c = NULL
 *         cdef char **papszStrList = _gdal.GDALGetMetadata(hobj, domain_c)
 *         for key, value in kwargs.items():             # <<<<<<<<<<<<<<
 *             key_b = text_type(key).encode('utf-8')
 *             value_b = text_type(value).encode('utf-8')
 */
  __pyx_t_6 = __Pyx_PyDict_Items(__pyx_v_kwargs); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
    __pyx_t_2 = __pyx_t_6; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  for (;;) {
    if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_6 = __pyx_t_9(__pyx_t_2);
      if (unlikely(!__pyx_t_6)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_6);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
      PyObject* sequence = __pyx_t_6;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_10 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_11);
      #else
      __pyx_t_10 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_11);
      #endif
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_12 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
      index = 0; __pyx_t_10 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_10)) goto __pyx_L10_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_10);
      index = 1; __pyx_t_11 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L10_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_11);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_13 = NULL;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      goto __pyx_L11_unpacking_done;
      __pyx_L10_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_13 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L11_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_10);
    __pyx_t_10 = 0;
    __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_11);
    __pyx_t_11 = 0;

    /* "rasterio/_io.pyx":957
 *         cdef char **papszStrList = _gdal.GDALGetMetadata(hobj, domain_c)
 *         for key, value in kwargs.items():
 *             key_b = text_type(key).encode('utf-8')             # <<<<<<<<<<<<<<
 *             value_b = text_type(value).encode('utf-8')
 *             key_c = key_b
 */
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_text_type); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_v_key);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_key);
    __Pyx_GIVEREF(__pyx_v_key);
    __pyx_t_10 = PyObject_Call(__pyx_t_6, __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_encode); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = PyObject_Call(__pyx_t_11, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF_SET(__pyx_v_key_b, __pyx_t_10);
    __pyx_t_10 = 0;

    /* "rasterio/_io.pyx":958
 *         for key, value in kwargs.items():
 *             key_b = text_type(key).encode('utf-8')
 *             value_b = text_type(value).encode('utf-8')             # <<<<<<<<<<<<<<
 *             key_c = key_b
 *             value_c = value_b
 */
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_text_type); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_v_value);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_value);
    __Pyx_GIVEREF(__pyx_v_value);
    __pyx_t_6 = PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_encode); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_Call(__pyx_t_11, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF_SET(__pyx_v_value_b, __pyx_t_6);
    __pyx_t_6 = 0;

    /* "rasterio/_io.pyx":959
 *             key_b = text_type(key).encode('utf-8')
 *             value_b = text_type(value).encode('utf-8')
 *             key_c = key_b             # <<<<<<<<<<<<<<
 *             value_c = value_b
 *             i = _gdal.CSLFindName(papszStrList, key_c)
 */
    __pyx_t_14 = __Pyx_PyObject_AsString(__pyx_v_key_b); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_key_c = __pyx_t_14;

    /* "rasterio/_io.pyx":960
 *             value_b = text_type(value).encode('utf-8')
 *             key_c = key_b
 *             value_c = value_b             # <<<<<<<<<<<<<<
 *             i = _gdal.CSLFindName(papszStrList, key_c)
 *             if i < 0:
 */
    __pyx_t_14 = __Pyx_PyObject_AsString(__pyx_v_value_b); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_value_c = __pyx_t_14;

    /* "rasterio/_io.pyx":961
 *             key_c = key_b
 *             value_c = value_b
 *             i = _gdal.CSLFindName(papszStrList, key_c)             # <<<<<<<<<<<<<<
 *             if i < 0:
 *                 papszStrList = _gdal.CSLAddNameValue(papszStrList, key_c, value_c)
 */
    __pyx_v_i = CSLFindName(__pyx_v_papszStrList, __pyx_v_key_c);

    /* "rasterio/_io.pyx":962
 *             value_c = value_b
 *             i = _gdal.CSLFindName(papszStrList, key_c)
 *             if i < 0:             # <<<<<<<<<<<<<<
 *                 papszStrList = _gdal.CSLAddNameValue(papszStrList, key_c, value_c)
 *             else:
 */
    __pyx_t_3 = ((__pyx_v_i < 0) != 0);
    if (__pyx_t_3) {

      /* "rasterio/_io.pyx":963
 *             i = _gdal.CSLFindName(papszStrList, key_c)
 *             if i < 0:
 *                 papszStrList = _gdal.CSLAddNameValue(papszStrList, key_c, value_c)             # <<<<<<<<<<<<<<
 *             else:
 *                 papszStrList = _gdal.CSLSetNameValue(papszStrList, key_c, value_c)
 */
      __pyx_v_papszStrList = CSLAddNameValue(__pyx_v_papszStrList, __pyx_v_key_c, __pyx_v_value_c);
      goto __pyx_L12;
    }
    /*else*/ {

      /* "rasterio/_io.pyx":965
 *                 papszStrList = _gdal.CSLAddNameValue(papszStrList, key_c, value_c)
 *             else:
 *                 papszStrList = _gdal.CSLSetNameValue(papszStrList, key_c, value_c)             # <<<<<<<<<<<<<<
 *         retval = _gdal.GDALSetMetadata(hobj, papszStrList, domain_c)
 * 
 */
      __pyx_v_papszStrList = CSLSetNameValue(__pyx_v_papszStrList, __pyx_v_key_c, __pyx_v_value_c);
    }
    __pyx_L12:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":966
 *             else:
 *                 papszStrList = _gdal.CSLSetNameValue(papszStrList, key_c, value_c)
 *         retval = _gdal.GDALSetMetadata(hobj, papszStrList, domain_c)             # <<<<<<<<<<<<<<
 * 
 *     def write_colormap(self, bidx, colormap):
 */
  __pyx_v_retval = GDALSetMetadata(__pyx_v_hobj, __pyx_v_papszStrList, __pyx_v_domain_c);

  /* "rasterio/_io.pyx":925
 *         # TODO: handle errors (by retval).
 * 
 *     def update_tags(self, bidx=0, ns=None, **kwargs):             # <<<<<<<<<<<<<<
 *         """Updates the tags of a dataset or one of its bands.
 * 
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.update_tags", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_domain_b);
  __Pyx_XDECREF(__pyx_v_key);
  __Pyx_XDECREF(__pyx_v_value);
  __Pyx_XDECREF(__pyx_v_key_b);
  __Pyx_XDECREF(__pyx_v_value_b);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":968
 *         retval = _gdal.GDALSetMetadata(hobj, papszStrList, domain_c)
 * 
 *     def write_colormap(self, bidx, colormap):             # <<<<<<<<<<<<<<
 *         """Write a colormap for a band to the dataset."""
 *         cdef void *hBand
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_19write_colormap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8rasterio_3_io_13RasterUpdater_18write_colormap[] = "Write a colormap for a band to the dataset.";
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_19write_colormap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_bidx = 0;
  PyObject *__pyx_v_colormap = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_colormap (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bidx,&__pyx_n_s_colormap,0};
    PyObject* values[2] = {0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_bidx)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_colormap)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("write_colormap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_colormap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
    }
    __pyx_v_bidx = values[0];
    __pyx_v_colormap = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_colormap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.write_colormap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater_18write_colormap(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self), __pyx_v_bidx, __pyx_v_colormap);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_18write_colormap(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_bidx, PyObject *__pyx_v_colormap) {
  void *__pyx_v_hBand;
  void *__pyx_v_hTable;
  GDALColorEntry __pyx_v_color;
  PyObject *__pyx_v_vals = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_rgba = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *(*__pyx_t_11)(PyObject *);
  PyObject *__pyx_t_12 = NULL;
  short __pyx_t_13;
  short __pyx_t_14;
  short __pyx_t_15;
  short __pyx_t_16;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_colormap", 0);
  __Pyx_TraceCall("write_colormap", __pyx_f[0], 968);

  /* "rasterio/_io.pyx":973
 *         cdef void *hTable
 *         cdef _gdal.GDALColorEntry color
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("can't read closed raster file")
 *         if bidx > 0:
 */
  __pyx_t_1 = ((__pyx_v_self->__pyx_base._hds == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":974
 *         cdef _gdal.GDALColorEntry color
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__65, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":975
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")
 *         if bidx > 0:             # <<<<<<<<<<<<<<
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")
 */
  __pyx_t_2 = PyObject_RichCompare(__pyx_v_bidx, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":976
 *             raise ValueError("can't read closed raster file")
 *         if bidx > 0:
 *             if bidx not in self.indexes:             # <<<<<<<<<<<<<<
 *                 raise ValueError("Invalid band index")
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)
 */
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_indexes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = (__Pyx_PySequence_Contains(__pyx_v_bidx, __pyx_t_2, Py_NE)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = (__pyx_t_1 != 0);
    if (__pyx_t_3) {

      /* "rasterio/_io.pyx":977
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")             # <<<<<<<<<<<<<<
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hBand == NULL:
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__66, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "rasterio/_io.pyx":978
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)             # <<<<<<<<<<<<<<
 *             if hBand == NULL:
 *                 raise ValueError("NULL band")
 */
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_bidx); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_hBand = GDALGetRasterBand(__pyx_v_self->__pyx_base._hds, __pyx_t_4);

    /* "rasterio/_io.pyx":979
 *                 raise ValueError("Invalid band index")
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hBand == NULL:             # <<<<<<<<<<<<<<
 *                 raise ValueError("NULL band")
 *         # RGB only for now. TODO: the other types.
 */
    __pyx_t_3 = ((__pyx_v_hBand == NULL) != 0);
    if (__pyx_t_3) {

      /* "rasterio/_io.pyx":980
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hBand == NULL:
 *                 raise ValueError("NULL band")             # <<<<<<<<<<<<<<
 *         # RGB only for now. TODO: the other types.
 *         # GPI_Gray=0,  GPI_RGB=1, GPI_CMYK=2,     GPI_HLS=3
 */
      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_Raise(__pyx_t_2, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "rasterio/_io.pyx":983
 *         # RGB only for now. TODO: the other types.
 *         # GPI_Gray=0,  GPI_RGB=1, GPI_CMYK=2,     GPI_HLS=3
 *         hTable = _gdal.GDALCreateColorTable(1)             # <<<<<<<<<<<<<<
 *         vals = range(256)
 *         for i, rgba in colormap.items():
 */
  __pyx_v_hTable = GDALCreateColorTable(1);

  /* "rasterio/_io.pyx":984
 *         # GPI_Gray=0,  GPI_RGB=1, GPI_CMYK=2,     GPI_HLS=3
 *         hTable = _gdal.GDALCreateColorTable(1)
 *         vals = range(256)             # <<<<<<<<<<<<<<
 *         for i, rgba in colormap.items():
 *             if i not in vals:
 */
  __pyx_t_2 = PyObject_Call(__pyx_builtin_range, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_v_vals = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":985
 *         hTable = _gdal.GDALCreateColorTable(1)
 *         vals = range(256)
 *         for i, rgba in colormap.items():             # <<<<<<<<<<<<<<
 *             if i not in vals:
 *                 log.warn("Invalid colormap key %d", i)
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_colormap, __pyx_n_s_items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
    __pyx_t_2 = __pyx_t_5; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  for (;;) {
    if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_2)) {
      if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_2)) {
      if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_5); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #else
      __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      #endif
    } else {
      __pyx_t_5 = __pyx_t_7(__pyx_t_2);
      if (unlikely(!__pyx_t_5)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        break;
      }
      __Pyx_GOTREF(__pyx_t_5);
    }
    if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
      PyObject* sequence = __pyx_t_5;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_9);
      #else
      __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_10 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
      index = 0; __pyx_t_8 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_8)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_8);
      index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_9);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L10_unpacking_done;
      __pyx_L9_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L10_unpacking_done:;
    }
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_8);
    __pyx_t_8 = 0;
    __Pyx_XDECREF_SET(__pyx_v_rgba, __pyx_t_9);
    __pyx_t_9 = 0;

    /* "rasterio/_io.pyx":986
 *         vals = range(256)
 *         for i, rgba in colormap.items():
 *             if i not in vals:             # <<<<<<<<<<<<<<
 *                 log.warn("Invalid colormap key %d", i)
 *                 continue
 */
    __pyx_t_3 = (__Pyx_PySequence_Contains(__pyx_v_i, __pyx_v_vals, Py_NE)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_1 = (__pyx_t_3 != 0);
    if (__pyx_t_1) {

      /* "rasterio/_io.pyx":987
 *         for i, rgba in colormap.items():
 *             if i not in vals:
 *                 log.warn("Invalid colormap key %d", i)             # <<<<<<<<<<<<<<
 *                 continue
 *             color.c1, color.c2, color.c3, color.c4 = rgba
 */
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_warn); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_kp_s_Invalid_colormap_key_d);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_s_Invalid_colormap_key_d);
      __Pyx_GIVEREF(__pyx_kp_s_Invalid_colormap_key_d);
      __Pyx_INCREF(__pyx_v_i);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_i);
      __Pyx_GIVEREF(__pyx_v_i);
      __pyx_t_8 = PyObject_Call(__pyx_t_9, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "rasterio/_io.pyx":988
 *             if i not in vals:
 *                 log.warn("Invalid colormap key %d", i)
 *                 continue             # <<<<<<<<<<<<<<
 *             color.c1, color.c2, color.c3, color.c4 = rgba
 *             _gdal.GDALSetColorEntry(hTable, i, &color)
 */
      goto __pyx_L7_continue;
    }

    /* "rasterio/_io.pyx":989
 *                 log.warn("Invalid colormap key %d", i)
 *                 continue
 *             color.c1, color.c2, color.c3, color.c4 = rgba             # <<<<<<<<<<<<<<
 *             _gdal.GDALSetColorEntry(hTable, i, &color)
 *         # TODO: other color interpretations?
 */
    if ((likely(PyTuple_CheckExact(__pyx_v_rgba))) || (PyList_CheckExact(__pyx_v_rgba))) {
      PyObject* sequence = __pyx_v_rgba;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 4)) {
        if (size > 4) __Pyx_RaiseTooManyValuesError(4);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_10 = PyTuple_GET_ITEM(sequence, 3); 
      } else {
        __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_10 = PyList_GET_ITEM(sequence, 3); 
      }
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_10);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_5,&__pyx_t_9,&__pyx_t_10};
        for (i=0; i < 4; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_5,&__pyx_t_9,&__pyx_t_10};
      __pyx_t_12 = PyObject_GetIter(__pyx_v_rgba); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_11 = Py_TYPE(__pyx_t_12)->tp_iternext;
      for (index=0; index < 4; index++) {
        PyObject* item = __pyx_t_11(__pyx_t_12); if (unlikely(!item)) goto __pyx_L12_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_12), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      goto __pyx_L13_unpacking_done;
      __pyx_L12_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L13_unpacking_done:;
    }
    __pyx_t_13 = __Pyx_PyInt_As_short(__pyx_t_8); if (unlikely((__pyx_t_13 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_14 = __Pyx_PyInt_As_short(__pyx_t_5); if (unlikely((__pyx_t_14 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_15 = __Pyx_PyInt_As_short(__pyx_t_9); if (unlikely((__pyx_t_15 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_16 = __Pyx_PyInt_As_short(__pyx_t_10); if (unlikely((__pyx_t_16 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_v_color.c1 = __pyx_t_13;
    __pyx_v_color.c2 = __pyx_t_14;
    __pyx_v_color.c3 = __pyx_t_15;
    __pyx_v_color.c4 = __pyx_t_16;

    /* "rasterio/_io.pyx":990
 *                 continue
 *             color.c1, color.c2, color.c3, color.c4 = rgba
 *             _gdal.GDALSetColorEntry(hTable, i, &color)             # <<<<<<<<<<<<<<
 *         # TODO: other color interpretations?
 *         _gdal.GDALSetRasterColorInterpretation(hBand, 2)
 */
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_i); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    GDALSetColorEntry(__pyx_v_hTable, __pyx_t_4, (&__pyx_v_color));
    __pyx_L7_continue:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":992
 *             _gdal.GDALSetColorEntry(hTable, i, &color)
 *         # TODO: other color interpretations?
 *         _gdal.GDALSetRasterColorInterpretation(hBand, 2)             # <<<<<<<<<<<<<<
 *         _gdal.GDALSetRasterColorTable(hBand, hTable)
 *         _gdal.GDALDestroyColorTable(hTable)
 */
  GDALSetRasterColorInterpretation(__pyx_v_hBand, 2);

  /* "rasterio/_io.pyx":993
 *         # TODO: other color interpretations?
 *         _gdal.GDALSetRasterColorInterpretation(hBand, 2)
 *         _gdal.GDALSetRasterColorTable(hBand, hTable)             # <<<<<<<<<<<<<<
 *         _gdal.GDALDestroyColorTable(hTable)
 * 
 */
  GDALSetRasterColorTable(__pyx_v_hBand, __pyx_v_hTable);

  /* "rasterio/_io.pyx":994
 *         _gdal.GDALSetRasterColorInterpretation(hBand, 2)
 *         _gdal.GDALSetRasterColorTable(hBand, hTable)
 *         _gdal.GDALDestroyColorTable(hTable)             # <<<<<<<<<<<<<<
 * 
 *     def write_mask(self, src, window=None):
 */
  GDALDestroyColorTable(__pyx_v_hTable);

  /* "rasterio/_io.pyx":968
 *         retval = _gdal.GDALSetMetadata(hobj, papszStrList, domain_c)
 * 
 *     def write_colormap(self, bidx, colormap):             # <<<<<<<<<<<<<<
 *         """Write a colormap for a band to the dataset."""
 *         cdef void *hBand
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.write_colormap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_vals);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_rgba);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pyx":996
 *         _gdal.GDALDestroyColorTable(hTable)
 * 
 *     def write_mask(self, src, window=None):             # <<<<<<<<<<<<<<
 *         """Write the valid data mask src array into the dataset's band
 *         mask.
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_21write_mask(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_8rasterio_3_io_13RasterUpdater_20write_mask[] = "Write the valid data mask src array into the dataset's band\n        mask.\n\n        The optional `window` argument takes a tuple like:\n        \n            ((row_start, row_stop), (col_start, col_stop))\n            \n        specifying a raster subset to write into.\n        ";
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_21write_mask(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_src = 0;
  PyObject *__pyx_v_window = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("write_mask (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_src,&__pyx_n_s_window,0};
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_src)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_window);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_mask") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_src = values[0];
    __pyx_v_window = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("write_mask", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.write_mask", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater_20write_mask(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self), __pyx_v_src, __pyx_v_window);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_20write_mask(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self, PyObject *__pyx_v_src, PyObject *__pyx_v_window) {
  void *__pyx_v_hband;
  void *__pyx_v_hmask;
  PyObject *__pyx_v_yoff = NULL;
  PyObject *__pyx_v_xoff = NULL;
  PyObject *__pyx_v_height = NULL;
  PyObject *__pyx_v_width = NULL;
  PyObject *__pyx_v_array = NULL;
  CYTHON_UNUSED int __pyx_v_retval;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("write_mask", 0);
  __Pyx_TraceCall("write_mask", __pyx_f[0], 996);
  __Pyx_INCREF(__pyx_v_window);

  /* "rasterio/_io.pyx":1008
 *         cdef void *hband
 *         cdef void *hmask
 *         if self._hds == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("can't write closed raster file")
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)
 */
  __pyx_t_1 = ((__pyx_v_self->__pyx_base._hds == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":1009
 *         cdef void *hmask
 *         if self._hds == NULL:
 *             raise ValueError("can't write closed raster file")             # <<<<<<<<<<<<<<
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)
 *         if hband == NULL:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":1010
 *         if self._hds == NULL:
 *             raise ValueError("can't write closed raster file")
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)             # <<<<<<<<<<<<<<
 *         if hband == NULL:
 *             raise ValueError("NULL band mask")
 */
  __pyx_v_hband = GDALGetRasterBand(__pyx_v_self->__pyx_base._hds, 1);

  /* "rasterio/_io.pyx":1011
 *             raise ValueError("can't write closed raster file")
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)
 *         if hband == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("NULL band mask")
 *         if _gdal.GDALCreateMaskBand(hband, 0x02) != 0:
 */
  __pyx_t_1 = ((__pyx_v_hband == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":1012
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)
 *         if hband == NULL:
 *             raise ValueError("NULL band mask")             # <<<<<<<<<<<<<<
 *         if _gdal.GDALCreateMaskBand(hband, 0x02) != 0:
 *             raise RuntimeError("Failed to create mask")
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":1013
 *         if hband == NULL:
 *             raise ValueError("NULL band mask")
 *         if _gdal.GDALCreateMaskBand(hband, 0x02) != 0:             # <<<<<<<<<<<<<<
 *             raise RuntimeError("Failed to create mask")
 *         hmask = _gdal.GDALGetMaskBand(hband)
 */
  __pyx_t_1 = ((GDALCreateMaskBand(__pyx_v_hband, 0x02) != 0) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":1014
 *             raise ValueError("NULL band mask")
 *         if _gdal.GDALCreateMaskBand(hband, 0x02) != 0:
 *             raise RuntimeError("Failed to create mask")             # <<<<<<<<<<<<<<
 *         hmask = _gdal.GDALGetMaskBand(hband)
 *         if hmask == NULL:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__71, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":1015
 *         if _gdal.GDALCreateMaskBand(hband, 0x02) != 0:
 *             raise RuntimeError("Failed to create mask")
 *         hmask = _gdal.GDALGetMaskBand(hband)             # <<<<<<<<<<<<<<
 *         if hmask == NULL:
 *             raise ValueError("NULL band mask")
 */
  __pyx_v_hmask = GDALGetMaskBand(__pyx_v_hband);

  /* "rasterio/_io.pyx":1016
 *             raise RuntimeError("Failed to create mask")
 *         hmask = _gdal.GDALGetMaskBand(hband)
 *         if hmask == NULL:             # <<<<<<<<<<<<<<
 *             raise ValueError("NULL band mask")
 *         log.debug("Created mask band")
 */
  __pyx_t_1 = ((__pyx_v_hmask == NULL) != 0);
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":1017
 *         hmask = _gdal.GDALGetMaskBand(hband)
 *         if hmask == NULL:
 *             raise ValueError("NULL band mask")             # <<<<<<<<<<<<<<
 *         log.debug("Created mask band")
 *         if window:
 */
    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "rasterio/_io.pyx":1018
 *         if hmask == NULL:
 *             raise ValueError("NULL band mask")
 *         log.debug("Created mask band")             # <<<<<<<<<<<<<<
 *         if window:
 *             window = eval_window(window, self.height, self.width)
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_tuple__73, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":1019
 *             raise ValueError("NULL band mask")
 *         log.debug("Created mask band")
 *         if window:             # <<<<<<<<<<<<<<
 *             window = eval_window(window, self.height, self.width)
 *             yoff = window[0][0]
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_window); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":1020
 *         log.debug("Created mask band")
 *         if window:
 *             window = eval_window(window, self.height, self.width)             # <<<<<<<<<<<<<<
 *             yoff = window[0][0]
 *             xoff = window[1][0]
 */
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_self->__pyx_base.height); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_self->__pyx_base.width); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __pyx_f_8rasterio_3_io_eval_window(__pyx_v_window, __pyx_t_4, __pyx_t_5, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF_SET(__pyx_v_window, __pyx_t_2);
    __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":1021
 *         if window:
 *             window = eval_window(window, self.height, self.width)
 *             yoff = window[0][0]             # <<<<<<<<<<<<<<
 *             xoff = window[1][0]
 *             height = window[0][1] - yoff
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_window, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_yoff = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "rasterio/_io.pyx":1022
 *             window = eval_window(window, self.height, self.width)
 *             yoff = window[0][0]
 *             xoff = window[1][0]             # <<<<<<<<<<<<<<
 *             height = window[0][1] - yoff
 *             width = window[1][1] - xoff
 */
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_window, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_xoff = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":1023
 *             yoff = window[0][0]
 *             xoff = window[1][0]
 *             height = window[0][1] - yoff             # <<<<<<<<<<<<<<
 *             width = window[1][1] - xoff
 *         else:
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_window, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1023; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1023; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_3, __pyx_v_yoff); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_height = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":1024
 *             xoff = window[1][0]
 *             height = window[0][1] - yoff
 *             width = window[1][1] - xoff             # <<<<<<<<<<<<<<
 *         else:
 *             xoff = yoff = 0
 */
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_window, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Subtract(__pyx_t_3, __pyx_v_xoff); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_width = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":1026
 *             width = window[1][1] - xoff
 *         else:
 *             xoff = yoff = 0             # <<<<<<<<<<<<<<
 *             width = self.width
 *             height = self.height
 */
    __pyx_t_2 = __Pyx_PyInt_From_long(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_xoff = __pyx_t_2;
    __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyInt_From_long(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_v_yoff = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":1027
 *         else:
 *             xoff = yoff = 0
 *             width = self.width             # <<<<<<<<<<<<<<
 *             height = self.height
 *         if src.dtype == np.bool:
 */
    __pyx_t_2 = __pyx_v_self->__pyx_base.width;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v_width = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "rasterio/_io.pyx":1028
 *             xoff = yoff = 0
 *             width = self.width
 *             height = self.height             # <<<<<<<<<<<<<<
 *         if src.dtype == np.bool:
 *             array = 255 * src.astype(np.uint8)
 */
    __pyx_t_2 = __pyx_v_self->__pyx_base.height;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v_height = __pyx_t_2;
    __pyx_t_2 = 0;
  }
  __pyx_L7:;

  /* "rasterio/_io.pyx":1029
 *             width = self.width
 *             height = self.height
 *         if src.dtype == np.bool:             # <<<<<<<<<<<<<<
 *             array = 255 * src.astype(np.uint8)
 *             retval = io_ubyte(
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_bool); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_1) {

    /* "rasterio/_io.pyx":1030
 *             height = self.height
 *         if src.dtype == np.bool:
 *             array = 255 * src.astype(np.uint8)             # <<<<<<<<<<<<<<
 *             retval = io_ubyte(
 *                 hmask, 1, xoff, yoff, width, height, array)
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_uint8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Multiply(__pyx_int_255, __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_v_array = __pyx_t_6;
    __pyx_t_6 = 0;

    /* "rasterio/_io.pyx":1032
 *             array = 255 * src.astype(np.uint8)
 *             retval = io_ubyte(
 *                 hmask, 1, xoff, yoff, width, height, array)             # <<<<<<<<<<<<<<
 *         else:
 *             retval = io_ubyte(
 */
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_array) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_array, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":1031
 *         if src.dtype == np.bool:
 *             array = 255 * src.astype(np.uint8)
 *             retval = io_ubyte(             # <<<<<<<<<<<<<<
 *                 hmask, 1, xoff, yoff, width, height, array)
 *         else:
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_ubyte(__pyx_v_hmask, 1, __pyx_t_5, __pyx_t_4, __pyx_t_7, __pyx_t_8, ((PyArrayObject *)__pyx_v_array));
    goto __pyx_L8;
  }
  /*else*/ {

    /* "rasterio/_io.pyx":1035
 *         else:
 *             retval = io_ubyte(
 *                 hmask, 1, xoff, yoff, width, height, src)             # <<<<<<<<<<<<<<
 * 
 */
    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_xoff); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_v_yoff); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_v_width); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_v_height); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

    /* "rasterio/_io.pyx":1034
 *                 hmask, 1, xoff, yoff, width, height, array)
 *         else:
 *             retval = io_ubyte(             # <<<<<<<<<<<<<<
 *                 hmask, 1, xoff, yoff, width, height, src)
 * 
 */
    __pyx_v_retval = __pyx_f_8rasterio_3_io_io_ubyte(__pyx_v_hmask, 1, __pyx_t_8, __pyx_t_7, __pyx_t_4, __pyx_t_5, ((PyArrayObject *)__pyx_v_src));
  }
  __pyx_L8:;

  /* "rasterio/_io.pyx":996
 *         _gdal.GDALDestroyColorTable(hTable)
 * 
 *     def write_mask(self, src, window=None):             # <<<<<<<<<<<<<<
 *         """Write the valid data mask src array into the dataset's band
 *         mask.
 */

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("rasterio._io.RasterUpdater.write_mask", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_yoff);
  __Pyx_XDECREF(__pyx_v_xoff);
  __Pyx_XDECREF(__pyx_v_height);
  __Pyx_XDECREF(__pyx_v_width);
  __Pyx_XDECREF(__pyx_v_array);
  __Pyx_XDECREF(__pyx_v_window);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":53
 * cdef class RasterUpdater(RasterReader):
 *     # Read-write access to raster data and metadata.
 *     cdef readonly object _init_dtype             # <<<<<<<<<<<<<<
 *     cdef readonly object _init_nodata
 *     cdef readonly object _options
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_11_init_dtype_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_11_init_dtype_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater_11_init_dtype___get__(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_11_init_dtype___get__(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 53);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_init_dtype);
  __pyx_r = __pyx_v_self->_init_dtype;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":54
 *     # Read-write access to raster data and metadata.
 *     cdef readonly object _init_dtype
 *     cdef readonly object _init_nodata             # <<<<<<<<<<<<<<
 *     cdef readonly object _options
 * 
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_12_init_nodata_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_12_init_nodata_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater_12_init_nodata___get__(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_12_init_nodata___get__(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 54);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_init_nodata);
  __pyx_r = __pyx_v_self->_init_nodata;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "rasterio/_io.pxd":55
 *     cdef readonly object _init_dtype
 *     cdef readonly object _init_nodata
 *     cdef readonly object _options             # <<<<<<<<<<<<<<
 * 
 * ctypedef np.uint8_t DTYPE_UBYTE_t
 */

/* Python wrapper */
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_8_options_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_8rasterio_3_io_13RasterUpdater_8_options_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_8rasterio_3_io_13RasterUpdater_8_options___get__(((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)__pyx_v_self));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_8rasterio_3_io_13RasterUpdater_8_options___get__(struct __pyx_obj_8rasterio_3_io_RasterUpdater *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);
  __Pyx_TraceCall("__get__", __pyx_f[1], 55);
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_self->_options);
  __pyx_r = __pyx_v_self->_options;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":194
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 *         # -- the details of this may change.
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

/* Python wrapper */
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
  __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
  int __pyx_v_copy_shape;
  int __pyx_v_i;
  int __pyx_v_ndim;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  int __pyx_v_t;
  char *__pyx_v_f;
  PyArray_Descr *__pyx_v_descr = 0;
  int __pyx_v_offset;
  int __pyx_v_hasfields;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  char *__pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__getbuffer__", 0);
  if (__pyx_v_info != NULL) {
    __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(__pyx_v_info->obj);
  }
  __Pyx_TraceCall("__getbuffer__", __pyx_f[2], 194);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":200
 *             # of flags
 * 
 *             if info == NULL: return             # <<<<<<<<<<<<<<
 * 
 *             cdef int copy_shape, i, ndim
 */
  __pyx_t_1 = ((__pyx_v_info == NULL) != 0);
  if (__pyx_t_1) {
    __pyx_r = 0;
    goto __pyx_L0;
  }

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":203
 * 
 *             cdef int copy_shape, i, ndim
 *             cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 */
  __pyx_v_endian_detector = 1;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":204
 *             cdef int copy_shape, i, ndim
 *             cdef int endian_detector = 1
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 * 
 *             ndim = PyArray_NDIM(self)
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":206
 *             cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 * 
 *             ndim = PyArray_NDIM(self)             # <<<<<<<<<<<<<<
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_v_ndim = PyArray_NDIM(__pyx_v_self);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":208
 *             ndim = PyArray_NDIM(self)
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 copy_shape = 1
 *             else:
 */
  __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  if (__pyx_t_1) {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":209
 * 
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 copy_shape = 1             # <<<<<<<<<<<<<<
 *             else:
 *                 copy_shape = 0
 */
    __pyx_v_copy_shape = 1;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":211
 *                 copy_shape = 1
 *             else:
 *                 copy_shape = 0             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 */
    __pyx_v_copy_shape = 0;
  }
  __pyx_L4:;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":213
 *                 copy_shape = 0
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")
 */
  __pyx_t_1 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0);
  if (__pyx_t_1) {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":214
 * 
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 */
    __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":215
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__74, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":217
 *                 raise ValueError(u"ndarray is not C contiguous")
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)             # <<<<<<<<<<<<<<
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 */
  __pyx_t_3 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0);
  if (__pyx_t_3) {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":218
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):             # <<<<<<<<<<<<<<
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 */
    __pyx_t_1 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0);
    __pyx_t_2 = __pyx_t_1;
  } else {
    __pyx_t_2 = __pyx_t_3;
  }
  if (__pyx_t_2) {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":219
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__75, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":221
 *                 raise ValueError(u"ndarray is not Fortran contiguous")
 * 
 *             info.buf = PyArray_DATA(self)             # <<<<<<<<<<<<<<
 *             info.ndim = ndim
 *             if copy_shape:
 */
  __pyx_v_info->buf = PyArray_DATA(__pyx_v_self);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":222
 * 
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim             # <<<<<<<<<<<<<<
 *             if copy_shape:
 *                 # Allocate new buffer for strides and shape info.
 */
  __pyx_v_info->ndim = __pyx_v_ndim;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":223
 *             info.buf = PyArray_DATA(self)
 *             info.ndim = ndim
 *             if copy_shape:             # <<<<<<<<<<<<<<
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 */
  __pyx_t_2 = (__pyx_v_copy_shape != 0);
  if (__pyx_t_2) {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":226
 *                 # Allocate new buffer for strides and shape info.
 *                 # This is allocated as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)             # <<<<<<<<<<<<<<
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 */
    __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2)));

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":227
 *                 # This is allocated as one block, strides first.
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
 *                 info.shape = info.strides + ndim             # <<<<<<<<<<<<<<
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 */
    __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim);

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":228
 *                 info.strides = <Py_ssize_t*>stdlib.malloc(sizeof(Py_ssize_t) * <size_t>ndim * 2)
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):             # <<<<<<<<<<<<<<
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 */
    __pyx_t_5 = __pyx_v_ndim;
    for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
      __pyx_v_i = __pyx_t_6;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":229
 *                 info.shape = info.strides + ndim
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]             # <<<<<<<<<<<<<<
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 */
      (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]);

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":230
 *                 for i in range(ndim):
 *                     info.strides[i] = PyArray_STRIDES(self)[i]
 *                     info.shape[i] = PyArray_DIMS(self)[i]             # <<<<<<<<<<<<<<
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 */
      (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]);
    }
    goto __pyx_L7;
  }
  /*else*/ {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":232
 *                     info.shape[i] = PyArray_DIMS(self)[i]
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)             # <<<<<<<<<<<<<<
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 */
    __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self));

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":233
 *             else:
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)             # <<<<<<<<<<<<<<
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 */
    __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self));
  }
  __pyx_L7:;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":234
 *                 info.strides = <Py_ssize_t*>PyArray_STRIDES(self)
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL             # <<<<<<<<<<<<<<
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 */
  __pyx_v_info->suboffsets = NULL;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":235
 *                 info.shape = <Py_ssize_t*>PyArray_DIMS(self)
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)             # <<<<<<<<<<<<<<
 *             info.readonly = not PyArray_ISWRITEABLE(self)
 * 
 */
  __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":236
 *             info.suboffsets = NULL
 *             info.itemsize = PyArray_ITEMSIZE(self)
 *             info.readonly = not PyArray_ISWRITEABLE(self)             # <<<<<<<<<<<<<<
 * 
 *             cdef int t
 */
  __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0));

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":239
 * 
 *             cdef int t
 *             cdef char* f = NULL             # <<<<<<<<<<<<<<
 *             cdef dtype descr = self.descr
 *             cdef list stack
 */
  __pyx_v_f = NULL;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":240
 *             cdef int t
 *             cdef char* f = NULL
 *             cdef dtype descr = self.descr             # <<<<<<<<<<<<<<
 *             cdef list stack
 *             cdef int offset
 */
  __pyx_t_4 = ((PyObject *)__pyx_v_self->descr);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_v_descr = ((PyArray_Descr *)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":244
 *             cdef int offset
 * 
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields and not copy_shape:
 */
  __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":246
 *             cdef bint hasfields = PyDataType_HASFIELDS(descr)
 * 
 *             if not hasfields and not copy_shape:             # <<<<<<<<<<<<<<
 *                 # do not call releasebuffer
 *                 info.obj = None
 */
  __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0);
  if (__pyx_t_2) {
    __pyx_t_3 = ((!(__pyx_v_copy_shape != 0)) != 0);
    __pyx_t_1 = __pyx_t_3;
  } else {
    __pyx_t_1 = __pyx_t_2;
  }
  if (__pyx_t_1) {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":248
 *             if not hasfields and not copy_shape:
 *                 # do not call releasebuffer
 *                 info.obj = None             # <<<<<<<<<<<<<<
 *             else:
 *                 # need to call releasebuffer
 */
    __Pyx_INCREF(Py_None);
    __Pyx_GIVEREF(Py_None);
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = Py_None;
    goto __pyx_L10;
  }
  /*else*/ {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":251
 *             else:
 *                 # need to call releasebuffer
 *                 info.obj = self             # <<<<<<<<<<<<<<
 * 
 *             if not hasfields:
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj);
    __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
  }
  __pyx_L10:;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":253
 *                 info.obj = self
 * 
 *             if not hasfields:             # <<<<<<<<<<<<<<
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 */
  __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0);
  if (__pyx_t_1) {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":254
 * 
 *             if not hasfields:
 *                 t = descr.type_num             # <<<<<<<<<<<<<<
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 */
    __pyx_t_5 = __pyx_v_descr->type_num;
    __pyx_v_t = __pyx_t_5;

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":255
 *             if not hasfields:
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_1 = ((__pyx_v_descr->byteorder == '>') != 0);
    if (__pyx_t_1) {
      __pyx_t_2 = (__pyx_v_little_endian != 0);
    } else {
      __pyx_t_2 = __pyx_t_1;
    }
    if (!__pyx_t_2) {

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":256
 *                 t = descr.type_num
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):             # <<<<<<<<<<<<<<
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 */
      __pyx_t_1 = ((__pyx_v_descr->byteorder == '<') != 0);
      if (__pyx_t_1) {
        __pyx_t_3 = ((!(__pyx_v_little_endian != 0)) != 0);
        __pyx_t_7 = __pyx_t_3;
      } else {
        __pyx_t_7 = __pyx_t_1;
      }
      __pyx_t_1 = __pyx_t_7;
    } else {
      __pyx_t_1 = __pyx_t_2;
    }
    if (__pyx_t_1) {

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":257
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
      __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":274
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
    switch (__pyx_v_t) {

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":258
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 */
      case NPY_BYTE:
      __pyx_v_f = __pyx_k_b;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":259
 *                     raise ValueError(u"Non-native byte order not supported")
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 */
      case NPY_UBYTE:
      __pyx_v_f = __pyx_k_B;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":260
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 */
      case NPY_SHORT:
      __pyx_v_f = __pyx_k_h;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":261
 *                 elif t == NPY_UBYTE:       f = "B"
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 */
      case NPY_USHORT:
      __pyx_v_f = __pyx_k_H;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":262
 *                 elif t == NPY_SHORT:       f = "h"
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 */
      case NPY_INT:
      __pyx_v_f = __pyx_k_i;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":263
 *                 elif t == NPY_USHORT:      f = "H"
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 */
      case NPY_UINT:
      __pyx_v_f = __pyx_k_I;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":264
 *                 elif t == NPY_INT:         f = "i"
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 */
      case NPY_LONG:
      __pyx_v_f = __pyx_k_l;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":265
 *                 elif t == NPY_UINT:        f = "I"
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 */
      case NPY_ULONG:
      __pyx_v_f = __pyx_k_L;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":266
 *                 elif t == NPY_LONG:        f = "l"
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 */
      case NPY_LONGLONG:
      __pyx_v_f = __pyx_k_q;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":267
 *                 elif t == NPY_ULONG:       f = "L"
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 */
      case NPY_ULONGLONG:
      __pyx_v_f = __pyx_k_Q;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":268
 *                 elif t == NPY_LONGLONG:    f = "q"
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 */
      case NPY_FLOAT:
      __pyx_v_f = __pyx_k_f;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":269
 *                 elif t == NPY_ULONGLONG:   f = "Q"
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 */
      case NPY_DOUBLE:
      __pyx_v_f = __pyx_k_d;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":270
 *                 elif t == NPY_FLOAT:       f = "f"
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 */
      case NPY_LONGDOUBLE:
      __pyx_v_f = __pyx_k_g;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":271
 *                 elif t == NPY_DOUBLE:      f = "d"
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 */
      case NPY_CFLOAT:
      __pyx_v_f = __pyx_k_Zf;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":272
 *                 elif t == NPY_LONGDOUBLE:  f = "g"
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"
 */
      case NPY_CDOUBLE:
      __pyx_v_f = __pyx_k_Zd;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":273
 *                 elif t == NPY_CFLOAT:      f = "Zf"
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"             # <<<<<<<<<<<<<<
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 */
      case NPY_CLONGDOUBLE:
      __pyx_v_f = __pyx_k_Zg;
      break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":274
 *                 elif t == NPY_CDOUBLE:     f = "Zd"
 *                 elif t == NPY_CLONGDOUBLE: f = "Zg"
 *                 elif t == NPY_OBJECT:      f = "O"             # <<<<<<<<<<<<<<
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
      case NPY_OBJECT:
      __pyx_v_f = __pyx_k_O;
      break;
      default:

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":276
 *                 elif t == NPY_OBJECT:      f = "O"
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *                 info.format = f
 *                 return
 */
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      break;
    }

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":277
 *                 else:
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f             # <<<<<<<<<<<<<<
 *                 return
 *             else:
 */
    __pyx_v_info->format = __pyx_v_f;

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":278
 *                     raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *                 info.format = f
 *                 return             # <<<<<<<<<<<<<<
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 */
    __pyx_r = 0;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":280
 *                 return
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)             # <<<<<<<<<<<<<<
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0
 */
    __pyx_v_info->format = ((char *)malloc(255));

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":281
 *             else:
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 *                 info.format[0] = c'^' # Native data types, manual alignment             # <<<<<<<<<<<<<<
 *                 offset = 0
 *                 f = _util_dtypestring(descr, info.format + 1,
 */
    (__pyx_v_info->format[0]) = '^';

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":282
 *                 info.format = <char*>stdlib.malloc(_buffer_format_string_len)
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0             # <<<<<<<<<<<<<<
 *                 f = _util_dtypestring(descr, info.format + 1,
 *                                       info.format + _buffer_format_string_len,
 */
    __pyx_v_offset = 0;

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":283
 *                 info.format[0] = c'^' # Native data types, manual alignment
 *                 offset = 0
 *                 f = _util_dtypestring(descr, info.format + 1,             # <<<<<<<<<<<<<<
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)
 */
    __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_f = __pyx_t_9;

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":286
 *                                       info.format + _buffer_format_string_len,
 *                                       &offset)
 *                 f[0] = c'\0' # Terminate format string             # <<<<<<<<<<<<<<
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 */
    (__pyx_v_f[0]) = '\x00';
  }

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":194
 *         # experimental exception made for __getbuffer__ and __releasebuffer__
 *         # -- the details of this may change.
 *         def __getbuffer__(ndarray self, Py_buffer* info, int flags):             # <<<<<<<<<<<<<<
 *             # This implementation of getbuffer is geared towards Cython
 *             # requirements, and does not yet fullfill the PEP.
 */

  /* function exit code */
  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) {
    __Pyx_GOTREF(__pyx_v_info->obj);
    __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL;
  }
  goto __pyx_L2;
  __pyx_L0:;
  if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) {
    __Pyx_GOTREF(Py_None);
    __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL;
  }
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_descr);
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":288
 *                 f[0] = c'\0' # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 */

/* Python wrapper */
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/
static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0);
  __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info));

  /* function exit code */
  __Pyx_RefNannyFinishContext();
}

static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("__releasebuffer__", 0);
  __Pyx_TraceCall("__releasebuffer__", __pyx_f[2], 288);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":289
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 */
  __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0);
  if (__pyx_t_1) {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":290
 *         def __releasebuffer__(ndarray self, Py_buffer* info):
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)             # <<<<<<<<<<<<<<
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)
 */
    free(__pyx_v_info->format);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":291
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):             # <<<<<<<<<<<<<<
 *                 stdlib.free(info.strides)
 *                 # info.shape was stored after info.strides in the same block
 */
  __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0);
  if (__pyx_t_1) {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":292
 *                 stdlib.free(info.format)
 *             if sizeof(npy_intp) != sizeof(Py_ssize_t):
 *                 stdlib.free(info.strides)             # <<<<<<<<<<<<<<
 *                 # info.shape was stored after info.strides in the same block
 * 
 */
    free(__pyx_v_info->strides);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":288
 *                 f[0] = c'\0' # Terminate format string
 * 
 *         def __releasebuffer__(ndarray self, Py_buffer* info):             # <<<<<<<<<<<<<<
 *             if PyArray_HASFIELDS(self):
 *                 stdlib.free(info.format)
 */

  /* function exit code */
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
}

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":768
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0);
  __Pyx_TraceCall("PyArray_MultiIterNew1", __pyx_f[2], 768);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":769
 * 
 * cdef inline object PyArray_MultiIterNew1(a):
 *     return PyArray_MultiIterNew(1, <void*>a)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":768
 * ctypedef npy_cdouble     complex_t
 * 
 * cdef inline object PyArray_MultiIterNew1(a):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":771
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0);
  __Pyx_TraceCall("PyArray_MultiIterNew2", __pyx_f[2], 771);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":772
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":771
 *     return PyArray_MultiIterNew(1, <void*>a)
 * 
 * cdef inline object PyArray_MultiIterNew2(a, b):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":774
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0);
  __Pyx_TraceCall("PyArray_MultiIterNew3", __pyx_f[2], 774);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":775
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":774
 *     return PyArray_MultiIterNew(2, <void*>a, <void*>b)
 * 
 * cdef inline object PyArray_MultiIterNew3(a, b, c):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":777
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0);
  __Pyx_TraceCall("PyArray_MultiIterNew4", __pyx_f[2], 777);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":778
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)             # <<<<<<<<<<<<<<
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":777
 *     return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
 * 
 * cdef inline object PyArray_MultiIterNew4(a, b, c, d):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":780
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0);
  __Pyx_TraceCall("PyArray_MultiIterNew5", __pyx_f[2], 780);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":781
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)             # <<<<<<<<<<<<<<
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":780
 *     return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
 * 
 * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):             # <<<<<<<<<<<<<<
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":783
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
 *     # Recursive utility function used in __getbuffer__ to get format
 *     # string. The new location in the format string is returned.
 */

static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) {
  PyArray_Descr *__pyx_v_child = 0;
  int __pyx_v_endian_detector;
  int __pyx_v_little_endian;
  PyObject *__pyx_v_fields = 0;
  PyObject *__pyx_v_childname = NULL;
  PyObject *__pyx_v_new_offset = NULL;
  PyObject *__pyx_v_t = NULL;
  char *__pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  long __pyx_t_10;
  char *__pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("_util_dtypestring", 0);
  __Pyx_TraceCall("_util_dtypestring", __pyx_f[2], 783);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":790
 *     cdef int delta_offset
 *     cdef tuple i
 *     cdef int endian_detector = 1             # <<<<<<<<<<<<<<
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)
 *     cdef tuple fields
 */
  __pyx_v_endian_detector = 1;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":791
 *     cdef tuple i
 *     cdef int endian_detector = 1
 *     cdef bint little_endian = ((<char*>&endian_detector)[0] != 0)             # <<<<<<<<<<<<<<
 *     cdef tuple fields
 * 
 */
  __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":794
 *     cdef tuple fields
 * 
 *     for childname in descr.names:             # <<<<<<<<<<<<<<
 *         fields = descr.fields[childname]
 *         child, new_offset = fields
 */
  if (unlikely(__pyx_v_descr->names == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[2]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  for (;;) {
    if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":795
 * 
 *     for childname in descr.names:
 *         fields = descr.fields[childname]             # <<<<<<<<<<<<<<
 *         child, new_offset = fields
 * 
 */
    __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
    __Pyx_GOTREF(__pyx_t_3);
    if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3));
    __pyx_t_3 = 0;

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":796
 *     for childname in descr.names:
 *         fields = descr.fields[childname]
 *         child, new_offset = fields             # <<<<<<<<<<<<<<
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:
 */
    if (likely(__pyx_v_fields != Py_None)) {
      PyObject* sequence = __pyx_v_fields;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      #endif
    } else {
      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3));
    __pyx_t_3 = 0;
    __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4);
    __pyx_t_4 = 0;

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":798
 *         child, new_offset = fields
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:             # <<<<<<<<<<<<<<
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 */
    __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0);
    if (__pyx_t_6) {

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":799
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 */
      __pyx_t_3 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__77, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":801
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")
 * 
 *         if ((child.byteorder == c'>' and little_endian) or             # <<<<<<<<<<<<<<
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")
 */
    __pyx_t_6 = ((__pyx_v_child->byteorder == '>') != 0);
    if (__pyx_t_6) {
      __pyx_t_7 = (__pyx_v_little_endian != 0);
    } else {
      __pyx_t_7 = __pyx_t_6;
    }
    if (!__pyx_t_7) {

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":802
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):             # <<<<<<<<<<<<<<
 *             raise ValueError(u"Non-native byte order not supported")
 *             # One could encode it in the format string and have Cython
 */
      __pyx_t_6 = ((__pyx_v_child->byteorder == '<') != 0);
      if (__pyx_t_6) {
        __pyx_t_8 = ((!(__pyx_v_little_endian != 0)) != 0);
        __pyx_t_9 = __pyx_t_8;
      } else {
        __pyx_t_9 = __pyx_t_6;
      }
      __pyx_t_6 = __pyx_t_9;
    } else {
      __pyx_t_6 = __pyx_t_7;
    }
    if (__pyx_t_6) {

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":803
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *             # One could encode it in the format string and have Cython
 *             # complain instead, BUT: < and > in format strings also imply
 */
      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_Raise(__pyx_t_3, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[2]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":813
 * 
 *         # Output padding bytes
 *         while offset[0] < new_offset:             # <<<<<<<<<<<<<<
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 */
    while (1) {
      __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!__pyx_t_6) break;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":814
 *         # Output padding bytes
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte             # <<<<<<<<<<<<<<
 *             f += 1
 *             offset[0] += 1
 */
      (__pyx_v_f[0]) = 120;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":815
 *         while offset[0] < new_offset:
 *             f[0] = 120 # "x"; pad byte
 *             f += 1             # <<<<<<<<<<<<<<
 *             offset[0] += 1
 * 
 */
      __pyx_v_f = (__pyx_v_f + 1);

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":816
 *             f[0] = 120 # "x"; pad byte
 *             f += 1
 *             offset[0] += 1             # <<<<<<<<<<<<<<
 * 
 *         offset[0] += child.itemsize
 */
      __pyx_t_10 = 0;
      (__pyx_v_offset[__pyx_t_10]) = ((__pyx_v_offset[__pyx_t_10]) + 1);
    }

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":818
 *             offset[0] += 1
 * 
 *         offset[0] += child.itemsize             # <<<<<<<<<<<<<<
 * 
 *         if not PyDataType_HASFIELDS(child):
 */
    __pyx_t_10 = 0;
    (__pyx_v_offset[__pyx_t_10]) = ((__pyx_v_offset[__pyx_t_10]) + __pyx_v_child->elsize);

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":820
 *         offset[0] += child.itemsize
 * 
 *         if not PyDataType_HASFIELDS(child):             # <<<<<<<<<<<<<<
 *             t = child.type_num
 *             if end - f < 5:
 */
    __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0);
    if (__pyx_t_6) {

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":821
 * 
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num             # <<<<<<<<<<<<<<
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")
 */
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4);
      __pyx_t_4 = 0;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":822
 *         if not PyDataType_HASFIELDS(child):
 *             t = child.type_num
 *             if end - f < 5:             # <<<<<<<<<<<<<<
 *                 raise RuntimeError(u"Format string allocated too short.")
 * 
 */
      __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0);
      if (__pyx_t_6) {

        /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":823
 *             t = child.type_num
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 */
        __pyx_t_4 = PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__79, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        {__pyx_filename = __pyx_f[2]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":826
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 98;
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":827
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"             # <<<<<<<<<<<<<<
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 66;
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":828
 *             if   t == NPY_BYTE:        f[0] =  98 #"b"
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"             # <<<<<<<<<<<<<<
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 104;
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":829
 *             elif t == NPY_UBYTE:       f[0] =  66 #"B"
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"             # <<<<<<<<<<<<<<
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 72;
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":830
 *             elif t == NPY_SHORT:       f[0] = 104 #"h"
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"             # <<<<<<<<<<<<<<
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 105;
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":831
 *             elif t == NPY_USHORT:      f[0] =  72 #"H"
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 73;
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":832
 *             elif t == NPY_INT:         f[0] = 105 #"i"
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 108;
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":833
 *             elif t == NPY_UINT:        f[0] =  73 #"I"
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 76;
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":834
 *             elif t == NPY_LONG:        f[0] = 108 #"l"
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 113;
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":835
 *             elif t == NPY_ULONG:       f[0] = 76  #"L"
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"             # <<<<<<<<<<<<<<
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 */
      __pyx_t_3 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 81;
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":836
 *             elif t == NPY_LONGLONG:    f[0] = 113 #"q"
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"             # <<<<<<<<<<<<<<
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 102;
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":837
 *             elif t == NPY_ULONGLONG:   f[0] = 81  #"Q"
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"             # <<<<<<<<<<<<<<
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 */
      __pyx_t_3 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 100;
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":838
 *             elif t == NPY_FLOAT:       f[0] = 102 #"f"
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"             # <<<<<<<<<<<<<<
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 */
      __pyx_t_4 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 103;
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":839
 *             elif t == NPY_DOUBLE:      f[0] = 100 #"d"
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf             # <<<<<<<<<<<<<<
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 */
      __pyx_t_3 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 102;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":840
 *             elif t == NPY_LONGDOUBLE:  f[0] = 103 #"g"
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd             # <<<<<<<<<<<<<<
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 */
      __pyx_t_4 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 100;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":841
 *             elif t == NPY_CFLOAT:      f[0] = 90; f[1] = 102; f += 1 # Zf
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg             # <<<<<<<<<<<<<<
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 */
      __pyx_t_3 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 90;
        (__pyx_v_f[1]) = 103;
        __pyx_v_f = (__pyx_v_f + 1);
        goto __pyx_L11;
      }

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":842
 *             elif t == NPY_CDOUBLE:     f[0] = 90; f[1] = 100; f += 1 # Zd
 *             elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 */
      __pyx_t_4 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_6) {
        (__pyx_v_f[0]) = 79;
        goto __pyx_L11;
      }
      /*else*/ {

        /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":844
 *             elif t == NPY_OBJECT:      f[0] = 79 #"O"
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)             # <<<<<<<<<<<<<<
 *             f += 1
 *         else:
 */
        __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_Raise(__pyx_t_3, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        {__pyx_filename = __pyx_f[2]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_L11:;

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":845
 *             else:
 *                 raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t)
 *             f += 1             # <<<<<<<<<<<<<<
 *         else:
 *             # Cython ignores struct boundary information ("T{...}"),
 */
      __pyx_v_f = (__pyx_v_f + 1);
      goto __pyx_L9;
    }
    /*else*/ {

      /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":849
 *             # Cython ignores struct boundary information ("T{...}"),
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)             # <<<<<<<<<<<<<<
 *     return f
 * 
 */
      __pyx_t_11 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_f = __pyx_t_11;
    }
    __pyx_L9:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":850
 *             # so don't output it
 *             f = _util_dtypestring(child, f, end, offset)
 *     return f             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_f;
  goto __pyx_L0;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":783
 *     return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
 * 
 * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL:             # <<<<<<<<<<<<<<
 *     # Recursive utility function used in __getbuffer__ to get format
 *     # string. The new location in the format string is returned.
 */

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_child);
  __Pyx_XDECREF(__pyx_v_fields);
  __Pyx_XDECREF(__pyx_v_childname);
  __Pyx_XDECREF(__pyx_v_new_offset);
  __Pyx_XDECREF(__pyx_v_t);
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":966
 * 
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *      cdef PyObject* baseptr
 *      if base is None:
 */

static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) {
  PyObject *__pyx_v_baseptr;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("set_array_base", 0);
  __Pyx_TraceCall("set_array_base", __pyx_f[2], 966);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":968
 * cdef inline void set_array_base(ndarray arr, object base):
 *      cdef PyObject* baseptr
 *      if base is None:             # <<<<<<<<<<<<<<
 *          baseptr = NULL
 *      else:
 */
  __pyx_t_1 = (__pyx_v_base == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":969
 *      cdef PyObject* baseptr
 *      if base is None:
 *          baseptr = NULL             # <<<<<<<<<<<<<<
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!
 */
    __pyx_v_baseptr = NULL;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":971
 *          baseptr = NULL
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!             # <<<<<<<<<<<<<<
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)
 */
    Py_INCREF(__pyx_v_base);

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":972
 *      else:
 *          Py_INCREF(base) # important to do this before decref below!
 *          baseptr = <PyObject*>base             # <<<<<<<<<<<<<<
 *      Py_XDECREF(arr.base)
 *      arr.base = baseptr
 */
    __pyx_v_baseptr = ((PyObject *)__pyx_v_base);
  }
  __pyx_L3:;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":973
 *          Py_INCREF(base) # important to do this before decref below!
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)             # <<<<<<<<<<<<<<
 *      arr.base = baseptr
 * 
 */
  Py_XDECREF(__pyx_v_arr->base);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":974
 *          baseptr = <PyObject*>base
 *      Py_XDECREF(arr.base)
 *      arr.base = baseptr             # <<<<<<<<<<<<<<
 * 
 * cdef inline object get_array_base(ndarray arr):
 */
  __pyx_v_arr->base = __pyx_v_baseptr;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":966
 * 
 * 
 * cdef inline void set_array_base(ndarray arr, object base):             # <<<<<<<<<<<<<<
 *      cdef PyObject* baseptr
 *      if base is None:
 */

  /* function exit code */
  __Pyx_TraceReturn(Py_None);
  __Pyx_RefNannyFinishContext();
}

/* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":976
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */

static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  __Pyx_TraceDeclarations
  __Pyx_RefNannySetupContext("get_array_base", 0);
  __Pyx_TraceCall("get_array_base", __pyx_f[2], 976);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":977
 * 
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:             # <<<<<<<<<<<<<<
 *         return None
 *     else:
 */
  __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0);
  if (__pyx_t_1) {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":978
 * cdef inline object get_array_base(ndarray arr):
 *     if arr.base is NULL:
 *         return None             # <<<<<<<<<<<<<<
 *     else:
 *         return <object>arr.base
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
  }
  /*else*/ {

    /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":980
 *         return None
 *     else:
 *         return <object>arr.base             # <<<<<<<<<<<<<<
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_arr->base));
    __pyx_r = ((PyObject *)__pyx_v_arr->base);
    goto __pyx_L0;
  }

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":976
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */

  /* function exit code */
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_TraceReturn(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_8rasterio_3_io_RasterReader __pyx_vtable_8rasterio_3_io_RasterReader;

static PyObject *__pyx_tp_new_8rasterio_3_io_RasterReader(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_8rasterio_3_io_RasterReader *p;
  PyObject *o;
  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
    o = (*t->tp_alloc)(t, 0);
  } else {
    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
  }
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_8rasterio_3_io_RasterReader *)o);
  p->__pyx_vtab = __pyx_vtabptr_8rasterio_3_io_RasterReader;
  p->name = Py_None; Py_INCREF(Py_None);
  p->mode = Py_None; Py_INCREF(Py_None);
  p->width = Py_None; Py_INCREF(Py_None);
  p->height = Py_None; Py_INCREF(Py_None);
  p->shape = Py_None; Py_INCREF(Py_None);
  p->driver = Py_None; Py_INCREF(Py_None);
  p->_count = Py_None; Py_INCREF(Py_None);
  p->_dtypes = Py_None; Py_INCREF(Py_None);
  p->_closed = Py_None; Py_INCREF(Py_None);
  p->_crs = Py_None; Py_INCREF(Py_None);
  p->_crs_wkt = Py_None; Py_INCREF(Py_None);
  p->_transform = Py_None; Py_INCREF(Py_None);
  p->_block_shapes = Py_None; Py_INCREF(Py_None);
  p->_nodatavals = Py_None; Py_INCREF(Py_None);
  p->_read = Py_None; Py_INCREF(Py_None);
  p->env = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_8rasterio_3_io_RasterReader(PyObject *o) {
  struct __pyx_obj_8rasterio_3_io_RasterReader *p = (struct __pyx_obj_8rasterio_3_io_RasterReader *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_8rasterio_3_io_12RasterReader_21__dealloc__(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_CLEAR(p->name);
  Py_CLEAR(p->mode);
  Py_CLEAR(p->width);
  Py_CLEAR(p->height);
  Py_CLEAR(p->shape);
  Py_CLEAR(p->driver);
  Py_CLEAR(p->_count);
  Py_CLEAR(p->_dtypes);
  Py_CLEAR(p->_closed);
  Py_CLEAR(p->_crs);
  Py_CLEAR(p->_crs_wkt);
  Py_CLEAR(p->_transform);
  Py_CLEAR(p->_block_shapes);
  Py_CLEAR(p->_nodatavals);
  Py_CLEAR(p->_read);
  Py_CLEAR(p->env);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_8rasterio_3_io_RasterReader(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_8rasterio_3_io_RasterReader *p = (struct __pyx_obj_8rasterio_3_io_RasterReader *)o;
  if (p->name) {
    e = (*v)(p->name, a); if (e) return e;
  }
  if (p->mode) {
    e = (*v)(p->mode, a); if (e) return e;
  }
  if (p->width) {
    e = (*v)(p->width, a); if (e) return e;
  }
  if (p->height) {
    e = (*v)(p->height, a); if (e) return e;
  }
  if (p->shape) {
    e = (*v)(p->shape, a); if (e) return e;
  }
  if (p->driver) {
    e = (*v)(p->driver, a); if (e) return e;
  }
  if (p->_count) {
    e = (*v)(p->_count, a); if (e) return e;
  }
  if (p->_dtypes) {
    e = (*v)(p->_dtypes, a); if (e) return e;
  }
  if (p->_closed) {
    e = (*v)(p->_closed, a); if (e) return e;
  }
  if (p->_crs) {
    e = (*v)(p->_crs, a); if (e) return e;
  }
  if (p->_crs_wkt) {
    e = (*v)(p->_crs_wkt, a); if (e) return e;
  }
  if (p->_transform) {
    e = (*v)(p->_transform, a); if (e) return e;
  }
  if (p->_block_shapes) {
    e = (*v)(p->_block_shapes, a); if (e) return e;
  }
  if (p->_nodatavals) {
    e = (*v)(p->_nodatavals, a); if (e) return e;
  }
  if (p->_read) {
    e = (*v)(p->_read, a); if (e) return e;
  }
  if (p->env) {
    e = (*v)(p->env, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_8rasterio_3_io_RasterReader(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_8rasterio_3_io_RasterReader *p = (struct __pyx_obj_8rasterio_3_io_RasterReader *)o;
  tmp = ((PyObject*)p->name);
  p->name = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->mode);
  p->mode = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->width);
  p->width = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->height);
  p->height = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->shape);
  p->shape = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->driver);
  p->driver = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_count);
  p->_count = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_dtypes);
  p->_dtypes = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_closed);
  p->_closed = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_crs);
  p->_crs = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_crs_wkt);
  p->_crs_wkt = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_transform);
  p->_transform = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_block_shapes);
  p->_block_shapes = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_nodatavals);
  p->_nodatavals = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_read);
  p->_read = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->env);
  p->env = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader_name(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_4name_1__get__(o);
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader_mode(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_4mode_1__get__(o);
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader_width(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_5width_1__get__(o);
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader_height(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_6height_1__get__(o);
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader_shape(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_5shape_1__get__(o);
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader_driver(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_6driver_1__get__(o);
}

static int __pyx_setprop_8rasterio_3_io_12RasterReader_driver(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_8rasterio_3_io_12RasterReader_6driver_3__set__(o, v);
  }
  else {
    return __pyx_pw_8rasterio_3_io_12RasterReader_6driver_5__del__(o);
  }
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader__count(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_6_count_1__get__(o);
}

static int __pyx_setprop_8rasterio_3_io_12RasterReader__count(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_8rasterio_3_io_12RasterReader_6_count_3__set__(o, v);
  }
  else {
    return __pyx_pw_8rasterio_3_io_12RasterReader_6_count_5__del__(o);
  }
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader__dtypes(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_7_dtypes_1__get__(o);
}

static int __pyx_setprop_8rasterio_3_io_12RasterReader__dtypes(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_8rasterio_3_io_12RasterReader_7_dtypes_3__set__(o, v);
  }
  else {
    return __pyx_pw_8rasterio_3_io_12RasterReader_7_dtypes_5__del__(o);
  }
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader__closed(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_7_closed_1__get__(o);
}

static int __pyx_setprop_8rasterio_3_io_12RasterReader__closed(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_8rasterio_3_io_12RasterReader_7_closed_3__set__(o, v);
  }
  else {
    return __pyx_pw_8rasterio_3_io_12RasterReader_7_closed_5__del__(o);
  }
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader__crs(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_4_crs_1__get__(o);
}

static int __pyx_setprop_8rasterio_3_io_12RasterReader__crs(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_8rasterio_3_io_12RasterReader_4_crs_3__set__(o, v);
  }
  else {
    return __pyx_pw_8rasterio_3_io_12RasterReader_4_crs_5__del__(o);
  }
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader__crs_wkt(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_8_crs_wkt_1__get__(o);
}

static int __pyx_setprop_8rasterio_3_io_12RasterReader__crs_wkt(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_8rasterio_3_io_12RasterReader_8_crs_wkt_3__set__(o, v);
  }
  else {
    return __pyx_pw_8rasterio_3_io_12RasterReader_8_crs_wkt_5__del__(o);
  }
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader__transform(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_10_transform_1__get__(o);
}

static int __pyx_setprop_8rasterio_3_io_12RasterReader__transform(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_8rasterio_3_io_12RasterReader_10_transform_3__set__(o, v);
  }
  else {
    return __pyx_pw_8rasterio_3_io_12RasterReader_10_transform_5__del__(o);
  }
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader__block_shapes(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_13_block_shapes_1__get__(o);
}

static int __pyx_setprop_8rasterio_3_io_12RasterReader__block_shapes(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_8rasterio_3_io_12RasterReader_13_block_shapes_3__set__(o, v);
  }
  else {
    return __pyx_pw_8rasterio_3_io_12RasterReader_13_block_shapes_5__del__(o);
  }
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader__nodatavals(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_11_nodatavals_1__get__(o);
}

static int __pyx_setprop_8rasterio_3_io_12RasterReader__nodatavals(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_8rasterio_3_io_12RasterReader_11_nodatavals_3__set__(o, v);
  }
  else {
    return __pyx_pw_8rasterio_3_io_12RasterReader_11_nodatavals_5__del__(o);
  }
}

static PyObject *__pyx_getprop_8rasterio_3_io_12RasterReader__read(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_12RasterReader_5_read_1__get__(o);
}

static int __pyx_setprop_8rasterio_3_io_12RasterReader__read(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_8rasterio_3_io_12RasterReader_5_read_3__set__(o, v);
  }
  else {
    return __pyx_pw_8rasterio_3_io_12RasterReader_5_read_5__del__(o);
  }
}

static PyMethodDef __pyx_methods_8rasterio_3_io_RasterReader[] = {
  {__Pyx_NAMESTR("start"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_5start, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("read_crs"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_7read_crs, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("read_crs_wkt"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_9read_crs_wkt, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("read_transform"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_11read_transform, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("stop"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_13stop, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_15close, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("__enter__"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_17__enter__, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("__exit__"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_19__exit__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("closed"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_23closed, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("count"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_25count, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("indexes"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_27indexes, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("dtypes"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_29dtypes, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_12RasterReader_28dtypes)},
  {__Pyx_NAMESTR("block_shapes"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_31block_shapes, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_12RasterReader_30block_shapes)},
  {__Pyx_NAMESTR("nodatavals"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_33nodatavals, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_12RasterReader_32nodatavals)},
  {__Pyx_NAMESTR("block_windows"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_35block_windows, METH_O, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_12RasterReader_34block_windows)},
  {__Pyx_NAMESTR("bounds"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_38bounds, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_12RasterReader_37bounds)},
  {__Pyx_NAMESTR("res"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_40res, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_12RasterReader_39res)},
  {__Pyx_NAMESTR("ul"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_42ul, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_12RasterReader_41ul)},
  {__Pyx_NAMESTR("index"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_44index, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_12RasterReader_43index)},
  {__Pyx_NAMESTR("meta"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_46meta, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("get_crs"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_48get_crs, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("get_crs_wkt"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_50get_crs_wkt, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("get_transform"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_52get_transform, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_12RasterReader_51get_transform)},
  {__Pyx_NAMESTR("read_band"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_54read_band, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_12RasterReader_53read_band)},
  {__Pyx_NAMESTR("tags"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_56tags, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_12RasterReader_55tags)},
  {__Pyx_NAMESTR("colormap"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_58colormap, METH_O, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_12RasterReader_57colormap)},
  {__Pyx_NAMESTR("read_mask"), (PyCFunction)__pyx_pw_8rasterio_3_io_12RasterReader_60read_mask, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_12RasterReader_59read_mask)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_8rasterio_3_io_RasterReader[] = {
  {(char *)"name", __pyx_getprop_8rasterio_3_io_12RasterReader_name, 0, 0, 0},
  {(char *)"mode", __pyx_getprop_8rasterio_3_io_12RasterReader_mode, 0, 0, 0},
  {(char *)"width", __pyx_getprop_8rasterio_3_io_12RasterReader_width, 0, 0, 0},
  {(char *)"height", __pyx_getprop_8rasterio_3_io_12RasterReader_height, 0, 0, 0},
  {(char *)"shape", __pyx_getprop_8rasterio_3_io_12RasterReader_shape, 0, 0, 0},
  {(char *)"driver", __pyx_getprop_8rasterio_3_io_12RasterReader_driver, __pyx_setprop_8rasterio_3_io_12RasterReader_driver, 0, 0},
  {(char *)"_count", __pyx_getprop_8rasterio_3_io_12RasterReader__count, __pyx_setprop_8rasterio_3_io_12RasterReader__count, 0, 0},
  {(char *)"_dtypes", __pyx_getprop_8rasterio_3_io_12RasterReader__dtypes, __pyx_setprop_8rasterio_3_io_12RasterReader__dtypes, 0, 0},
  {(char *)"_closed", __pyx_getprop_8rasterio_3_io_12RasterReader__closed, __pyx_setprop_8rasterio_3_io_12RasterReader__closed, 0, 0},
  {(char *)"_crs", __pyx_getprop_8rasterio_3_io_12RasterReader__crs, __pyx_setprop_8rasterio_3_io_12RasterReader__crs, 0, 0},
  {(char *)"_crs_wkt", __pyx_getprop_8rasterio_3_io_12RasterReader__crs_wkt, __pyx_setprop_8rasterio_3_io_12RasterReader__crs_wkt, 0, 0},
  {(char *)"_transform", __pyx_getprop_8rasterio_3_io_12RasterReader__transform, __pyx_setprop_8rasterio_3_io_12RasterReader__transform, 0, 0},
  {(char *)"_block_shapes", __pyx_getprop_8rasterio_3_io_12RasterReader__block_shapes, __pyx_setprop_8rasterio_3_io_12RasterReader__block_shapes, 0, 0},
  {(char *)"_nodatavals", __pyx_getprop_8rasterio_3_io_12RasterReader__nodatavals, __pyx_setprop_8rasterio_3_io_12RasterReader__nodatavals, 0, 0},
  {(char *)"_read", __pyx_getprop_8rasterio_3_io_12RasterReader__read, __pyx_setprop_8rasterio_3_io_12RasterReader__read, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_8rasterio_3_io_RasterReader = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("rasterio._io.RasterReader"), /*tp_name*/
  sizeof(struct __pyx_obj_8rasterio_3_io_RasterReader), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_8rasterio_3_io_RasterReader, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_8rasterio_3_io_12RasterReader_3__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_8rasterio_3_io_RasterReader, /*tp_traverse*/
  __pyx_tp_clear_8rasterio_3_io_RasterReader, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_8rasterio_3_io_RasterReader, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_8rasterio_3_io_RasterReader, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_8rasterio_3_io_12RasterReader_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_8rasterio_3_io_RasterReader, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};
static struct __pyx_vtabstruct_8rasterio_3_io_RasterUpdater __pyx_vtable_8rasterio_3_io_RasterUpdater;

static PyObject *__pyx_tp_new_8rasterio_3_io_RasterUpdater(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_8rasterio_3_io_RasterUpdater *p;
  PyObject *o = __pyx_tp_new_8rasterio_3_io_RasterReader(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_8rasterio_3_io_RasterUpdater *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_8rasterio_3_io_RasterReader*)__pyx_vtabptr_8rasterio_3_io_RasterUpdater;
  p->_init_dtype = Py_None; Py_INCREF(Py_None);
  p->_init_nodata = Py_None; Py_INCREF(Py_None);
  p->_options = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_8rasterio_3_io_RasterUpdater(PyObject *o) {
  struct __pyx_obj_8rasterio_3_io_RasterUpdater *p = (struct __pyx_obj_8rasterio_3_io_RasterUpdater *)o;
  #if PY_VERSION_HEX >= 0x030400a1
  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
    if (PyObject_CallFinalizerFromDealloc(o)) return;
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->_init_dtype);
  Py_CLEAR(p->_init_nodata);
  Py_CLEAR(p->_options);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_8rasterio_3_io_RasterReader(o);
}

static int __pyx_tp_traverse_8rasterio_3_io_RasterUpdater(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_8rasterio_3_io_RasterUpdater *p = (struct __pyx_obj_8rasterio_3_io_RasterUpdater *)o;
  e = __pyx_tp_traverse_8rasterio_3_io_RasterReader(o, v, a); if (e) return e;
  if (p->_init_dtype) {
    e = (*v)(p->_init_dtype, a); if (e) return e;
  }
  if (p->_init_nodata) {
    e = (*v)(p->_init_nodata, a); if (e) return e;
  }
  if (p->_options) {
    e = (*v)(p->_options, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_8rasterio_3_io_RasterUpdater(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_8rasterio_3_io_RasterUpdater *p = (struct __pyx_obj_8rasterio_3_io_RasterUpdater *)o;
  __pyx_tp_clear_8rasterio_3_io_RasterReader(o);
  tmp = ((PyObject*)p->_init_dtype);
  p->_init_dtype = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_init_nodata);
  p->_init_nodata = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_options);
  p->_options = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_8rasterio_3_io_13RasterUpdater__init_dtype(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_13RasterUpdater_11_init_dtype_1__get__(o);
}

static PyObject *__pyx_getprop_8rasterio_3_io_13RasterUpdater__init_nodata(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_13RasterUpdater_12_init_nodata_1__get__(o);
}

static PyObject *__pyx_getprop_8rasterio_3_io_13RasterUpdater__options(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_8rasterio_3_io_13RasterUpdater_8_options_1__get__(o);
}

static PyMethodDef __pyx_methods_8rasterio_3_io_RasterUpdater[] = {
  {__Pyx_NAMESTR("start"), (PyCFunction)__pyx_pw_8rasterio_3_io_13RasterUpdater_5start, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("get_crs"), (PyCFunction)__pyx_pw_8rasterio_3_io_13RasterUpdater_7get_crs, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("write_crs"), (PyCFunction)__pyx_pw_8rasterio_3_io_13RasterUpdater_9write_crs, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("write_transform"), (PyCFunction)__pyx_pw_8rasterio_3_io_13RasterUpdater_11write_transform, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("get_transform"), (PyCFunction)__pyx_pw_8rasterio_3_io_13RasterUpdater_13get_transform, METH_NOARGS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("write_band"), (PyCFunction)__pyx_pw_8rasterio_3_io_13RasterUpdater_15write_band, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_13RasterUpdater_14write_band)},
  {__Pyx_NAMESTR("update_tags"), (PyCFunction)__pyx_pw_8rasterio_3_io_13RasterUpdater_17update_tags, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_13RasterUpdater_16update_tags)},
  {__Pyx_NAMESTR("write_colormap"), (PyCFunction)__pyx_pw_8rasterio_3_io_13RasterUpdater_19write_colormap, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_13RasterUpdater_18write_colormap)},
  {__Pyx_NAMESTR("write_mask"), (PyCFunction)__pyx_pw_8rasterio_3_io_13RasterUpdater_21write_mask, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_13RasterUpdater_20write_mask)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_8rasterio_3_io_RasterUpdater[] = {
  {(char *)"_init_dtype", __pyx_getprop_8rasterio_3_io_13RasterUpdater__init_dtype, 0, 0, 0},
  {(char *)"_init_nodata", __pyx_getprop_8rasterio_3_io_13RasterUpdater__init_nodata, 0, 0, 0},
  {(char *)"_options", __pyx_getprop_8rasterio_3_io_13RasterUpdater__options, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_8rasterio_3_io_RasterUpdater = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("rasterio._io.RasterUpdater"), /*tp_name*/
  sizeof(struct __pyx_obj_8rasterio_3_io_RasterUpdater), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_8rasterio_3_io_RasterUpdater, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_8rasterio_3_io_13RasterUpdater_3__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_8rasterio_3_io_RasterUpdater, /*tp_traverse*/
  __pyx_tp_clear_8rasterio_3_io_RasterUpdater, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_8rasterio_3_io_RasterUpdater, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_8rasterio_3_io_RasterUpdater, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_8rasterio_3_io_13RasterUpdater_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_8rasterio_3_io_RasterUpdater, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows *__pyx_freelist_8rasterio_3_io___pyx_scope_struct_2_block_windows[8];
static int __pyx_freecount_8rasterio_3_io___pyx_scope_struct_2_block_windows = 0;

static PyObject *__pyx_tp_new_8rasterio_3_io___pyx_scope_struct_2_block_windows(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (likely((__pyx_freecount_8rasterio_3_io___pyx_scope_struct_2_block_windows > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows)))) {
    o = (PyObject*)__pyx_freelist_8rasterio_3_io___pyx_scope_struct_2_block_windows[--__pyx_freecount_8rasterio_3_io___pyx_scope_struct_2_block_windows];
    memset(o, 0, sizeof(struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_8rasterio_3_io___pyx_scope_struct_2_block_windows(PyObject *o) {
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows *p = (struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_bdix);
  Py_CLEAR(p->__pyx_v_col);
  Py_CLEAR(p->__pyx_v_d);
  Py_CLEAR(p->__pyx_v_h);
  Py_CLEAR(p->__pyx_v_height);
  Py_CLEAR(p->__pyx_v_m);
  Py_CLEAR(p->__pyx_v_ncols);
  Py_CLEAR(p->__pyx_v_nrows);
  Py_CLEAR(p->__pyx_v_row);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_w);
  Py_CLEAR(p->__pyx_v_width);
  if ((__pyx_freecount_8rasterio_3_io___pyx_scope_struct_2_block_windows < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows))) {
    __pyx_freelist_8rasterio_3_io___pyx_scope_struct_2_block_windows[__pyx_freecount_8rasterio_3_io___pyx_scope_struct_2_block_windows++] = ((struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_8rasterio_3_io___pyx_scope_struct_2_block_windows(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows *p = (struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows *)o;
  if (p->__pyx_v_bdix) {
    e = (*v)(p->__pyx_v_bdix, a); if (e) return e;
  }
  if (p->__pyx_v_col) {
    e = (*v)(p->__pyx_v_col, a); if (e) return e;
  }
  if (p->__pyx_v_d) {
    e = (*v)(p->__pyx_v_d, a); if (e) return e;
  }
  if (p->__pyx_v_h) {
    e = (*v)(p->__pyx_v_h, a); if (e) return e;
  }
  if (p->__pyx_v_height) {
    e = (*v)(p->__pyx_v_height, a); if (e) return e;
  }
  if (p->__pyx_v_m) {
    e = (*v)(p->__pyx_v_m, a); if (e) return e;
  }
  if (p->__pyx_v_ncols) {
    e = (*v)(p->__pyx_v_ncols, a); if (e) return e;
  }
  if (p->__pyx_v_nrows) {
    e = (*v)(p->__pyx_v_nrows, a); if (e) return e;
  }
  if (p->__pyx_v_row) {
    e = (*v)(p->__pyx_v_row, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e;
  }
  if (p->__pyx_v_w) {
    e = (*v)(p->__pyx_v_w, a); if (e) return e;
  }
  if (p->__pyx_v_width) {
    e = (*v)(p->__pyx_v_width, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_8rasterio_3_io___pyx_scope_struct_2_block_windows(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows *p = (struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows *)o;
  tmp = ((PyObject*)p->__pyx_v_bdix);
  p->__pyx_v_bdix = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_col);
  p->__pyx_v_col = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_d);
  p->__pyx_v_d = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_h);
  p->__pyx_v_h = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_height);
  p->__pyx_v_height = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_m);
  p->__pyx_v_m = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_ncols);
  p->__pyx_v_ncols = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_nrows);
  p->__pyx_v_nrows = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_row);
  p->__pyx_v_row = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_self);
  p->__pyx_v_self = ((struct __pyx_obj_8rasterio_3_io_RasterReader *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_w);
  p->__pyx_v_w = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_width);
  p->__pyx_v_width = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_8rasterio_3_io___pyx_scope_struct_2_block_windows = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("rasterio._io.__pyx_scope_struct_2_block_windows"), /*tp_name*/
  sizeof(struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_2_block_windows), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_8rasterio_3_io___pyx_scope_struct_2_block_windows, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_8rasterio_3_io___pyx_scope_struct_2_block_windows, /*tp_traverse*/
  __pyx_tp_clear_8rasterio_3_io___pyx_scope_struct_2_block_windows, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_8rasterio_3_io___pyx_scope_struct_2_block_windows, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index *__pyx_freelist_8rasterio_3_io___pyx_scope_struct__window_index[8];
static int __pyx_freecount_8rasterio_3_io___pyx_scope_struct__window_index = 0;

static PyObject *__pyx_tp_new_8rasterio_3_io___pyx_scope_struct__window_index(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (likely((__pyx_freecount_8rasterio_3_io___pyx_scope_struct__window_index > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index)))) {
    o = (PyObject*)__pyx_freelist_8rasterio_3_io___pyx_scope_struct__window_index[--__pyx_freecount_8rasterio_3_io___pyx_scope_struct__window_index];
    memset(o, 0, sizeof(struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_8rasterio_3_io___pyx_scope_struct__window_index(PyObject *o) {
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index *p = (struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_window);
  if ((__pyx_freecount_8rasterio_3_io___pyx_scope_struct__window_index < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index))) {
    __pyx_freelist_8rasterio_3_io___pyx_scope_struct__window_index[__pyx_freecount_8rasterio_3_io___pyx_scope_struct__window_index++] = ((struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_8rasterio_3_io___pyx_scope_struct__window_index(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index *p = (struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index *)o;
  if (p->__pyx_v_window) {
    e = (*v)(p->__pyx_v_window, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_8rasterio_3_io___pyx_scope_struct__window_index(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index *p = (struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index *)o;
  tmp = ((PyObject*)p->__pyx_v_window);
  p->__pyx_v_window = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_8rasterio_3_io___pyx_scope_struct__window_index = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("rasterio._io.__pyx_scope_struct__window_index"), /*tp_name*/
  sizeof(struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_8rasterio_3_io___pyx_scope_struct__window_index, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_8rasterio_3_io___pyx_scope_struct__window_index, /*tp_traverse*/
  __pyx_tp_clear_8rasterio_3_io___pyx_scope_struct__window_index, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_8rasterio_3_io___pyx_scope_struct__window_index, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr *__pyx_freelist_8rasterio_3_io___pyx_scope_struct_1_genexpr[8];
static int __pyx_freecount_8rasterio_3_io___pyx_scope_struct_1_genexpr = 0;

static PyObject *__pyx_tp_new_8rasterio_3_io___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  if (likely((__pyx_freecount_8rasterio_3_io___pyx_scope_struct_1_genexpr > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr)))) {
    o = (PyObject*)__pyx_freelist_8rasterio_3_io___pyx_scope_struct_1_genexpr[--__pyx_freecount_8rasterio_3_io___pyx_scope_struct_1_genexpr];
    memset(o, 0, sizeof(struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr));
    (void) PyObject_INIT(o, t);
    PyObject_GC_Track(o);
  } else {
    o = (*t->tp_alloc)(t, 0);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_8rasterio_3_io___pyx_scope_struct_1_genexpr(PyObject *o) {
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_w);
  Py_CLEAR(p->__pyx_t_0);
  if ((__pyx_freecount_8rasterio_3_io___pyx_scope_struct_1_genexpr < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr))) {
    __pyx_freelist_8rasterio_3_io___pyx_scope_struct_1_genexpr[__pyx_freecount_8rasterio_3_io___pyx_scope_struct_1_genexpr++] = ((struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr *)o);
  } else {
    (*Py_TYPE(o)->tp_free)(o);
  }
}

static int __pyx_tp_traverse_8rasterio_3_io___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr *)o;
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_w) {
    e = (*v)(p->__pyx_v_w, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_8rasterio_3_io___pyx_scope_struct_1_genexpr(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr *)o;
  tmp = ((PyObject*)p->__pyx_outer_scope);
  p->__pyx_outer_scope = ((struct __pyx_obj_8rasterio_3_io___pyx_scope_struct__window_index *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_v_w);
  p->__pyx_v_w = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->__pyx_t_0);
  p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyTypeObject __pyx_type_8rasterio_3_io___pyx_scope_struct_1_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("rasterio._io.__pyx_scope_struct_1_genexpr"), /*tp_name*/
  sizeof(struct __pyx_obj_8rasterio_3_io___pyx_scope_struct_1_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_8rasterio_3_io___pyx_scope_struct_1_genexpr, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_8rasterio_3_io___pyx_scope_struct_1_genexpr, /*tp_traverse*/
  __pyx_tp_clear_8rasterio_3_io___pyx_scope_struct_1_genexpr, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_8rasterio_3_io___pyx_scope_struct_1_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
  #if PY_VERSION_HEX >= 0x030400a1
  0, /*tp_finalize*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {__Pyx_NAMESTR("eval_window"), (PyCFunction)__pyx_pw_8rasterio_3_io_1eval_window, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8rasterio_3_io_eval_window)},
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
  #if PY_VERSION_HEX < 0x03020000
    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  #else
    PyModuleDef_HEAD_INIT,
  #endif
    __Pyx_NAMESTR("_io"),
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_Can_t_read_closed_raster_file, __pyx_k_Can_t_read_closed_raster_file, sizeof(__pyx_k_Can_t_read_closed_raster_file), 0, 0, 1, 0},
  {&__pyx_kp_s_Color_d_d_d_d, __pyx_k_Color_d_d_d_d, sizeof(__pyx_k_Color_d_d_d_d), 0, 0, 1, 0},
  {&__pyx_kp_s_Created_mask_band, __pyx_k_Created_mask_band, sizeof(__pyx_k_Created_mask_band), 0, 0, 1, 0},
  {&__pyx_kp_s_Failed_to_create_mask, __pyx_k_Failed_to_create_mask, sizeof(__pyx_k_Failed_to_create_mask), 0, 0, 1, 0},
  {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0},
  {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0},
  {&__pyx_n_s_GDALEnv, __pyx_k_GDALEnv, sizeof(__pyx_k_GDALEnv), 0, 0, 1, 1},
  {&__pyx_n_s_GTiff, __pyx_k_GTiff, sizeof(__pyx_k_GTiff), 0, 0, 1, 1},
  {&__pyx_kp_s_Got_coordinate_system, __pyx_k_Got_coordinate_system, sizeof(__pyx_k_Got_coordinate_system), 0, 0, 1, 0},
  {&__pyx_n_s_Handler, __pyx_k_Handler, sizeof(__pyx_k_Handler), 0, 0, 1, 1},
  {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
  {&__pyx_kp_s_Invalid_band_index, __pyx_k_Invalid_band_index, sizeof(__pyx_k_Invalid_band_index), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_colormap_key_d, __pyx_k_Invalid_colormap_key_d, sizeof(__pyx_k_Invalid_colormap_key_d), 0, 0, 1, 0},
  {&__pyx_kp_s_Invalid_dtype, __pyx_k_Invalid_dtype, sizeof(__pyx_k_Invalid_dtype), 0, 0, 1, 0},
  {&__pyx_kp_s_NULL_band, __pyx_k_NULL_band, sizeof(__pyx_k_NULL_band), 0, 0, 1, 0},
  {&__pyx_kp_s_NULL_band_mask, __pyx_k_NULL_band_mask, sizeof(__pyx_k_NULL_band_mask), 0, 0, 1, 0},
  {&__pyx_kp_s_NULL_color_at_d_skipping, __pyx_k_NULL_color_at_d_skipping, sizeof(__pyx_k_NULL_color_at_d_skipping), 0, 0, 1, 0},
  {&__pyx_kp_s_NULL_color_table, __pyx_k_NULL_color_table, sizeof(__pyx_k_NULL_color_table), 0, 0, 1, 0},
  {&__pyx_kp_s_NULL_dataset, __pyx_k_NULL_dataset, sizeof(__pyx_k_NULL_dataset), 0, 0, 1, 0},
  {&__pyx_kp_s_NULL_driver_for_s, __pyx_k_NULL_driver_for_s, sizeof(__pyx_k_NULL_driver_for_s), 0, 0, 1, 0},
  {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0},
  {&__pyx_n_s_NullHandler, __pyx_k_NullHandler, sizeof(__pyx_k_NullHandler), 0, 0, 1, 1},
  {&__pyx_n_s_NullHandler_emit, __pyx_k_NullHandler_emit, sizeof(__pyx_k_NullHandler_emit), 0, 0, 1, 1},
  {&__pyx_kp_s_Null_band, __pyx_k_Null_band, sizeof(__pyx_k_Null_band), 0, 0, 1, 0},
  {&__pyx_kp_s_Null_dataset, __pyx_k_Null_dataset, sizeof(__pyx_k_Null_dataset), 0, 0, 1, 0},
  {&__pyx_kp_s_Null_projection, __pyx_k_Null_projection, sizeof(__pyx_k_Null_projection), 0, 0, 1, 0},
  {&__pyx_kp_s_Null_spatial_reference, __pyx_k_Null_spatial_reference, sizeof(__pyx_k_Null_spatial_reference), 0, 0, 1, 0},
  {&__pyx_kp_s_Option_r, __pyx_k_Option_r, sizeof(__pyx_k_Option_r), 0, 0, 1, 0},
  {&__pyx_kp_s_Params_s, __pyx_k_Params_s, sizeof(__pyx_k_Params_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Projection_not_found_cogr_crs_wa, __pyx_k_Projection_not_found_cogr_crs_wa, sizeof(__pyx_k_Projection_not_found_cogr_crs_wa), 0, 0, 1, 0},
  {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1},
  {&__pyx_kp_s_Unexpected_NULL_spatial_referenc, __pyx_k_Unexpected_NULL_spatial_referenc, sizeof(__pyx_k_Unexpected_NULL_spatial_referenc), 0, 0, 1, 0},
  {&__pyx_kp_s_Unexpected_Null_spatial_referenc, __pyx_k_Unexpected_Null_spatial_referenc, sizeof(__pyx_k_Unexpected_Null_spatial_referenc), 0, 0, 1, 0},
  {&__pyx_kp_s_Unexpected_proj_parameter_s, __pyx_k_Unexpected_proj_parameter_s, sizeof(__pyx_k_Unexpected_proj_parameter_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Unsupported_dtype_s, __pyx_k_Unsupported_dtype_s, sizeof(__pyx_k_Unsupported_dtype_s), 0, 0, 1, 0},
  {&__pyx_kp_s_Users_seang_code_rasterio_raste, __pyx_k_Users_seang_code_rasterio_raste, sizeof(__pyx_k_Users_seang_code_rasterio_raste), 0, 0, 1, 0},
  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
  {&__pyx_kp_s__11, __pyx_k__11, sizeof(__pyx_k__11), 0, 0, 1, 0},
  {&__pyx_kp_s__13, __pyx_k__13, sizeof(__pyx_k__13), 0, 0, 1, 0},
  {&__pyx_kp_s__53, __pyx_k__53, sizeof(__pyx_k__53), 0, 0, 1, 0},
  {&__pyx_n_s_a, __pyx_k_a, sizeof(__pyx_k_a), 0, 0, 1, 1},
  {&__pyx_n_s_addHandler, __pyx_k_addHandler, sizeof(__pyx_k_addHandler), 0, 0, 1, 1},
  {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
  {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1},
  {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
  {&__pyx_kp_s_band_index_out_of_range, __pyx_k_band_index_out_of_range, sizeof(__pyx_k_band_index_out_of_range), 0, 0, 1, 0},
  {&__pyx_n_s_bidx, __pyx_k_bidx, sizeof(__pyx_k_bidx), 0, 0, 1, 1},
  {&__pyx_n_s_block_shapes, __pyx_k_block_shapes, sizeof(__pyx_k_block_shapes), 0, 0, 1, 1},
  {&__pyx_n_s_bool, __pyx_k_bool, sizeof(__pyx_k_bool), 0, 0, 1, 1},
  {&__pyx_n_s_bounds, __pyx_k_bounds, sizeof(__pyx_k_bounds), 0, 0, 1, 1},
  {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
  {&__pyx_kp_s_can_t_read_closed_raster_file, __pyx_k_can_t_read_closed_raster_file, sizeof(__pyx_k_can_t_read_closed_raster_file), 0, 0, 1, 0},
  {&__pyx_kp_s_can_t_write_closed_raster_file, __pyx_k_can_t_write_closed_raster_file, sizeof(__pyx_k_can_t_write_closed_raster_file), 0, 0, 1, 0},
  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
  {&__pyx_n_s_closed, __pyx_k_closed, sizeof(__pyx_k_closed), 0, 0, 1, 1},
  {&__pyx_n_s_col, __pyx_k_col, sizeof(__pyx_k_col), 0, 0, 1, 1},
  {&__pyx_n_s_colormap, __pyx_k_colormap, sizeof(__pyx_k_colormap), 0, 0, 1, 1},
  {&__pyx_n_s_count, __pyx_k_count, sizeof(__pyx_k_count), 0, 0, 1, 1},
  {&__pyx_n_s_crs, __pyx_k_crs, sizeof(__pyx_k_crs), 0, 0, 1, 1},
  {&__pyx_n_s_crs_wkt, __pyx_k_crs_wkt, sizeof(__pyx_k_crs_wkt), 0, 0, 1, 1},
  {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1},
  {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  {&__pyx_n_s_driver, __pyx_k_driver, sizeof(__pyx_k_driver), 0, 0, 1, 1},
  {&__pyx_n_s_driver_count, __pyx_k_driver_count, sizeof(__pyx_k_driver_count), 0, 0, 1, 1},
  {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1},
  {&__pyx_n_s_dtype_fwd, __pyx_k_dtype_fwd, sizeof(__pyx_k_dtype_fwd), 0, 0, 1, 1},
  {&__pyx_n_s_dtype_rev, __pyx_k_dtype_rev, sizeof(__pyx_k_dtype_rev), 0, 0, 1, 1},
  {&__pyx_n_s_dtypes, __pyx_k_dtypes, sizeof(__pyx_k_dtypes), 0, 0, 1, 1},
  {&__pyx_n_s_emit, __pyx_k_emit, sizeof(__pyx_k_emit), 0, 0, 1, 1},
  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
  {&__pyx_n_s_exists, __pyx_k_exists, sizeof(__pyx_k_exists), 0, 0, 1, 1},
  {&__pyx_n_s_float32, __pyx_k_float32, sizeof(__pyx_k_float32), 0, 0, 1, 1},
  {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1},
  {&__pyx_n_s_genexpr, __pyx_k_genexpr, sizeof(__pyx_k_genexpr), 0, 0, 1, 1},
  {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
  {&__pyx_n_s_getLogger, __pyx_k_getLogger, sizeof(__pyx_k_getLogger), 0, 0, 1, 1},
  {&__pyx_n_s_get_crs, __pyx_k_get_crs, sizeof(__pyx_k_get_crs), 0, 0, 1, 1},
  {&__pyx_n_s_get_crs_wkt, __pyx_k_get_crs_wkt, sizeof(__pyx_k_get_crs_wkt), 0, 0, 1, 1},
  {&__pyx_n_s_get_transform, __pyx_k_get_transform, sizeof(__pyx_k_get_transform), 0, 0, 1, 1},
  {&__pyx_n_s_height, __pyx_k_height, sizeof(__pyx_k_height), 0, 0, 1, 1},
  {&__pyx_n_s_hex, __pyx_k_hex, sizeof(__pyx_k_hex), 0, 0, 1, 1},
  {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1},
  {&__pyx_n_s_indexes, __pyx_k_indexes, sizeof(__pyx_k_indexes), 0, 0, 1, 1},
  {&__pyx_n_s_info, __pyx_k_info, sizeof(__pyx_k_info), 0, 0, 1, 1},
  {&__pyx_n_s_int16, __pyx_k_int16, sizeof(__pyx_k_int16), 0, 0, 1, 1},
  {&__pyx_n_s_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 0, 1, 1},
  {&__pyx_kp_s_invalid_height_d, __pyx_k_invalid_height_d, sizeof(__pyx_k_invalid_height_d), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_width_d, __pyx_k_invalid_width_d, sizeof(__pyx_k_invalid_width_d), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_window_col_range_d_d, __pyx_k_invalid_window_col_range_d_d, sizeof(__pyx_k_invalid_window_col_range_d_d), 0, 0, 1, 0},
  {&__pyx_kp_s_invalid_window_row_range_d_d, __pyx_k_invalid_window_row_range_d_d, sizeof(__pyx_k_invalid_window_row_range_d_d), 0, 0, 1, 0},
  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
  {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
  {&__pyx_n_s_log, __pyx_k_log, sizeof(__pyx_k_log), 0, 0, 1, 1},
  {&__pyx_n_s_logging, __pyx_k_logging, sizeof(__pyx_k_logging), 0, 0, 1, 1},
  {&__pyx_n_s_lstrip, __pyx_k_lstrip, sizeof(__pyx_k_lstrip), 0, 0, 1, 1},
  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  {&__pyx_n_s_math, __pyx_k_math, sizeof(__pyx_k_math), 0, 0, 1, 1},
  {&__pyx_n_s_meta, __pyx_k_meta, sizeof(__pyx_k_meta), 0, 0, 1, 1},
  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0},
  {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0},
  {&__pyx_n_s_no_defs, __pyx_k_no_defs, sizeof(__pyx_k_no_defs), 0, 0, 1, 1},
  {&__pyx_n_s_nodata, __pyx_k_nodata, sizeof(__pyx_k_nodata), 0, 0, 1, 1},
  {&__pyx_n_s_nodatavals, __pyx_k_nodatavals, sizeof(__pyx_k_nodatavals), 0, 0, 1, 1},
  {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1},
  {&__pyx_n_s_ns, __pyx_k_ns, sizeof(__pyx_k_ns), 0, 0, 1, 1},
  {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1},
  {&__pyx_kp_s_only_GTiffs_can_be_opened_in_w_m, __pyx_k_only_GTiffs_can_be_opened_in_w_m, sizeof(__pyx_k_only_GTiffs_can_be_opened_in_w_m), 0, 0, 1, 0},
  {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1},
  {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
  {&__pyx_n_s_os_path, __pyx_k_os_path, sizeof(__pyx_k_os_path), 0, 0, 1, 1},
  {&__pyx_n_s_out, __pyx_k_out, sizeof(__pyx_k_out), 0, 0, 1, 1},
  {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  {&__pyx_n_s_property, __pyx_k_property, sizeof(__pyx_k_property), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_releasebuffer, __pyx_k_pyx_releasebuffer, sizeof(__pyx_k_pyx_releasebuffer), 0, 0, 1, 1},
  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
  {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  {&__pyx_n_s_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 0, 1, 1},
  {&__pyx_kp_s_r_2, __pyx_k_r_2, sizeof(__pyx_k_r_2), 0, 0, 1, 0},
  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  {&__pyx_n_s_rasterio, __pyx_k_rasterio, sizeof(__pyx_k_rasterio), 0, 0, 1, 1},
  {&__pyx_n_s_rasterio__drivers, __pyx_k_rasterio__drivers, sizeof(__pyx_k_rasterio__drivers), 0, 0, 1, 1},
  {&__pyx_n_s_rasterio__io, __pyx_k_rasterio__io, sizeof(__pyx_k_rasterio__io), 0, 0, 1, 1},
  {&__pyx_n_s_rasterio_five, __pyx_k_rasterio_five, sizeof(__pyx_k_rasterio_five), 0, 0, 1, 1},
  {&__pyx_n_s_read_crs, __pyx_k_read_crs, sizeof(__pyx_k_read_crs), 0, 0, 1, 1},
  {&__pyx_n_s_read_crs_wkt, __pyx_k_read_crs_wkt, sizeof(__pyx_k_read_crs_wkt), 0, 0, 1, 1},
  {&__pyx_n_s_read_transform, __pyx_k_read_transform, sizeof(__pyx_k_read_transform), 0, 0, 1, 1},
  {&__pyx_n_s_record, __pyx_k_record, sizeof(__pyx_k_record), 0, 0, 1, 1},
  {&__pyx_n_s_res, __pyx_k_res, sizeof(__pyx_k_res), 0, 0, 1, 1},
  {&__pyx_n_s_row, __pyx_k_row, sizeof(__pyx_k_row), 0, 0, 1, 1},
  {&__pyx_kp_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_RasterReader_s_at_s, __pyx_k_s_RasterReader_s_at_s, sizeof(__pyx_k_s_RasterReader_s_at_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_RasterUpdater_s_at_s, __pyx_k_s_RasterUpdater_s_at_s, sizeof(__pyx_k_s_RasterUpdater_s_at_s), 0, 0, 1, 0},
  {&__pyx_kp_s_s_s, __pyx_k_s_s, sizeof(__pyx_k_s_s), 0, 0, 1, 0},
  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
  {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
  {&__pyx_n_s_sqrt, __pyx_k_sqrt, sizeof(__pyx_k_sqrt), 0, 0, 1, 1},
  {&__pyx_n_s_src, __pyx_k_src, sizeof(__pyx_k_src), 0, 0, 1, 1},
  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
  {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
  {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  {&__pyx_n_s_text_type, __pyx_k_text_type, sizeof(__pyx_k_text_type), 0, 0, 1, 1},
  {&__pyx_kp_s_the_array_s_dtype_s_does_not_mat, __pyx_k_the_array_s_dtype_s_does_not_mat, sizeof(__pyx_k_the_array_s_dtype_s_does_not_mat), 0, 0, 1, 0},
  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
  {&__pyx_n_s_traceback, __pyx_k_traceback, sizeof(__pyx_k_traceback), 0, 0, 1, 1},
  {&__pyx_n_s_transform, __pyx_k_transform, sizeof(__pyx_k_transform), 0, 0, 1, 1},
  {&__pyx_n_s_type, __pyx_k_type, sizeof(__pyx_k_type), 0, 0, 1, 1},
  {&__pyx_n_s_ubyte, __pyx_k_ubyte, sizeof(__pyx_k_ubyte), 0, 0, 1, 1},
  {&__pyx_n_s_uint16, __pyx_k_uint16, sizeof(__pyx_k_uint16), 0, 0, 1, 1},
  {&__pyx_n_s_uint32, __pyx_k_uint32, sizeof(__pyx_k_uint32), 0, 0, 1, 1},
  {&__pyx_n_s_uint8, __pyx_k_uint8, sizeof(__pyx_k_uint8), 0, 0, 1, 1},
  {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0},
  {&__pyx_n_s_unlink, __pyx_k_unlink, sizeof(__pyx_k_unlink), 0, 0, 1, 1},
  {&__pyx_n_s_upper, __pyx_k_upper, sizeof(__pyx_k_upper), 0, 0, 1, 1},
  {&__pyx_kp_s_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 0, 1, 0},
  {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  {&__pyx_n_s_w, __pyx_k_w, sizeof(__pyx_k_w), 0, 0, 1, 1},
  {&__pyx_n_s_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 0, 0, 1, 1},
  {&__pyx_n_s_width, __pyx_k_width, sizeof(__pyx_k_width), 0, 0, 1, 1},
  {&__pyx_n_s_window, __pyx_k_window, sizeof(__pyx_k_window), 0, 0, 1, 1},
  {&__pyx_n_s_window_index, __pyx_k_window_index, sizeof(__pyx_k_window_index), 0, 0, 1, 1},
  {&__pyx_n_s_window_shape, __pyx_k_window_shape, sizeof(__pyx_k_window_shape), 0, 0, 1, 1},
  {&__pyx_n_s_write_crs, __pyx_k_write_crs, sizeof(__pyx_k_write_crs), 0, 0, 1, 1},
  {&__pyx_n_s_write_transform, __pyx_k_write_transform, sizeof(__pyx_k_write_transform), 0, 0, 1, 1},
  {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1},
  {&__pyx_n_s_y, __pyx_k_y, sizeof(__pyx_k_y), 0, 0, 1, 1},
  {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_property = __Pyx_GetBuiltinName(__pyx_n_s_property); if (!__pyx_builtin_property) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_hex = __Pyx_GetBuiltinName(__pyx_n_s_hex); if (!__pyx_builtin_hex) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "rasterio/_io.pyx":183
 *         if driver_count() == 0 and not self.env:
 *             # create a local manager and enter
 *             self.env = GDALEnv(True)             # <<<<<<<<<<<<<<
 *         else:
 *             # create a local manager and enter
 */
  __pyx_tuple_ = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple_);
  __Pyx_GIVEREF(__pyx_tuple_);

  /* "rasterio/_io.pyx":186
 *         else:
 *             # create a local manager and enter
 *             self.env = GDALEnv(False)             # <<<<<<<<<<<<<<
 *         self.env.start()
 * 
 */
  __pyx_tuple__2 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);

  /* "rasterio/_io.pyx":189
 *         self.env.start()
 * 
 *         name_b = self.name.encode('utf-8')             # <<<<<<<<<<<<<<
 *         cdef const char *fname = name_b
 *         self._hds = _gdal.GDALOpen(fname, 0)
 */
  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_utf_8); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__3);
  __Pyx_GIVEREF(__pyx_tuple__3);

  /* "rasterio/_io.pyx":193
 *         self._hds = _gdal.GDALOpen(fname, 0)
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")             # <<<<<<<<<<<<<<
 * 
 *         cdef void *drv
 */
  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_Null_dataset); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);

  /* "rasterio/_io.pyx":217
 *     cdef void *band(self, int bidx):
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")             # <<<<<<<<<<<<<<
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 *         if hband == NULL:
 */
  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_Null_dataset); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__5);
  __Pyx_GIVEREF(__pyx_tuple__5);

  /* "rasterio/_io.pyx":220
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 *         if hband == NULL:
 *             raise ValueError("Null band")             # <<<<<<<<<<<<<<
 *         return hband
 * 
 */
  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Null_band); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__6);
  __Pyx_GIVEREF(__pyx_tuple__6);

  /* "rasterio/_io.pyx":227
 *         cdef void *osr = NULL
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")             # <<<<<<<<<<<<<<
 *         crs = {}
 *         cdef const char *proj = _gdal.GDALGetProjectionRef(self._hds)
 */
  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_Null_dataset); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);

  /* "rasterio/_io.pyx":234
 *             osr = _gdal.OSRNewSpatialReference(proj)
 *             if osr == NULL:
 *                 raise ValueError("Unexpected NULL spatial reference")             # <<<<<<<<<<<<<<
 *             log.debug("Got coordinate system")
 *             _gdal.OSRExportToProj4(osr, &proj_c)
 */
  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_Unexpected_NULL_spatial_referenc); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__8);
  __Pyx_GIVEREF(__pyx_tuple__8);

  /* "rasterio/_io.pyx":235
 *             if osr == NULL:
 *                 raise ValueError("Unexpected NULL spatial reference")
 *             log.debug("Got coordinate system")             # <<<<<<<<<<<<<<
 *             _gdal.OSRExportToProj4(osr, &proj_c)
 *             if proj_c == NULL:
 */
  __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_Got_coordinate_system); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);

  /* "rasterio/_io.pyx":238
 *             _gdal.OSRExportToProj4(osr, &proj_c)
 *             if proj_c == NULL:
 *                 raise ValueError("Unexpected Null spatial reference")             # <<<<<<<<<<<<<<
 *             proj_b = proj_c
 *             log.debug("Params: %s", proj_b)
 */
  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Unexpected_Null_spatial_referenc); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__10);
  __Pyx_GIVEREF(__pyx_tuple__10);

  /* "rasterio/_io.pyx":244
 *             value = value.strip()
 *             for param in value.split():
 *                 kv = param.split("=")             # <<<<<<<<<<<<<<
 *                 if len(kv) == 2:
 *                     k, v = kv
 */
  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s__11); if (unlikely(!__pyx_tuple__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);

  /* "rasterio/_io.pyx":258
 *                 else:
 *                     raise ValueError("Unexpected proj parameter %s" % param)
 *                 k = k.lstrip("+")             # <<<<<<<<<<<<<<
 *                 crs[k] = v
 *             _gdal.CPLFree(proj_c)
 */
  __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s__13); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 258; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);

  /* "rasterio/_io.pyx":263
 *             _gdal.OSRDestroySpatialReference(osr)
 *         else:
 *             log.debug("Projection not found (cogr_crs was NULL)")             # <<<<<<<<<<<<<<
 *         return crs
 * 
 */
  __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_Projection_not_found_cogr_crs_wa); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__15);
  __Pyx_GIVEREF(__pyx_tuple__15);

  /* "rasterio/_io.pyx":269
 *         cdef char *proj_c = NULL
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")             # <<<<<<<<<<<<<<
 *         cdef void *osr = _gdal.OSRNewSpatialReference(
 *             _gdal.GDALGetProjectionRef(self._hds))
 */
  __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Null_dataset); if (unlikely(!__pyx_tuple__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__16);
  __Pyx_GIVEREF(__pyx_tuple__16);

  /* "rasterio/_io.pyx":272
 *         cdef void *osr = _gdal.OSRNewSpatialReference(
 *             _gdal.GDALGetProjectionRef(self._hds))
 *         log.debug("Got coordinate system")             # <<<<<<<<<<<<<<
 *         crs = {}
 *         if osr != NULL:
 */
  __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_Got_coordinate_system); if (unlikely(!__pyx_tuple__17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__17);
  __Pyx_GIVEREF(__pyx_tuple__17);

  /* "rasterio/_io.pyx":277
 *             _gdal.OSRExportToWkt(osr, &proj_c)
 *             if proj_c == NULL:
 *                 raise ValueError("Null projection")             # <<<<<<<<<<<<<<
 *             proj_b = proj_c
 *             crs_wkt = proj_b.decode('utf-8')
 */
  __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_Null_projection); if (unlikely(!__pyx_tuple__18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);

  /* "rasterio/_io.pyx":283
 *             _gdal.OSRDestroySpatialReference(osr)
 *         else:
 *             log.debug("Projection not found (cogr_crs was NULL)")             # <<<<<<<<<<<<<<
 *         return crs_wkt
 * 
 */
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_Projection_not_found_cogr_crs_wa); if (unlikely(!__pyx_tuple__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);

  /* "rasterio/_io.pyx":288
 *     def read_transform(self):
 *         if self._hds == NULL:
 *             raise ValueError("Null dataset")             # <<<<<<<<<<<<<<
 *         cdef double gt[6]
 *         _gdal.GDALGetGeoTransform(self._hds, gt)
 */
  __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_Null_dataset); if (unlikely(!__pyx_tuple__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__20);
  __Pyx_GIVEREF(__pyx_tuple__20);

  /* "rasterio/_io.pyx":326
 *         if not self._count:
 *             if self._hds == NULL:
 *                 raise ValueError("Can't read closed raster file")             # <<<<<<<<<<<<<<
 *             self._count = _gdal.GDALGetRasterCount(self._hds)
 *         return self._count
 */
  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_Can_t_read_closed_raster_file); if (unlikely(!__pyx_tuple__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);

  /* "rasterio/_io.pyx":340
 *         if not self._dtypes:
 *             if self._hds == NULL:
 *                 raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *             for i in range(self._count):
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 */
  __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_can_t_read_closed_raster_file); if (unlikely(!__pyx_tuple__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__22);
  __Pyx_GIVEREF(__pyx_tuple__22);

  /* "rasterio/_io.pyx":358
 *         if not self._block_shapes:
 *             if self._hds == NULL:
 *                 raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *             for i in range(self._count):
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 */
  __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_can_t_read_closed_raster_file); if (unlikely(!__pyx_tuple__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);

  /* "rasterio/_io.pyx":362
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                 if hband == NULL:
 *                     raise ValueError("Null band")             # <<<<<<<<<<<<<<
 *                 _gdal.GDALGetBlockSize(hband, &xsize, &ysize)
 *                 self._block_shapes.append((ysize, xsize))
 */
  __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_Null_band); if (unlikely(!__pyx_tuple__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__24);
  __Pyx_GIVEREF(__pyx_tuple__24);

  /* "rasterio/_io.pyx":375
 *         if not self._nodatavals:
 *             if self._hds == NULL:
 *                 raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *             for i in range(self._count):
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 */
  __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_can_t_read_closed_raster_file); if (unlikely(!__pyx_tuple__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);

  /* "rasterio/_io.pyx":379
 *                 hband = _gdal.GDALGetRasterBand(self._hds, i+1)
 *                 if hband == NULL:
 *                     raise ValueError("Null band")             # <<<<<<<<<<<<<<
 *                 val = _gdal.GDALGetRasterNoDataValue(hband, &success)
 *                 if not success:
 */
  __pyx_tuple__26 = PyTuple_Pack(1, __pyx_kp_s_Null_band); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__26);
  __Pyx_GIVEREF(__pyx_tuple__26);

  /* "rasterio/_io.pyx":515
 *         """
 *         if bidx not in self.indexes:
 *             raise IndexError("band index out of range")             # <<<<<<<<<<<<<<
 *         i = self.indexes.index(bidx)
 *         if self._hds == NULL:
 */
  __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_s_band_index_out_of_range); if (unlikely(!__pyx_tuple__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);

  /* "rasterio/_io.pyx":518
 *         i = self.indexes.index(bidx)
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *         if out is not None and out.dtype != self.dtypes[i]:
 *             raise ValueError(
 */
  __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_can_t_read_closed_raster_file); if (unlikely(!__pyx_tuple__28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__28);
  __Pyx_GIVEREF(__pyx_tuple__28);

  /* "rasterio/_io.pyx":526
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 *         if hband == NULL:
 *             raise ValueError("NULL band")             # <<<<<<<<<<<<<<
 * 
 *         dtype = self.dtypes[i]
 */
  __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_NULL_band); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);

  /* "rasterio/_io.pyx":567
 *                 hband, 0, xoff, yoff, width, height, out)
 *         else:
 *             raise ValueError("Invalid dtype")             # <<<<<<<<<<<<<<
 *         # TODO: handle errors (by retval).
 * 
 */
  __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_Invalid_dtype); if (unlikely(!__pyx_tuple__30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);

  /* "rasterio/_io.pyx":590
 *         cdef char **papszStrList
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 */
  __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_can_t_read_closed_raster_file); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);

  /* "rasterio/_io.pyx":593
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")             # <<<<<<<<<<<<<<
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hobj == NULL:
 */
  __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_Invalid_band_index); if (unlikely(!__pyx_tuple__32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__32);
  __Pyx_GIVEREF(__pyx_tuple__32);

  /* "rasterio/_io.pyx":596
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hobj == NULL:
 *                 raise ValueError("NULL band")             # <<<<<<<<<<<<<<
 *         else:
 *             hobj = self._hds
 */
  __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_NULL_band); if (unlikely(!__pyx_tuple__33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);

  /* "rasterio/_io.pyx":600
 *             hobj = self._hds
 *         if ns:
 *             domain_b = ns.encode('utf-8')             # <<<<<<<<<<<<<<
 *             domain_c = domain_b
 *         else:
 */
  __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_s_utf_8); if (unlikely(!__pyx_tuple__34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__34);
  __Pyx_GIVEREF(__pyx_tuple__34);

  /* "rasterio/_io.pyx":611
 *             item_b = item_c
 *             item = item_b.decode('utf-8')
 *             key, value = item.split('=')             # <<<<<<<<<<<<<<
 *             retval[key] = value
 *         return retval
 */
  __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_s__11); if (unlikely(!__pyx_tuple__35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);

  /* "rasterio/_io.pyx":622
 *         cdef _gdal.GDALColorEntry *color
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 */
  __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_s_can_t_read_closed_raster_file); if (unlikely(!__pyx_tuple__36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__36);
  __Pyx_GIVEREF(__pyx_tuple__36);

  /* "rasterio/_io.pyx":625
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")             # <<<<<<<<<<<<<<
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hBand == NULL:
 */
  __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_s_Invalid_band_index); if (unlikely(!__pyx_tuple__37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);

  /* "rasterio/_io.pyx":628
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hBand == NULL:
 *                 raise ValueError("NULL band")             # <<<<<<<<<<<<<<
 *         hTable = _gdal.GDALGetRasterColorTable(hBand)
 *         if hTable == NULL:
 */
  __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_s_NULL_band); if (unlikely(!__pyx_tuple__38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__38);
  __Pyx_GIVEREF(__pyx_tuple__38);

  /* "rasterio/_io.pyx":631
 *         hTable = _gdal.GDALGetRasterColorTable(hBand)
 *         if hTable == NULL:
 *             raise ValueError("NULL color table")             # <<<<<<<<<<<<<<
 *         retval = {}
 * 
 */
  __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_s_NULL_color_table); if (unlikely(!__pyx_tuple__39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);

  /* "rasterio/_io.pyx":657
 *         cdef void *hmask
 *         if self._hds == NULL:
 *             raise ValueError("can't write closed raster file")             # <<<<<<<<<<<<<<
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)
 *         if hband == NULL:
 */
  __pyx_tuple__40 = PyTuple_Pack(1, __pyx_kp_s_can_t_write_closed_raster_file); if (unlikely(!__pyx_tuple__40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__40);
  __Pyx_GIVEREF(__pyx_tuple__40);

  /* "rasterio/_io.pyx":660
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)
 *         if hband == NULL:
 *             raise ValueError("NULL band mask")             # <<<<<<<<<<<<<<
 *         hmask = _gdal.GDALGetMaskBand(hband)
 *         if hmask == NULL:
 */
  __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_s_NULL_band_mask); if (unlikely(!__pyx_tuple__41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);

  /* "rasterio/_io.pyx":724
 *         cdef void *hband = NULL
 *         cdef int success
 *         name_b = self.name.encode('utf-8')             # <<<<<<<<<<<<<<
 *         cdef const char *fname = name_b
 * 
 */
  __pyx_tuple__42 = PyTuple_Pack(1, __pyx_kp_s_utf_8); if (unlikely(!__pyx_tuple__42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);

  /* "rasterio/_io.pyx":730
 *         if driver_count() == 0 and not self.env:
 *             # create a local manager and enter
 *             self.env = GDALEnv(True)             # <<<<<<<<<<<<<<
 *         else:
 *             self.env = GDALEnv(False)
 */
  __pyx_tuple__43 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);

  /* "rasterio/_io.pyx":732
 *             self.env = GDALEnv(True)
 *         else:
 *             self.env = GDALEnv(False)             # <<<<<<<<<<<<<<
 *         self.env.start()
 * 
 */
  __pyx_tuple__44 = PyTuple_Pack(1, Py_False); if (unlikely(!__pyx_tuple__44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__44);
  __Pyx_GIVEREF(__pyx_tuple__44);

  /* "rasterio/_io.pyx":739
 *             # CreateCopy(). Rasterio lets you write GTiffs *only* for now.
 *             if self.driver not in ['GTiff']:
 *                 raise ValueError("only GTiffs can be opened in 'w' mode")             # <<<<<<<<<<<<<<
 * 
 *             # Delete existing file, create.
 */
  __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_s_only_GTiffs_can_be_opened_in_w_m); if (unlikely(!__pyx_tuple__45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__45);
  __Pyx_GIVEREF(__pyx_tuple__45);

  /* "rasterio/_io.pyx":745
 *                 os.unlink(self.name)
 * 
 *             driver_b = self.driver.encode('utf-8')             # <<<<<<<<<<<<<<
 *             drv_name = driver_b
 *             drv = _gdal.GDALGetDriverByName(drv_name)
 */
  __pyx_tuple__46 = PyTuple_Pack(1, __pyx_kp_s_utf_8); if (unlikely(!__pyx_tuple__46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);

  /* "rasterio/_io.pyx":767
 *             for k, v in self._options.items():
 *                 k, v = k.upper(), v.upper()
 *                 key_b = k.encode('utf-8')             # <<<<<<<<<<<<<<
 *                 val_b = v.encode('utf-8')
 *                 key_c = key_b
 */
  __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_s_utf_8); if (unlikely(!__pyx_tuple__47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);

  /* "rasterio/_io.pyx":768
 *                 k, v = k.upper(), v.upper()
 *                 key_b = k.encode('utf-8')
 *                 val_b = v.encode('utf-8')             # <<<<<<<<<<<<<<
 *                 key_c = key_b
 *                 val_c = val_b
 */
  __pyx_tuple__48 = PyTuple_Pack(1, __pyx_kp_s_utf_8); if (unlikely(!__pyx_tuple__48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__48);
  __Pyx_GIVEREF(__pyx_tuple__48);

  /* "rasterio/_io.pyx":778
 *                 gdal_dtype, options)
 *             if self._hds == NULL:
 *                 raise ValueError("NULL dataset")             # <<<<<<<<<<<<<<
 * 
 *             if self._init_nodata is not None:
 */
  __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_s_NULL_dataset); if (unlikely(!__pyx_tuple__49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);

  /* "rasterio/_io.pyx":794
 *             self._hds = _gdal.GDALOpen(fname, 1)
 *             if self._hds == NULL:
 *                 raise ValueError("NULL dataset")             # <<<<<<<<<<<<<<
 * 
 *         drv = _gdal.GDALGetDatasetDriver(self._hds)
 */
  __pyx_tuple__50 = PyTuple_Pack(1, __pyx_kp_s_NULL_dataset); if (unlikely(!__pyx_tuple__50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);

  /* "rasterio/_io.pyx":824
 *     def write_crs(self, crs):
 *         if self._hds == NULL:
 *             raise ValueError("Can't read closed raster file")             # <<<<<<<<<<<<<<
 *         cdef void *osr = _gdal.OSRNewSpatialReference(NULL)
 *         if osr == NULL:
 */
  __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_s_Can_t_read_closed_raster_file); if (unlikely(!__pyx_tuple__51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__51);
  __Pyx_GIVEREF(__pyx_tuple__51);

  /* "rasterio/_io.pyx":827
 *         cdef void *osr = _gdal.OSRNewSpatialReference(NULL)
 *         if osr == NULL:
 *             raise ValueError("Null spatial reference")             # <<<<<<<<<<<<<<
 *         params = []
 *         for k, v in crs.items():
 */
  __pyx_tuple__52 = PyTuple_Pack(1, __pyx_kp_s_Null_spatial_reference); if (unlikely(!__pyx_tuple__52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);

  /* "rasterio/_io.pyx":850
 *     def write_transform(self, transform):
 *         if self._hds == NULL:
 *             raise ValueError("Can't read closed raster file")             # <<<<<<<<<<<<<<
 *         cdef double gt[6]
 *         for i in range(6):
 */
  __pyx_tuple__54 = PyTuple_Pack(1, __pyx_kp_s_Can_t_read_closed_raster_file); if (unlikely(!__pyx_tuple__54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);

  /* "rasterio/_io.pyx":876
 *         """
 *         if bidx not in self.indexes:
 *             raise IndexError("band index out of range")             # <<<<<<<<<<<<<<
 *         i = self.indexes.index(bidx)
 *         if self._hds == NULL:
 */
  __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_s_band_index_out_of_range); if (unlikely(!__pyx_tuple__55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__55);
  __Pyx_GIVEREF(__pyx_tuple__55);

  /* "rasterio/_io.pyx":879
 *         i = self.indexes.index(bidx)
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *         if src is not None and src.dtype != self.dtypes[i]:
 *             raise ValueError(
 */
  __pyx_tuple__56 = PyTuple_Pack(1, __pyx_kp_s_can_t_read_closed_raster_file); if (unlikely(!__pyx_tuple__56)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_GIVEREF(__pyx_tuple__56);

  /* "rasterio/_io.pyx":887
 *         cdef void *hband = _gdal.GDALGetRasterBand(self._hds, bidx)
 *         if hband == NULL:
 *             raise ValueError("NULL band")             # <<<<<<<<<<<<<<
 * 
 *         if window:
 */
  __pyx_tuple__57 = PyTuple_Pack(1, __pyx_kp_s_NULL_band); if (unlikely(!__pyx_tuple__57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__57);
  __Pyx_GIVEREF(__pyx_tuple__57);

  /* "rasterio/_io.pyx":922
 *                 hband, 1, xoff, yoff, width, height, src)
 *         else:
 *             raise ValueError("Invalid dtype")             # <<<<<<<<<<<<<<
 *         # TODO: handle errors (by retval).
 * 
 */
  __pyx_tuple__58 = PyTuple_Pack(1, __pyx_kp_s_Invalid_dtype); if (unlikely(!__pyx_tuple__58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);

  /* "rasterio/_io.pyx":941
 *         cdef const char *domain_c
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 */
  __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_s_can_t_read_closed_raster_file); if (unlikely(!__pyx_tuple__59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__59);
  __Pyx_GIVEREF(__pyx_tuple__59);

  /* "rasterio/_io.pyx":944
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")             # <<<<<<<<<<<<<<
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hobj == NULL:
 */
  __pyx_tuple__60 = PyTuple_Pack(1, __pyx_kp_s_Invalid_band_index); if (unlikely(!__pyx_tuple__60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__60);
  __Pyx_GIVEREF(__pyx_tuple__60);

  /* "rasterio/_io.pyx":947
 *             hobj = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hobj == NULL:
 *                 raise ValueError("NULL band")             # <<<<<<<<<<<<<<
 *         else:
 *             hobj = self._hds
 */
  __pyx_tuple__61 = PyTuple_Pack(1, __pyx_kp_s_NULL_band); if (unlikely(!__pyx_tuple__61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);

  /* "rasterio/_io.pyx":951
 *             hobj = self._hds
 *         if ns:
 *             domain_b = ns.encode('utf-8')             # <<<<<<<<<<<<<<
 *             domain_c = domain_b
 *         else:
 */
  __pyx_tuple__62 = PyTuple_Pack(1, __pyx_kp_s_utf_8); if (unlikely(!__pyx_tuple__62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__62);
  __Pyx_GIVEREF(__pyx_tuple__62);

  /* "rasterio/_io.pyx":957
 *         cdef char **papszStrList = _gdal.GDALGetMetadata(hobj, domain_c)
 *         for key, value in kwargs.items():
 *             key_b = text_type(key).encode('utf-8')             # <<<<<<<<<<<<<<
 *             value_b = text_type(value).encode('utf-8')
 *             key_c = key_b
 */
  __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_s_utf_8); if (unlikely(!__pyx_tuple__63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);

  /* "rasterio/_io.pyx":958
 *         for key, value in kwargs.items():
 *             key_b = text_type(key).encode('utf-8')
 *             value_b = text_type(value).encode('utf-8')             # <<<<<<<<<<<<<<
 *             key_c = key_b
 *             value_c = value_b
 */
  __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_s_utf_8); if (unlikely(!__pyx_tuple__64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__64);
  __Pyx_GIVEREF(__pyx_tuple__64);

  /* "rasterio/_io.pyx":974
 *         cdef _gdal.GDALColorEntry color
 *         if self._hds == NULL:
 *             raise ValueError("can't read closed raster file")             # <<<<<<<<<<<<<<
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 */
  __pyx_tuple__65 = PyTuple_Pack(1, __pyx_kp_s_can_t_read_closed_raster_file); if (unlikely(!__pyx_tuple__65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__65);
  __Pyx_GIVEREF(__pyx_tuple__65);

  /* "rasterio/_io.pyx":977
 *         if bidx > 0:
 *             if bidx not in self.indexes:
 *                 raise ValueError("Invalid band index")             # <<<<<<<<<<<<<<
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hBand == NULL:
 */
  __pyx_tuple__66 = PyTuple_Pack(1, __pyx_kp_s_Invalid_band_index); if (unlikely(!__pyx_tuple__66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);

  /* "rasterio/_io.pyx":980
 *             hBand = _gdal.GDALGetRasterBand(self._hds, bidx)
 *             if hBand == NULL:
 *                 raise ValueError("NULL band")             # <<<<<<<<<<<<<<
 *         # RGB only for now. TODO: the other types.
 *         # GPI_Gray=0,  GPI_RGB=1, GPI_CMYK=2,     GPI_HLS=3
 */
  __pyx_tuple__67 = PyTuple_Pack(1, __pyx_kp_s_NULL_band); if (unlikely(!__pyx_tuple__67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__67);
  __Pyx_GIVEREF(__pyx_tuple__67);

  /* "rasterio/_io.pyx":984
 *         # GPI_Gray=0,  GPI_RGB=1, GPI_CMYK=2,     GPI_HLS=3
 *         hTable = _gdal.GDALCreateColorTable(1)
 *         vals = range(256)             # <<<<<<<<<<<<<<
 *         for i, rgba in colormap.items():
 *             if i not in vals:
 */
  __pyx_tuple__68 = PyTuple_Pack(1, __pyx_int_256); if (unlikely(!__pyx_tuple__68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__68);
  __Pyx_GIVEREF(__pyx_tuple__68);

  /* "rasterio/_io.pyx":1009
 *         cdef void *hmask
 *         if self._hds == NULL:
 *             raise ValueError("can't write closed raster file")             # <<<<<<<<<<<<<<
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)
 *         if hband == NULL:
 */
  __pyx_tuple__69 = PyTuple_Pack(1, __pyx_kp_s_can_t_write_closed_raster_file); if (unlikely(!__pyx_tuple__69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__69);
  __Pyx_GIVEREF(__pyx_tuple__69);

  /* "rasterio/_io.pyx":1012
 *         hband = _gdal.GDALGetRasterBand(self._hds, 1)
 *         if hband == NULL:
 *             raise ValueError("NULL band mask")             # <<<<<<<<<<<<<<
 *         if _gdal.GDALCreateMaskBand(hband, 0x02) != 0:
 *             raise RuntimeError("Failed to create mask")
 */
  __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_s_NULL_band_mask); if (unlikely(!__pyx_tuple__70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__70);
  __Pyx_GIVEREF(__pyx_tuple__70);

  /* "rasterio/_io.pyx":1014
 *             raise ValueError("NULL band mask")
 *         if _gdal.GDALCreateMaskBand(hband, 0x02) != 0:
 *             raise RuntimeError("Failed to create mask")             # <<<<<<<<<<<<<<
 *         hmask = _gdal.GDALGetMaskBand(hband)
 *         if hmask == NULL:
 */
  __pyx_tuple__71 = PyTuple_Pack(1, __pyx_kp_s_Failed_to_create_mask); if (unlikely(!__pyx_tuple__71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__71);
  __Pyx_GIVEREF(__pyx_tuple__71);

  /* "rasterio/_io.pyx":1017
 *         hmask = _gdal.GDALGetMaskBand(hband)
 *         if hmask == NULL:
 *             raise ValueError("NULL band mask")             # <<<<<<<<<<<<<<
 *         log.debug("Created mask band")
 *         if window:
 */
  __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_s_NULL_band_mask); if (unlikely(!__pyx_tuple__72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__72);
  __Pyx_GIVEREF(__pyx_tuple__72);

  /* "rasterio/_io.pyx":1018
 *         if hmask == NULL:
 *             raise ValueError("NULL band mask")
 *         log.debug("Created mask band")             # <<<<<<<<<<<<<<
 *         if window:
 *             window = eval_window(window, self.height, self.width)
 */
  __pyx_tuple__73 = PyTuple_Pack(1, __pyx_kp_s_Created_mask_band); if (unlikely(!__pyx_tuple__73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_GIVEREF(__pyx_tuple__73);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":215
 *             if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not C contiguous")             # <<<<<<<<<<<<<<
 * 
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 */
  __pyx_tuple__74 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__74)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__74);
  __Pyx_GIVEREF(__pyx_tuple__74);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":219
 *             if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS)
 *                 and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)):
 *                 raise ValueError(u"ndarray is not Fortran contiguous")             # <<<<<<<<<<<<<<
 * 
 *             info.buf = PyArray_DATA(self)
 */
  __pyx_tuple__75 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__75)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__75);
  __Pyx_GIVEREF(__pyx_tuple__75);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":257
 *                 if ((descr.byteorder == c'>' and little_endian) or
 *                     (descr.byteorder == c'<' and not little_endian)):
 *                     raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *                 if   t == NPY_BYTE:        f = "b"
 *                 elif t == NPY_UBYTE:       f = "B"
 */
  __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__76)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":799
 * 
 *         if (end - f) - <int>(new_offset - offset[0]) < 15:
 *             raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd")             # <<<<<<<<<<<<<<
 * 
 *         if ((child.byteorder == c'>' and little_endian) or
 */
  __pyx_tuple__77 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__77)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__77);
  __Pyx_GIVEREF(__pyx_tuple__77);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":803
 *         if ((child.byteorder == c'>' and little_endian) or
 *             (child.byteorder == c'<' and not little_endian)):
 *             raise ValueError(u"Non-native byte order not supported")             # <<<<<<<<<<<<<<
 *             # One could encode it in the format string and have Cython
 *             # complain instead, BUT: < and > in format strings also imply
 */
  __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__78)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__78);
  __Pyx_GIVEREF(__pyx_tuple__78);

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":823
 *             t = child.type_num
 *             if end - f < 5:
 *                 raise RuntimeError(u"Format string allocated too short.")             # <<<<<<<<<<<<<<
 * 
 *             # Until ticket #99 is fixed, use integers to avoid warnings
 */
  __pyx_tuple__79 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__79)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);

  /* "rasterio/_io.pyx":17
 * 
 * 
 * log = logging.getLogger('rasterio')             # <<<<<<<<<<<<<<
 * class NullHandler(logging.Handler):
 *     def emit(self, record):
 */
  __pyx_tuple__80 = PyTuple_Pack(1, __pyx_n_s_rasterio); if (unlikely(!__pyx_tuple__80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__80);
  __Pyx_GIVEREF(__pyx_tuple__80);

  /* "rasterio/_io.pyx":19
 * log = logging.getLogger('rasterio')
 * class NullHandler(logging.Handler):
 *     def emit(self, record):             # <<<<<<<<<<<<<<
 *         pass
 * log.addHandler(NullHandler())
 */
  __pyx_tuple__81 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_record); if (unlikely(!__pyx_tuple__81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);
  __pyx_codeobj__82 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__81, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_seang_code_rasterio_raste, __pyx_n_s_emit, 19, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "rasterio/_io.pyx":144
 *     return (r_start, r_stop), (c_start, c_stop)
 * 
 * def window_shape(window, height=-1, width=-1):             # <<<<<<<<<<<<<<
 *     """Returns shape of a window.
 * 
 */
  __pyx_tuple__83 = PyTuple_Pack(7, __pyx_n_s_window, __pyx_n_s_height, __pyx_n_s_width, __pyx_n_s_a, __pyx_n_s_b, __pyx_n_s_c, __pyx_n_s_d); if (unlikely(!__pyx_tuple__83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__83);
  __Pyx_GIVEREF(__pyx_tuple__83);
  __pyx_codeobj__84 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__83, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_seang_code_rasterio_raste, __pyx_n_s_window_shape, 144, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "rasterio/_io.pyx":153
 *     return b-a, d-c
 * 
 * def window_index(window):             # <<<<<<<<<<<<<<
 *     return tuple(slice(*w) for w in window)
 * 
 */
  __pyx_tuple__85 = PyTuple_Pack(3, __pyx_n_s_window, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_tuple__85);
  __Pyx_GIVEREF(__pyx_tuple__85);
  __pyx_codeobj__86 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__85, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_seang_code_rasterio_raste, __pyx_n_s_window_index, 153, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_255 = PyInt_FromLong(255); if (unlikely(!__pyx_int_255)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_256 = PyInt_FromLong(256); if (unlikely(!__pyx_int_256)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init_io(void); /*proto*/
PyMODINIT_FUNC init_io(void)
#else
PyMODINIT_FUNC PyInit__io(void); /*proto*/
PyMODINIT_FUNC PyInit__io(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__io(void)", 0);
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_io"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_d);
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  if (__pyx_module_is_main_rasterio___io) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!PyDict_GetItemString(modules, "rasterio._io")) {
      if (unlikely(PyDict_SetItemString(modules, "rasterio._io", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  if (__Pyx_ExportFunction("io_ubyte", (void (*)(void))__pyx_f_8rasterio_3_io_io_ubyte, "int (void *, int, int, int, int, int, PyArrayObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("io_uint16", (void (*)(void))__pyx_f_8rasterio_3_io_io_uint16, "int (void *, int, int, int, int, int, PyArrayObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("io_int16", (void (*)(void))__pyx_f_8rasterio_3_io_io_int16, "int (void *, int, int, int, int, int, PyArrayObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("io_uint32", (void (*)(void))__pyx_f_8rasterio_3_io_io_uint32, "int (void *, int, int, int, int, int, PyArrayObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("io_int32", (void (*)(void))__pyx_f_8rasterio_3_io_io_int32, "int (void *, int, int, int, int, int, PyArrayObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("io_float32", (void (*)(void))__pyx_f_8rasterio_3_io_io_float32, "int (void *, int, int, int, int, int, PyArrayObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ExportFunction("io_float64", (void (*)(void))__pyx_f_8rasterio_3_io_io_float64, "int (void *, int, int, int, int, int, PyArrayObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Type init code ---*/
  __pyx_vtabptr_8rasterio_3_io_RasterReader = &__pyx_vtable_8rasterio_3_io_RasterReader;
  __pyx_vtable_8rasterio_3_io_RasterReader.band = (void *(*)(struct __pyx_obj_8rasterio_3_io_RasterReader *, int))__pyx_f_8rasterio_3_io_12RasterReader_band;
  if (PyType_Ready(&__pyx_type_8rasterio_3_io_RasterReader) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_8rasterio_3_io_RasterReader.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_8rasterio_3_io_RasterReader.tp_dict, __pyx_vtabptr_8rasterio_3_io_RasterReader) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "RasterReader", (PyObject *)&__pyx_type_8rasterio_3_io_RasterReader) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_8rasterio_3_io_RasterReader = &__pyx_type_8rasterio_3_io_RasterReader;
  __pyx_vtabptr_8rasterio_3_io_RasterUpdater = &__pyx_vtable_8rasterio_3_io_RasterUpdater;
  __pyx_vtable_8rasterio_3_io_RasterUpdater.__pyx_base = *__pyx_vtabptr_8rasterio_3_io_RasterReader;
  __pyx_type_8rasterio_3_io_RasterUpdater.tp_base = __pyx_ptype_8rasterio_3_io_RasterReader;
  if (PyType_Ready(&__pyx_type_8rasterio_3_io_RasterUpdater) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_8rasterio_3_io_RasterUpdater.tp_print = 0;
  if (__Pyx_SetVtable(__pyx_type_8rasterio_3_io_RasterUpdater.tp_dict, __pyx_vtabptr_8rasterio_3_io_RasterUpdater) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "RasterUpdater", (PyObject *)&__pyx_type_8rasterio_3_io_RasterUpdater) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_8rasterio_3_io_RasterUpdater = &__pyx_type_8rasterio_3_io_RasterUpdater;
  if (PyType_Ready(&__pyx_type_8rasterio_3_io___pyx_scope_struct_2_block_windows) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_8rasterio_3_io___pyx_scope_struct_2_block_windows.tp_print = 0;
  __pyx_ptype_8rasterio_3_io___pyx_scope_struct_2_block_windows = &__pyx_type_8rasterio_3_io___pyx_scope_struct_2_block_windows;
  if (PyType_Ready(&__pyx_type_8rasterio_3_io___pyx_scope_struct__window_index) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_8rasterio_3_io___pyx_scope_struct__window_index.tp_print = 0;
  __pyx_ptype_8rasterio_3_io___pyx_scope_struct__window_index = &__pyx_type_8rasterio_3_io___pyx_scope_struct__window_index;
  if (PyType_Ready(&__pyx_type_8rasterio_3_io___pyx_scope_struct_1_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_type_8rasterio_3_io___pyx_scope_struct_1_genexpr.tp_print = 0;
  __pyx_ptype_8rasterio_3_io___pyx_scope_struct_1_genexpr = &__pyx_type_8rasterio_3_io___pyx_scope_struct_1_genexpr;
  /*--- Type import code ---*/
  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", 
  #if CYTHON_COMPILING_IN_PYPY
  sizeof(PyTypeObject),
  #else
  sizeof(PyHeapTypeObject),
  #endif
  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "rasterio/_io.pyx":3
 * # cython: profile=True
 * 
 * import logging             # <<<<<<<<<<<<<<
 * import os
 * import os.path
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_logging, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_logging, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":4
 * 
 * import logging
 * import os             # <<<<<<<<<<<<<<
 * import os.path
 * import math
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":5
 * import logging
 * import os
 * import os.path             # <<<<<<<<<<<<<<
 * import math
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_os_path, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":6
 * import os
 * import os.path
 * import math             # <<<<<<<<<<<<<<
 * 
 * import numpy as np
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_math, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_math, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":8
 * import math
 * 
 * import numpy as np             # <<<<<<<<<<<<<<
 * cimport numpy as np
 * 
 */
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":12
 * 
 * from rasterio cimport _gdal, _ogr, _io
 * from rasterio._drivers import driver_count, GDALEnv             # <<<<<<<<<<<<<<
 * from rasterio import dtypes
 * from rasterio.five import text_type
 */
  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_driver_count);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_driver_count);
  __Pyx_GIVEREF(__pyx_n_s_driver_count);
  __Pyx_INCREF(__pyx_n_s_GDALEnv);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_GDALEnv);
  __Pyx_GIVEREF(__pyx_n_s_GDALEnv);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_rasterio__drivers, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_driver_count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_driver_count, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_GDALEnv); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_GDALEnv, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":13
 * from rasterio cimport _gdal, _ogr, _io
 * from rasterio._drivers import driver_count, GDALEnv
 * from rasterio import dtypes             # <<<<<<<<<<<<<<
 * from rasterio.five import text_type
 * 
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_n_s_dtypes);
  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_dtypes);
  __Pyx_GIVEREF(__pyx_n_s_dtypes);
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_rasterio, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_dtypes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_dtypes, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "rasterio/_io.pyx":14
 * from rasterio._drivers import driver_count, GDALEnv
 * from rasterio import dtypes
 * from rasterio.five import text_type             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_text_type);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_text_type);
  __Pyx_GIVEREF(__pyx_n_s_text_type);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_rasterio_five, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_text_type); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_text_type, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":17
 * 
 * 
 * log = logging.getLogger('rasterio')             # <<<<<<<<<<<<<<
 * class NullHandler(logging.Handler):
 *     def emit(self, record):
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_logging); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_getLogger); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_log, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":18
 * 
 * log = logging.getLogger('rasterio')
 * class NullHandler(logging.Handler):             # <<<<<<<<<<<<<<
 *     def emit(self, record):
 *         pass
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_logging); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Handler); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_NullHandler, __pyx_n_s_NullHandler, (PyObject *) NULL, __pyx_n_s_rasterio__io, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "rasterio/_io.pyx":19
 * log = logging.getLogger('rasterio')
 * class NullHandler(logging.Handler):
 *     def emit(self, record):             # <<<<<<<<<<<<<<
 *         pass
 * log.addHandler(NullHandler())
 */
  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_8rasterio_3_io_11NullHandler_1emit, 0, __pyx_n_s_NullHandler_emit, NULL, __pyx_n_s_rasterio__io, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__82)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_emit, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "rasterio/_io.pyx":18
 * 
 * log = logging.getLogger('rasterio')
 * class NullHandler(logging.Handler):             # <<<<<<<<<<<<<<
 *     def emit(self, record):
 *         pass
 */
  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_NullHandler, __pyx_t_2, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_NullHandler, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "rasterio/_io.pyx":21
 *     def emit(self, record):
 *         pass
 * log.addHandler(NullHandler())             # <<<<<<<<<<<<<<
 * 
 * cdef int io_ubyte(
 */
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_log); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_addHandler); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_NullHandler); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "rasterio/_io.pyx":144
 *     return (r_start, r_stop), (c_start, c_stop)
 * 
 * def window_shape(window, height=-1, width=-1):             # <<<<<<<<<<<<<<
 *     """Returns shape of a window.
 * 
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_8rasterio_3_io_3window_shape, NULL, __pyx_n_s_rasterio__io); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_window_shape, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "rasterio/_io.pyx":153
 *     return b-a, d-c
 * 
 * def window_index(window):             # <<<<<<<<<<<<<<
 *     return tuple(slice(*w) for w in window)
 * 
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_8rasterio_3_io_5window_index, NULL, __pyx_n_s_rasterio__io); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_window_index, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "rasterio/_io.pyx":319
 * 
 *     @property
 *     def closed(self):             # <<<<<<<<<<<<<<
 *         return self._closed
 * 
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader, __pyx_n_s_closed); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "rasterio/_io.pyx":318
 *             _gdal.GDALClose(self._hds)
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def closed(self):
 *         return self._closed
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader->tp_dict, __pyx_n_s_closed, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterReader);

  /* "rasterio/_io.pyx":323
 * 
 *     @property
 *     def count(self):             # <<<<<<<<<<<<<<
 *         if not self._count:
 *             if self._hds == NULL:
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader, __pyx_n_s_count); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "rasterio/_io.pyx":322
 *         return self._closed
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def count(self):
 *         if not self._count:
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader->tp_dict, __pyx_n_s_count, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterReader);

  /* "rasterio/_io.pyx":331
 * 
 *     @property
 *     def indexes(self):             # <<<<<<<<<<<<<<
 *         return list(range(1, self.count+1))
 * 
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader, __pyx_n_s_indexes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "rasterio/_io.pyx":330
 *         return self._count
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def indexes(self):
 *         return list(range(1, self.count+1))
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader->tp_dict, __pyx_n_s_indexes, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterReader);

  /* "rasterio/_io.pyx":335
 * 
 *     @property
 *     def dtypes(self):             # <<<<<<<<<<<<<<
 *         """Returns an ordered list of all band data types."""
 *         cdef void *hband = NULL
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader, __pyx_n_s_dtypes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "rasterio/_io.pyx":334
 *         return list(range(1, self.count+1))
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def dtypes(self):
 *         """Returns an ordered list of all band data types."""
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader->tp_dict, __pyx_n_s_dtypes, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterReader);

  /* "rasterio/_io.pyx":348
 * 
 *     @property
 *     def block_shapes(self):             # <<<<<<<<<<<<<<
 *         """Returns an ordered list of block shapes for all bands.
 * 
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader, __pyx_n_s_block_shapes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "rasterio/_io.pyx":347
 *         return self._dtypes
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def block_shapes(self):
 *         """Returns an ordered list of block shapes for all bands.
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader->tp_dict, __pyx_n_s_block_shapes, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterReader);

  /* "rasterio/_io.pyx":368
 * 
 *     @property
 *     def nodatavals(self):             # <<<<<<<<<<<<<<
 *         """Returns a band-ordered list of nodata values."""
 *         cdef void *hband = NULL
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader, __pyx_n_s_nodatavals); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "rasterio/_io.pyx":367
 *         return self._block_shapes
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def nodatavals(self):
 *         """Returns a band-ordered list of nodata values."""
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader->tp_dict, __pyx_n_s_nodatavals, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterReader);

  /* "rasterio/_io.pyx":420
 * 
 *     @property
 *     def bounds(self):             # <<<<<<<<<<<<<<
 *         """Returns the lower left and upper right bounds of the dataset
 *         in the units of its coordinate reference system.
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader, __pyx_n_s_bounds); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "rasterio/_io.pyx":419
 *                 yield (j, i), ((row, row+height), (col, col+width))
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def bounds(self):
 *         """Returns the lower left and upper right bounds of the dataset
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader->tp_dict, __pyx_n_s_bounds, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterReader);

  /* "rasterio/_io.pyx":431
 * 
 *     @property
 *     def res(self):             # <<<<<<<<<<<<<<
 *         """Returns the (width, height) of pixels in the units of its
 *         coordinate reference system."""
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader, __pyx_n_s_res); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "rasterio/_io.pyx":430
 *         return (t[0], t[3]+t[5]*self.height, t[0]+t[1]*self.width, t[3])
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def res(self):
 *         """Returns the (width, height) of pixels in the units of its
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader->tp_dict, __pyx_n_s_res, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterReader);

  /* "rasterio/_io.pyx":457
 * 
 *     @property
 *     def meta(self):             # <<<<<<<<<<<<<<
 *         m = {
 *             'driver': self.driver,
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader, __pyx_n_s_meta); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "rasterio/_io.pyx":456
 *         return int((t[3]-y)/t[5]), int((x-t[0])/t[1])
 * 
 *     @property             # <<<<<<<<<<<<<<
 *     def meta(self):
 *         m = {
 */
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader->tp_dict, __pyx_n_s_meta, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterReader);

  /* "rasterio/_io.pyx":476
 *             self._crs = self.read_crs()
 *         return self._crs
 *     crs = property(get_crs)             # <<<<<<<<<<<<<<
 * 
 *     def get_crs_wkt(self):
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader, __pyx_n_s_get_crs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader->tp_dict, __pyx_n_s_crs, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterReader);

  /* "rasterio/_io.pyx":482
 *             self._crs = self.read_crs_wkt()
 *         return self._crs_wkt
 *     crs_wkt = property(get_crs_wkt)             # <<<<<<<<<<<<<<
 * 
 *     def get_transform(self):
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader, __pyx_n_s_get_crs_wkt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader->tp_dict, __pyx_n_s_crs_wkt, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterReader);

  /* "rasterio/_io.pyx":499
 *             self._transform = self.read_transform()
 *         return self._transform
 *     transform = property(get_transform)             # <<<<<<<<<<<<<<
 * 
 *     def read_band(self, bidx, out=None, window=None):
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader, __pyx_n_s_get_transform); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_property, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterReader->tp_dict, __pyx_n_s_transform, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterReader);

  /* "rasterio/_io.pyx":846
 *         self._crs = crs
 * 
 *     crs = property(get_crs, write_crs)             # <<<<<<<<<<<<<<
 * 
 *     def write_transform(self, transform):
 */
  __pyx_t_3 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterUpdater, __pyx_n_s_get_crs); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterUpdater, __pyx_n_s_write_crs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_property, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterUpdater->tp_dict, __pyx_n_s_crs, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterUpdater);

  /* "rasterio/_io.pyx":862
 *         return self._transform
 * 
 *     transform = property(get_transform, write_transform)             # <<<<<<<<<<<<<<
 * 
 *     def write_band(self, bidx, src, window=None):
 */
  __pyx_t_2 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterUpdater, __pyx_n_s_get_transform); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetNameInClass((PyObject *)__pyx_ptype_8rasterio_3_io_RasterUpdater, __pyx_n_s_write_transform); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_Call(__pyx_builtin_property, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_8rasterio_3_io_RasterUpdater->tp_dict, __pyx_n_s_transform, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  PyType_Modified(__pyx_ptype_8rasterio_3_io_RasterUpdater);

  /* "rasterio/_io.pyx":1
 * # cython: profile=True             # <<<<<<<<<<<<<<
 * 
 * import logging
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/Users/seang/envs/tob33/lib/python3.3/site-packages/Cython/Includes/numpy/__init__.pxd":976
 *      arr.base = baseptr
 * 
 * cdef inline object get_array_base(ndarray arr):             # <<<<<<<<<<<<<<
 *     if arr.base is NULL:
 *         return None
 */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__pyx_m) {
    __Pyx_AddTraceback("init rasterio._io", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init rasterio._io");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif /* CYTHON_REFNANNY */

static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%.200s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%.200s() got an unexpected keyword argument '%.200s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

#if CYTHON_PROFILE
static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
                                   PyFrameObject** frame,
                                   const char *funcname,
                                   const char *srcfile,
                                   int firstlineno) {
    int retval;
    PyThreadState* tstate = PyThreadState_GET();
    if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) {
        if (*code == NULL) {
            *code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno);
            if (*code == NULL) return 0;
        }
        *frame = PyFrame_New(
            tstate,                          /*PyThreadState *tstate*/
            *code,                           /*PyCodeObject *code*/
            __pyx_d,                  /*PyObject *globals*/
            0                                /*PyObject *locals*/
        );
        if (*frame == NULL) return 0;
        if (CYTHON_TRACE && (*frame)->f_trace == NULL) {
            Py_INCREF(Py_None);
            (*frame)->f_trace = Py_None;
        }
#if PY_VERSION_HEX < 0x030400B1
    } else {
        (*frame)->f_tstate = tstate;
#endif
    }
    (*frame)->f_lineno = firstlineno;
    tstate->use_tracing = 0;
    #if CYTHON_TRACE
    if (tstate->c_tracefunc)
        tstate->c_tracefunc(tstate->c_traceobj, *frame, PyTrace_CALL, NULL);
    if (!tstate->c_profilefunc)
        retval = 1;
    else
    #endif
        retval = tstate->c_profilefunc(tstate->c_profileobj, *frame, PyTrace_CALL, NULL) == 0;
    tstate->use_tracing = (tstate->c_profilefunc ||
                           (CYTHON_TRACE && tstate->c_tracefunc));
    return tstate->use_tracing && retval;
}
static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyCodeObject *py_code = 0;
    #if PY_MAJOR_VERSION < 3
    py_funcname = PyString_FromString(funcname);
    py_srcfile = PyString_FromString(srcfile);
    #else
    py_funcname = PyUnicode_FromString(funcname);
    py_srcfile = PyUnicode_FromString(srcfile);
    #endif
    if (!py_funcname | !py_srcfile) goto bad;
    py_code = PyCode_New(
        0,                /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,                /*int kwonlyargcount,*/
        #endif
        0,                /*int nlocals,*/
        0,                /*int stacksize,*/
        0,                /*int flags,*/
        __pyx_empty_bytes,     /*PyObject *code,*/
        __pyx_empty_tuple,     /*PyObject *consts,*/
        __pyx_empty_tuple,     /*PyObject *names,*/
        __pyx_empty_tuple,     /*PyObject *varnames,*/
        __pyx_empty_tuple,     /*PyObject *freevars,*/
        __pyx_empty_tuple,     /*PyObject *cellvars,*/
        py_srcfile,       /*PyObject *filename,*/
        py_funcname,      /*PyObject *name,*/
        firstlineno,      /*int firstlineno,*/
        __pyx_empty_bytes      /*PyObject *lnotab*/
    );
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return py_code;
}
#endif /* CYTHON_PROFILE */

static CYTHON_INLINE int __Pyx_IsLittleEndian(void) {
  unsigned int n = 1;
  return *(unsigned char*)(&n) != 0;
}
static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
                              __Pyx_BufFmt_StackElem* stack,
                              __Pyx_TypeInfo* type) {
  stack[0].field = &ctx->root;
  stack[0].parent_offset = 0;
  ctx->root.type = type;
  ctx->root.name = "buffer dtype";
  ctx->root.offset = 0;
  ctx->head = stack;
  ctx->head->field = &ctx->root;
  ctx->fmt_offset = 0;
  ctx->head->parent_offset = 0;
  ctx->new_packmode = '@';
  ctx->enc_packmode = '@';
  ctx->new_count = 1;
  ctx->enc_count = 0;
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  ctx->is_valid_array = 0;
  ctx->struct_alignment = 0;
  while (type->typegroup == 'S') {
    ++ctx->head;
    ctx->head->field = type->fields;
    ctx->head->parent_offset = 0;
    type = type->fields->type;
  }
}
static int __Pyx_BufFmt_ParseNumber(const char** ts) {
    int count;
    const char* t = *ts;
    if (*t < '0' || *t > '9') {
      return -1;
    } else {
        count = *t++ - '0';
        while (*t >= '0' && *t < '9') {
            count *= 10;
            count += *t++ - '0';
        }
    }
    *ts = t;
    return count;
}
static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
    int number = __Pyx_BufFmt_ParseNumber(ts);
    if (number == -1) /* First char was not a digit */
        PyErr_Format(PyExc_ValueError,\
                     "Does not understand character buffer dtype format string ('%c')", **ts);
    return number;
}
static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
  PyErr_Format(PyExc_ValueError,
               "Unexpected format string character: '%c'", ch);
}
static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
  switch (ch) {
    case 'c': return "'char'";
    case 'b': return "'signed char'";
    case 'B': return "'unsigned char'";
    case 'h': return "'short'";
    case 'H': return "'unsigned short'";
    case 'i': return "'int'";
    case 'I': return "'unsigned int'";
    case 'l': return "'long'";
    case 'L': return "'unsigned long'";
    case 'q': return "'long long'";
    case 'Q': return "'unsigned long long'";
    case 'f': return (is_complex ? "'complex float'" : "'float'");
    case 'd': return (is_complex ? "'complex double'" : "'double'");
    case 'g': return (is_complex ? "'complex long double'" : "'long double'");
    case 'T': return "a struct";
    case 'O': return "Python object";
    case 'P': return "a pointer";
    case 's': case 'p': return "a string";
    case 0: return "end";
    default: return "unparseable format string";
  }
}
static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return 2;
    case 'i': case 'I': case 'l': case 'L': return 4;
    case 'q': case 'Q': return 8;
    case 'f': return (is_complex ? 8 : 4);
    case 'd': return (is_complex ? 16 : 8);
    case 'g': {
      PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
      return 0;
    }
    case 'O': case 'P': return sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
  switch (ch) {
    case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(short);
    case 'i': case 'I': return sizeof(int);
    case 'l': case 'L': return sizeof(long);
    #ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(PY_LONG_LONG);
    #endif
    case 'f': return sizeof(float) * (is_complex ? 2 : 1);
    case 'd': return sizeof(double) * (is_complex ? 2 : 1);
    case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
    case 'O': case 'P': return sizeof(void*);
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
typedef struct { char c; short x; } __Pyx_st_short;
typedef struct { char c; int x; } __Pyx_st_int;
typedef struct { char c; long x; } __Pyx_st_long;
typedef struct { char c; float x; } __Pyx_st_float;
typedef struct { char c; double x; } __Pyx_st_double;
typedef struct { char c; long double x; } __Pyx_st_longdouble;
typedef struct { char c; void *x; } __Pyx_st_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
/* These are for computing the padding at the end of the struct to align
   on the first member of the struct. This will probably the same as above,
   but we don't have any guarantees.
 */
typedef struct { short x; char c; } __Pyx_pad_short;
typedef struct { int x; char c; } __Pyx_pad_int;
typedef struct { long x; char c; } __Pyx_pad_long;
typedef struct { float x; char c; } __Pyx_pad_float;
typedef struct { double x; char c; } __Pyx_pad_double;
typedef struct { long double x; char c; } __Pyx_pad_longdouble;
typedef struct { void *x; char c; } __Pyx_pad_void_p;
#ifdef HAVE_LONG_LONG
typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
#endif
static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
  switch (ch) {
    case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
    case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
    case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
    case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
#ifdef HAVE_LONG_LONG
    case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
#endif
    case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
    case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
    case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
    case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
    default:
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
}
static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
  switch (ch) {
    case 'c':
        return 'H';
    case 'b': case 'h': case 'i':
    case 'l': case 'q': case 's': case 'p':
        return 'I';
    case 'B': case 'H': case 'I': case 'L': case 'Q':
        return 'U';
    case 'f': case 'd': case 'g':
        return (is_complex ? 'C' : 'R');
    case 'O':
        return 'O';
    case 'P':
        return 'P';
    default: {
      __Pyx_BufFmt_RaiseUnexpectedChar(ch);
      return 0;
    }
  }
}
static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
  if (ctx->head == NULL || ctx->head->field == &ctx->root) {
    const char* expected;
    const char* quote;
    if (ctx->head == NULL) {
      expected = "end";
      quote = "";
    } else {
      expected = ctx->head->field->type->name;
      quote = "'";
    }
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected %s%s%s but got %s",
                 quote, expected, quote,
                 __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
  } else {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_StructField* parent = (ctx->head - 1)->field;
    PyErr_Format(PyExc_ValueError,
                 "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
                 field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
                 parent->type->name, field->name);
  }
}
static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
  char group;
  size_t size, offset, arraysize = 1;
  if (ctx->enc_type == 0) return 0;
  if (ctx->head->field->type->arraysize[0]) {
    int i, ndim = 0;
    if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
        ctx->is_valid_array = ctx->head->field->type->ndim == 1;
        ndim = 1;
        if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
            PyErr_Format(PyExc_ValueError,
                         "Expected a dimension of size %zu, got %zu",
                         ctx->head->field->type->arraysize[0], ctx->enc_count);
            return -1;
        }
    }
    if (!ctx->is_valid_array) {
      PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
                   ctx->head->field->type->ndim, ndim);
      return -1;
    }
    for (i = 0; i < ctx->head->field->type->ndim; i++) {
      arraysize *= ctx->head->field->type->arraysize[i];
    }
    ctx->is_valid_array = 0;
    ctx->enc_count = 1;
  }
  group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
  do {
    __Pyx_StructField* field = ctx->head->field;
    __Pyx_TypeInfo* type = field->type;
    if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
      size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
    } else {
      size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
    }
    if (ctx->enc_packmode == '@') {
      size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
      size_t align_mod_offset;
      if (align_at == 0) return -1;
      align_mod_offset = ctx->fmt_offset % align_at;
      if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
      if (ctx->struct_alignment == 0)
          ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
                                                                 ctx->is_complex);
    }
    if (type->size != size || type->typegroup != group) {
      if (type->typegroup == 'C' && type->fields != NULL) {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        ++ctx->head;
        ctx->head->field = type->fields;
        ctx->head->parent_offset = parent_offset;
        continue;
      }
      if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
      } else {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
      }
    }
    offset = ctx->head->parent_offset + field->offset;
    if (ctx->fmt_offset != offset) {
      PyErr_Format(PyExc_ValueError,
                   "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
                   (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
      return -1;
    }
    ctx->fmt_offset += size;
    if (arraysize)
      ctx->fmt_offset += (arraysize - 1) * size;
    --ctx->enc_count; /* Consume from buffer string */
    while (1) {
      if (field == &ctx->root) {
        ctx->head = NULL;
        if (ctx->enc_count != 0) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return -1;
        }
        break; /* breaks both loops as ctx->enc_count == 0 */
      }
      ctx->head->field = ++field;
      if (field->type == NULL) {
        --ctx->head;
        field = ctx->head->field;
        continue;
      } else if (field->type->typegroup == 'S') {
        size_t parent_offset = ctx->head->parent_offset + field->offset;
        if (field->type->fields->type == NULL) continue; /* empty struct */
        field = field->type->fields;
        ++ctx->head;
        ctx->head->field = field;
        ctx->head->parent_offset = parent_offset;
        break;
      } else {
        break;
      }
    }
  } while (ctx->enc_count);
  ctx->enc_type = 0;
  ctx->is_complex = 0;
  return 0;
}
static CYTHON_INLINE PyObject *
__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
{
    const char *ts = *tsp;
    int i = 0, number;
    int ndim = ctx->head->field->type->ndim;
;
    ++ts;
    if (ctx->new_count != 1) {
        PyErr_SetString(PyExc_ValueError,
                        "Cannot handle repeated arrays in format string");
        return NULL;
    }
    if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
    while (*ts && *ts != ')') {
        if (isspace(*ts))
            continue;
        number = __Pyx_BufFmt_ExpectNumber(&ts);
        if (number == -1) return NULL;
        if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
            return PyErr_Format(PyExc_ValueError,
                        "Expected a dimension of size %zu, got %d",
                        ctx->head->field->type->arraysize[i], number);
        if (*ts != ',' && *ts != ')')
            return PyErr_Format(PyExc_ValueError,
                                "Expected a comma in format string, got '%c'", *ts);
        if (*ts == ',') ts++;
        i++;
    }
    if (i != ndim)
        return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
                            ctx->head->field->type->ndim, i);
    if (!*ts) {
        PyErr_SetString(PyExc_ValueError,
                        "Unexpected end of format string, expected ')'");
        return NULL;
    }
    ctx->is_valid_array = 1;
    ctx->new_count = 1;
    *tsp = ++ts;
    return Py_None;
}
static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
  int got_Z = 0;
  while (1) {
    switch(*ts) {
      case 0:
        if (ctx->enc_type != 0 && ctx->head == NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        if (ctx->head != NULL) {
          __Pyx_BufFmt_RaiseExpected(ctx);
          return NULL;
        }
                return ts;
      case ' ':
      case 10:
      case 13:
        ++ts;
        break;
      case '<':
        if (!__Pyx_IsLittleEndian()) {
          PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '>':
      case '!':
        if (__Pyx_IsLittleEndian()) {
          PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
          return NULL;
        }
        ctx->new_packmode = '=';
        ++ts;
        break;
      case '=':
      case '@':
      case '^':
        ctx->new_packmode = *ts++;
        break;
      case 'T': /* substruct */
        {
          const char* ts_after_sub;
          size_t i, struct_count = ctx->new_count;
          size_t struct_alignment = ctx->struct_alignment;
          ctx->new_count = 1;
          ++ts;
          if (*ts != '{') {
            PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
            return NULL;
          }
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0; /* Erase processed last struct element */
          ctx->enc_count = 0;
          ctx->struct_alignment = 0;
          ++ts;
          ts_after_sub = ts;
          for (i = 0; i != struct_count; ++i) {
            ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
            if (!ts_after_sub) return NULL;
          }
          ts = ts_after_sub;
          if (struct_alignment) ctx->struct_alignment = struct_alignment;
        }
        break;
      case '}': /* end of substruct; either repeat or move on */
        {
          size_t alignment = ctx->struct_alignment;
          ++ts;
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_type = 0; /* Erase processed last struct element */
          if (alignment && ctx->fmt_offset % alignment) {
            ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
          }
        }
        return ts;
      case 'x':
        if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
        ctx->fmt_offset += ctx->new_count;
        ctx->new_count = 1;
        ctx->enc_count = 0;
        ctx->enc_type = 0;
        ctx->enc_packmode = ctx->new_packmode;
        ++ts;
        break;
      case 'Z':
        got_Z = 1;
        ++ts;
        if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
          __Pyx_BufFmt_RaiseUnexpectedChar('Z');
          return NULL;
        }        /* fall through */
      case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
      case 'l': case 'L': case 'q': case 'Q':
      case 'f': case 'd': case 'g':
      case 'O': case 's': case 'p':
        if (ctx->enc_type == *ts && got_Z == ctx->is_complex &&
            ctx->enc_packmode == ctx->new_packmode) {
          ctx->enc_count += ctx->new_count;
        } else {
          if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
          ctx->enc_count = ctx->new_count;
          ctx->enc_packmode = ctx->new_packmode;
          ctx->enc_type = *ts;
          ctx->is_complex = got_Z;
        }
        ++ts;
        ctx->new_count = 1;
        got_Z = 0;
        break;
      case ':':
        ++ts;
        while(*ts != ':') ++ts;
        ++ts;
        break;
      case '(':
        if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
        break;
      default:
        {
          int number = __Pyx_BufFmt_ExpectNumber(&ts);
          if (number == -1) return NULL;
          ctx->new_count = (size_t)number;
        }
    }
  }
}
static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) {
  buf->buf = NULL;
  buf->obj = NULL;
  buf->strides = __Pyx_zeros;
  buf->shape = __Pyx_zeros;
  buf->suboffsets = __Pyx_minusones;
}
static CYTHON_INLINE int __Pyx_GetBufferAndValidate(
        Py_buffer* buf, PyObject* obj,  __Pyx_TypeInfo* dtype, int flags,
        int nd, int cast, __Pyx_BufFmt_StackElem* stack)
{
  if (obj == Py_None || obj == NULL) {
    __Pyx_ZeroBuffer(buf);
    return 0;
  }
  buf->buf = NULL;
  if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail;
  if (buf->ndim != nd) {
    PyErr_Format(PyExc_ValueError,
                 "Buffer has wrong number of dimensions (expected %d, got %d)",
                 nd, buf->ndim);
    goto fail;
  }
  if (!cast) {
    __Pyx_BufFmt_Context ctx;
    __Pyx_BufFmt_Init(&ctx, stack, dtype);
    if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail;
  }
  if ((unsigned)buf->itemsize != dtype->size) {
    PyErr_Format(PyExc_ValueError,
      "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)",
      buf->itemsize, (buf->itemsize > 1) ? "s" : "",
      dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : "");
    goto fail;
  }
  if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones;
  return 0;
fail:;
  __Pyx_ZeroBuffer(buf);
  return -1;
}
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) {
  if (info->buf == NULL) return;
  if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL;
  __Pyx_ReleaseBuffer(info);
}

static void __Pyx_RaiseBufferIndexError(int axis) {
  PyErr_Format(PyExc_IndexError,
     "Out of bounds on buffer access (axis %d)", axis);
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
                                  int full_traceback) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    if (full_traceback) {
        Py_XINCREF(old_exc);
        Py_XINCREF(old_val);
        Py_XINCREF(old_tb);
        __Pyx_ErrRestore(old_exc, old_val, old_tb);
        PyErr_PrintEx(1);
    }
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                 index, (index == 1) ? "" : "s");
}

static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
                        PyErr_Clear();
                    else
                        return NULL;
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    #if PY_VERSION_HEX < 0x02050000
    if (PyClass_Check(type)) {
    #else
    if (PyType_Check(type)) {
    #endif
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        #if PY_VERSION_HEX < 0x02050000
        if (PyInstance_Check(type)) {
            type = (PyObject*) ((PyInstanceObject*)type)->in_class;
            Py_INCREF(type);
        } else {
            type = 0;
            PyErr_SetString(PyExc_TypeError,
                "raise: exception must be an old-style class or instance");
            goto raise_error;
        }
        #else
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
        #endif
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else /* Python 3+ */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                if (PyObject_IsSubclass(instance_class, type)) {
                    type = instance_class;
                } else {
                    instance_class = NULL;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
#if PY_VERSION_HEX >= 0x03030000
    if (cause) {
#else
    if (cause && cause != Py_None) {
#endif
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) {
    PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
}

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON
    result = PyDict_GetItem(__pyx_d, name);
    if (result) {
        Py_INCREF(result);
    } else {
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
         const char* cstring, Py_ssize_t start, Py_ssize_t stop,
         const char* encoding, const char* errors,
         PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
    Py_ssize_t length;
    if (unlikely((start < 0) | (stop < 0))) {
        length = strlen(cstring);
        if (start < 0) {
            start += length;
            if (start < 0)
                start = 0;
        }
        if (stop < 0)
            stop += length;
    }
    length = stop - start;
    if (unlikely(length <= 0))
        return PyUnicode_FromUnicode(NULL, 0);
    cstring += start;
    if (decode_func) {
        return decode_func(cstring, length, errors);
    } else {
        return PyUnicode_Decode(cstring, length, encoding, errors);
    }
}

static double __Pyx__PyObject_AsDouble(PyObject* obj) {
    PyObject* float_value;
#if CYTHON_COMPILING_IN_PYPY
    float_value = PyNumber_Float(obj);
#else
    PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number;
    if (likely(nb) && likely(nb->nb_float)) {
        float_value = nb->nb_float(obj);
        if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) {
            PyErr_Format(PyExc_TypeError,
                "__float__ returned non-float (type %.200s)",
                Py_TYPE(float_value)->tp_name);
            Py_DECREF(float_value);
            goto bad;
        }
    } else if (PyUnicode_CheckExact(obj) || PyBytes_CheckExact(obj)) {
#if PY_MAJOR_VERSION >= 3
        float_value = PyFloat_FromString(obj);
#else
        float_value = PyFloat_FromString(obj, 0);
#endif
    } else {
        PyObject* args = PyTuple_New(1);
        if (unlikely(!args)) goto bad;
        PyTuple_SET_ITEM(args, 0, obj);
        float_value = PyObject_Call((PyObject*)&PyFloat_Type, args, 0);
        PyTuple_SET_ITEM(args, 0, 0);
        Py_DECREF(args);
    }
#endif
    if (likely(float_value)) {
        double value = PyFloat_AS_DOUBLE(float_value);
        Py_DECREF(float_value);
        return value;
    }
bad:
    return (double)-1;
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
#else
    PyErr_GetExcInfo(type, value, tb);
#endif
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(type, value, tb);
#endif
}

static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
}

static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
                                               int is_list, int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
        if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject* old = PyList_GET_ITEM(o, n);
            Py_INCREF(v);
            PyList_SET_ITEM(o, n, v);
            Py_DECREF(old);
            return 1;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_ass_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
                        PyErr_Clear();
                    else
                        return -1;
                }
            }
            return m->sq_ass_item(o, i, v);
        }
    }
#else
#if CYTHON_COMPILING_IN_PYPY
    if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) {
#else
    if (is_list || PySequence_Check(o)) {
#endif
        return PySequence_SetItem(o, i, v);
    }
#endif
    return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
}

static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
    if (likely(PyList_CheckExact(L))) {
        if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
    } else {
        PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
        if (unlikely(!retval))
            return -1;
        Py_DECREF(retval);
    }
    return 0;
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
#if PY_MAJOR_VERSION < 3
    PyObject* owned_ref = NULL;
#endif
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
#if PY_MAJOR_VERSION < 3
    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
        owned_ref = PyUnicode_FromObject(s2);
        if (unlikely(!owned_ref))
            return -1;
        s2 = owned_ref;
        s2_is_unicode = 1;
    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
        owned_ref = PyUnicode_FromObject(s1);
        if (unlikely(!owned_ref))
            return -1;
        s1 = owned_ref;
        s1_is_unicode = 1;
    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
        return __Pyx_PyBytes_Equals(s1, s2, equals);
    }
#endif
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length;
        int kind;
        void *data1, *data2;
        #if CYTHON_PEP393_ENABLED
        if (unlikely(PyUnicode_READY(s1) < 0) || unlikely(PyUnicode_READY(s2) < 0))
            return -1;
        #endif
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
            goto return_ne;
        }
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, length * kind);
            #if PY_MAJOR_VERSION < 3
            Py_XDECREF(owned_ref);
            #endif
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_EQ);
return_ne:
    #if PY_MAJOR_VERSION < 3
    Py_XDECREF(owned_ref);
    #endif
    return (equals == Py_NE);
#endif
}

#if !CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyBytes_Join(PyObject* sep, PyObject* values) {
    return PyObject_CallMethodObjArgs(sep, __pyx_n_s_join, values, NULL)
}
#endif

static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
    if (PY_MAJOR_VERSION >= 3)
        return __Pyx_PyObject_CallMethod1((PyObject*)&PyDict_Type, __pyx_n_s_items, d);
    else
        return PyDict_Items(d);
}

static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
    Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
    for (i=0; i < nbases; i++) {
        PyTypeObject *tmptype;
        PyObject *tmp = PyTuple_GET_ITEM(bases, i);
        tmptype = Py_TYPE(tmp);
#if PY_MAJOR_VERSION < 3
        if (tmptype == &PyClass_Type)
            continue;
#endif
        if (!metaclass) {
            metaclass = tmptype;
            continue;
        }
        if (PyType_IsSubtype(metaclass, tmptype))
            continue;
        if (PyType_IsSubtype(tmptype, metaclass)) {
            metaclass = tmptype;
            continue;
        }
        PyErr_SetString(PyExc_TypeError,
                        "metaclass conflict: "
                        "the metaclass of a derived class "
                        "must be a (non-strict) subclass "
                        "of the metaclasses of all its bases");
        return NULL;
    }
    if (!metaclass) {
#if PY_MAJOR_VERSION < 3
        metaclass = &PyClass_Type;
#else
        metaclass = &PyType_Type;
#endif
    }
    Py_INCREF((PyObject*) metaclass);
    return (PyObject*) metaclass;
}

static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
    PyObject* fake_module;
    PyTypeObject* cached_type = NULL;
    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
    if (!fake_module) return NULL;
    Py_INCREF(fake_module);
    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
    if (cached_type) {
        if (!PyType_Check((PyObject*)cached_type)) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s is not a type object",
                type->tp_name);
            goto bad;
        }
        if (cached_type->tp_basicsize != type->tp_basicsize) {
            PyErr_Format(PyExc_TypeError,
                "Shared Cython type %.200s has the wrong size, try recompiling",
                type->tp_name);
            goto bad;
        }
    } else {
        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
        PyErr_Clear();
        if (PyType_Ready(type) < 0) goto bad;
        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
            goto bad;
        Py_INCREF(type);
        cached_type = type;
    }
done:
    Py_DECREF(fake_module);
    return cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
{
    if (unlikely(op->func_doc == NULL)) {
        if (op->func.m_ml->ml_doc) {
#if PY_MAJOR_VERSION >= 3
            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
#else
            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
#endif
            if (unlikely(op->func_doc == NULL))
                return NULL;
        } else {
            Py_INCREF(Py_None);
            return Py_None;
        }
    }
    Py_INCREF(op->func_doc);
    return op->func_doc;
}
static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp = op->func_doc;
    if (value == NULL)
        value = Py_None; /* Mark as deleted */
    Py_INCREF(value);
    op->func_doc = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_name == NULL)) {
#if PY_MAJOR_VERSION >= 3
        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
#else
        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
#endif
        if (unlikely(op->func_name == NULL))
            return NULL;
    }
    Py_INCREF(op->func_name);
    return op->func_name;
}
static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    tmp = op->func_name;
    Py_INCREF(value);
    op->func_name = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_qualname);
    return op->func_qualname;
}
static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->func_qualname;
    Py_INCREF(value);
    op->func_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
{
    PyObject *self;
    self = m->func_closure;
    if (self == NULL)
        self = Py_None;
    Py_INCREF(self);
    return self;
}
static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
{
    if (unlikely(op->func_dict == NULL)) {
        op->func_dict = PyDict_New();
        if (unlikely(op->func_dict == NULL))
            return NULL;
    }
    Py_INCREF(op->func_dict);
    return op->func_dict;
}
static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
    PyObject *tmp;
    if (unlikely(value == NULL)) {
        PyErr_SetString(PyExc_TypeError,
               "function's dictionary may not be deleted");
        return -1;
    }
    if (unlikely(!PyDict_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
               "setting function's dictionary to a non-dict");
        return -1;
    }
    tmp = op->func_dict;
    Py_INCREF(value);
    op->func_dict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
{
    Py_INCREF(op->func_globals);
    return op->func_globals;
}
static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
{
    Py_INCREF(Py_None);
    return Py_None;
}
static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
{
    PyObject* result = (op->func_code) ? op->func_code : Py_None;
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
    PyObject *res = op->defaults_getter((PyObject *) op);
    if (unlikely(!res))
        return -1;
    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
    Py_INCREF(op->defaults_tuple);
    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
    Py_INCREF(op->defaults_kwdict);
    Py_DECREF(res);
    return 0;
}
static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyTuple_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__defaults__ must be set to a tuple object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_tuple;
    op->defaults_tuple = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_tuple;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_tuple;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value) {
        value = Py_None;
    } else if (value != Py_None && !PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__kwdefaults__ must be set to a dict object");
        return -1;
    }
    Py_INCREF(value);
    tmp = op->defaults_kwdict;
    op->defaults_kwdict = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
    PyObject* result = op->defaults_kwdict;
    if (unlikely(!result)) {
        if (op->defaults_getter) {
            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
            result = op->defaults_kwdict;
        } else {
            result = Py_None;
        }
    }
    Py_INCREF(result);
    return result;
}
static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
    PyObject* tmp;
    if (!value || value == Py_None) {
        value = NULL;
    } else if (!PyDict_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__annotations__ must be set to a dict object");
        return -1;
    }
    Py_XINCREF(value);
    tmp = op->func_annotations;
    op->func_annotations = value;
    Py_XDECREF(tmp);
    return 0;
}
static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
    PyObject* result = op->func_annotations;
    if (unlikely(!result)) {
        result = PyDict_New();
        if (unlikely(!result)) return NULL;
        op->func_annotations = result;
    }
    Py_INCREF(result);
    return result;
}
static PyGetSetDef __pyx_CyFunction_getsets[] = {
    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
    {0, 0, 0, 0, 0}
};
#ifndef PY_WRITE_RESTRICTED /* < Py2.5 */
#define PY_WRITE_RESTRICTED WRITE_RESTRICTED
#endif
static PyMemberDef __pyx_CyFunction_members[] = {
    {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
    {0, 0, 0,  0, 0}
};
static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromString(m->func.m_ml->ml_name);
#else
    return PyString_FromString(m->func.m_ml->ml_name);
#endif
}
static PyMethodDef __pyx_CyFunction_methods[] = {
    {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
    {0, 0, 0, 0}
};
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
    if (op == NULL)
        return NULL;
    op->flags = flags;
    op->func_weakreflist = NULL;
    op->func.m_ml = ml;
    op->func.m_self = (PyObject *) op;
    Py_XINCREF(closure);
    op->func_closure = closure;
    Py_XINCREF(module);
    op->func.m_module = module;
    op->func_dict = NULL;
    op->func_name = NULL;
    Py_INCREF(qualname);
    op->func_qualname = qualname;
    op->func_doc = NULL;
    op->func_classobj = NULL;
    op->func_globals = globals;
    Py_INCREF(op->func_globals);
    Py_XINCREF(code);
    op->func_code = code;
    op->defaults_pyobjects = 0;
    op->defaults = NULL;
    op->defaults_tuple = NULL;
    op->defaults_kwdict = NULL;
    op->defaults_getter = NULL;
    op->func_annotations = NULL;
    PyObject_GC_Track(op);
    return (PyObject *) op;
}
static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
{
    Py_CLEAR(m->func_closure);
    Py_CLEAR(m->func.m_module);
    Py_CLEAR(m->func_dict);
    Py_CLEAR(m->func_name);
    Py_CLEAR(m->func_qualname);
    Py_CLEAR(m->func_doc);
    Py_CLEAR(m->func_globals);
    Py_CLEAR(m->func_code);
    Py_CLEAR(m->func_classobj);
    Py_CLEAR(m->defaults_tuple);
    Py_CLEAR(m->defaults_kwdict);
    Py_CLEAR(m->func_annotations);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_XDECREF(pydefaults[i]);
        PyMem_Free(m->defaults);
        m->defaults = NULL;
    }
    return 0;
}
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
    PyObject_GC_UnTrack(m);
    if (m->func_weakreflist != NULL)
        PyObject_ClearWeakRefs((PyObject *) m);
    __Pyx_CyFunction_clear(m);
    PyObject_GC_Del(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{
    Py_VISIT(m->func_closure);
    Py_VISIT(m->func.m_module);
    Py_VISIT(m->func_dict);
    Py_VISIT(m->func_name);
    Py_VISIT(m->func_qualname);
    Py_VISIT(m->func_doc);
    Py_VISIT(m->func_globals);
    Py_VISIT(m->func_code);
    Py_VISIT(m->func_classobj);
    Py_VISIT(m->defaults_tuple);
    Py_VISIT(m->defaults_kwdict);
    if (m->defaults) {
        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
        int i;
        for (i = 0; i < m->defaults_pyobjects; i++)
            Py_VISIT(pydefaults[i]);
    }
    return 0;
}
static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
        Py_INCREF(func);
        return func;
    }
    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
        if (type == NULL)
            type = (PyObject *)(Py_TYPE(obj));
        return PyMethod_New(func,
                            type, (PyObject *)(Py_TYPE(type)));
    }
    if (obj == Py_None)
        obj = NULL;
    return PyMethod_New(func, obj, type);
}
static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
{
#if PY_MAJOR_VERSION >= 3
    return PyUnicode_FromFormat("<cyfunction %U at %p>",
                                op->func_qualname, (void *)op);
#else
    return PyString_FromFormat("<cyfunction %s at %p>",
                               PyString_AsString(op->func_qualname), (void *)op);
#endif
}
#if CYTHON_COMPILING_IN_PYPY
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyCFunctionObject* f = (PyCFunctionObject*)func;
    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
    PyObject *self = PyCFunction_GET_SELF(func);
    Py_ssize_t size;
    switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) {
    case METH_VARARGS:
        if (likely(kw == NULL) || PyDict_Size(kw) == 0)
            return (*meth)(self, arg);
        break;
    case METH_VARARGS | METH_KEYWORDS:
        return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
    case METH_NOARGS:
        if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
            size = PyTuple_GET_SIZE(arg);
            if (size == 0)
                return (*meth)(self, NULL);
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes no arguments (%zd given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    case METH_O:
        if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
            size = PyTuple_GET_SIZE(arg);
            if (size == 1)
                return (*meth)(self, PyTuple_GET_ITEM(arg, 0));
            PyErr_Format(PyExc_TypeError,
                "%.200s() takes exactly one argument (%zd given)",
                f->m_ml->ml_name, size);
            return NULL;
        }
        break;
    default:
        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
                        "longer supported!");
        return NULL;
    }
    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
                 f->m_ml->ml_name);
    return NULL;
}
#else
static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
	return PyCFunction_Call(func, arg, kw);
}
#endif
static PyTypeObject __pyx_CyFunctionType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    __Pyx_NAMESTR("cython_function_or_method"), /*tp_name*/
    sizeof(__pyx_CyFunctionObject),   /*tp_basicsize*/
    0,                                  /*tp_itemsize*/
    (destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/
    0,                                  /*tp_print*/
    0,                                  /*tp_getattr*/
    0,                                  /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
    0,                                  /*tp_compare*/
#else
    0,                                  /*reserved*/
#endif
    (reprfunc) __Pyx_CyFunction_repr,   /*tp_repr*/
    0,                                  /*tp_as_number*/
    0,                                  /*tp_as_sequence*/
    0,                                  /*tp_as_mapping*/
    0,                                  /*tp_hash*/
    __Pyx_CyFunction_Call,              /*tp_call*/
    0,                                  /*tp_str*/
    0,                                  /*tp_getattro*/
    0,                                  /*tp_setattro*/
    0,                                  /*tp_as_buffer*/
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/
    0,                                  /*tp_doc*/
    (traverseproc) __Pyx_CyFunction_traverse,   /*tp_traverse*/
    (inquiry) __Pyx_CyFunction_clear,   /*tp_clear*/
    0,                                  /*tp_richcompare*/
    offsetof(__pyx_CyFunctionObject, func_weakreflist), /* tp_weaklistoffse */
    0,                                  /*tp_iter*/
    0,                                  /*tp_iternext*/
    __pyx_CyFunction_methods,           /*tp_methods*/
    __pyx_CyFunction_members,           /*tp_members*/
    __pyx_CyFunction_getsets,           /*tp_getset*/
    0,                                  /*tp_base*/
    0,                                  /*tp_dict*/
    __Pyx_CyFunction_descr_get,         /*tp_descr_get*/
    0,                                  /*tp_descr_set*/
    offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/
    0,                                  /*tp_init*/
    0,                                  /*tp_alloc*/
    0,                                  /*tp_new*/
    0,                                  /*tp_free*/
    0,                                  /*tp_is_gc*/
    0,                                  /*tp_bases*/
    0,                                  /*tp_mro*/
    0,                                  /*tp_cache*/
    0,                                  /*tp_subclasses*/
    0,                                  /*tp_weaklist*/
    0,                                  /*tp_del*/
#if PY_VERSION_HEX >= 0x02060000
    0,                                  /*tp_version_tag*/
#endif
#if PY_VERSION_HEX >= 0x030400a1
    0,                                  /*tp_finalize*/
#endif
};
static int __Pyx_CyFunction_init(void) {
#if !CYTHON_COMPILING_IN_PYPY
    __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
#endif
    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
    if (__pyx_CyFunctionType == NULL) {
        return -1;
    }
    return 0;
}
static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults = PyMem_Malloc(size);
    if (!m->defaults)
        return PyErr_NoMemory();
    memset(m->defaults, 0, size);
    m->defaults_pyobjects = pyobjects;
    return m->defaults;
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_tuple = tuple;
    Py_INCREF(tuple);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->defaults_kwdict = dict;
    Py_INCREF(dict);
}
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
    m->func_annotations = dict;
    Py_INCREF(dict);
}

static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
                                           PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
    PyObject *ns;
    if (metaclass) {
        PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
        if (prep) {
            PyObject *pargs = PyTuple_Pack(2, name, bases);
            if (unlikely(!pargs)) {
                Py_DECREF(prep);
                return NULL;
            }
            ns = PyObject_Call(prep, pargs, mkw);
            Py_DECREF(prep);
            Py_DECREF(pargs);
        } else {
            if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
                return NULL;
            PyErr_Clear();
            ns = PyDict_New();
        }
    } else {
        ns = PyDict_New();
    }
    if (unlikely(!ns))
        return NULL;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
    if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
    return ns;
bad:
    Py_DECREF(ns);
    return NULL;
}
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
                                      PyObject *dict, PyObject *mkw,
                                      int calculate_metaclass, int allow_py2_metaclass) {
    PyObject *result, *margs;
    PyObject *owned_metaclass = NULL;
    if (allow_py2_metaclass) {
        owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
        if (owned_metaclass) {
            metaclass = owned_metaclass;
        } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
            PyErr_Clear();
        } else {
            return NULL;
        }
    }
    if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
        metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
        Py_XDECREF(owned_metaclass);
        if (unlikely(!metaclass))
            return NULL;
        owned_metaclass = metaclass;
    }
    margs = PyTuple_Pack(3, name, bases, dict);
    if (unlikely(!margs)) {
        result = NULL;
    } else {
        result = PyObject_Call(metaclass, margs, mkw);
        Py_DECREF(margs);
    }
    Py_XDECREF(owned_metaclass);
    return result;
}

static PyObject *__Pyx_GetNameInClass(PyObject *nmspace, PyObject *name) {
    PyObject *result;
    result = __Pyx_PyObject_GetAttrStr(nmspace, name);
    if (!result)
        result = __Pyx_GetModuleGlobalName(name);
    return result;
}

#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
  #if PY_VERSION_HEX >= 0x02060000
    if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
  #endif
        if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags);
  #if PY_VERSION_HEX < 0x02060000
    if (obj->ob_type->tp_dict) {
        PyObject *getbuffer_cobj = PyObject_GetItem(
            obj->ob_type->tp_dict, __pyx_n_s_pyx_getbuffer);
        if (getbuffer_cobj) {
            getbufferproc func = (getbufferproc) PyCObject_AsVoidPtr(getbuffer_cobj);
            Py_DECREF(getbuffer_cobj);
            if (!func)
                goto fail;
            return func(obj, view, flags);
        } else {
            PyErr_Clear();
        }
    }
  #endif
    PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
#if PY_VERSION_HEX < 0x02060000
fail:
#endif
    return -1;
}
static void __Pyx_ReleaseBuffer(Py_buffer *view) {
    PyObject *obj = view->obj;
    if (!obj) return;
  #if PY_VERSION_HEX >= 0x02060000
    if (PyObject_CheckBuffer(obj)) {
        PyBuffer_Release(view);
        return;
    }
  #endif
        if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; }
  #if PY_VERSION_HEX < 0x02060000
    if (obj->ob_type->tp_dict) {
        PyObject *releasebuffer_cobj = PyObject_GetItem(
            obj->ob_type->tp_dict, __pyx_n_s_pyx_releasebuffer);
        if (releasebuffer_cobj) {
            releasebufferproc func = (releasebufferproc) PyCObject_AsVoidPtr(releasebuffer_cobj);
            Py_DECREF(releasebuffer_cobj);
            if (!func)
                goto fail;
            func(obj, view);
            return;
        } else {
            PyErr_Clear();
        }
    }
  #endif
    goto nofail;
#if PY_VERSION_HEX < 0x02060000
fail:
#endif
    PyErr_WriteUnraisable(obj);
nofail:
    Py_DECREF(obj);
    view->obj = NULL;
}
#endif /*  PY_MAJOR_VERSION < 3 */


              static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_VERSION_HEX < 0x03030000
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    #if PY_VERSION_HEX >= 0x02050000
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                #if PY_VERSION_HEX < 0x03030000
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                #else
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                #endif
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0; /* try absolute import on failure */
        }
        #endif
        if (!module) {
            #if PY_VERSION_HEX < 0x03030000
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
    #else
    if (level>0) {
        PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
        goto bad;
    }
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
    #endif
bad:
    #if PY_VERSION_HEX < 0x03030000
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func)             \
    {                                                                     \
        func_type value = func(x);                                        \
        if (sizeof(target_type) < sizeof(func_type)) {                    \
            if (unlikely(value != (func_type) (target_type) value)) {     \
                func_type zero = 0;                                       \
                PyErr_SetString(PyExc_OverflowError,                      \
                    (is_unsigned && unlikely(value < zero)) ?             \
                    "can't convert negative value to " #target_type :     \
                    "value too large to convert to " #target_type);       \
                return (target_type) -1;                                  \
            }                                                             \
        }                                                                 \
        return (target_type) value;                                       \
    }

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
 #endif
#endif
static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
    const int neg_one = (int) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(int) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG)
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to int");
                return (int) -1;
            }
            return (int) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(int)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (int) ((PyLongObject*)x)->ob_digit[0];
                }
            }
 #endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to int");
                return (int) -1;
            }
            if (sizeof(int) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong)
            } else if (sizeof(int) <= sizeof(unsigned long long)) {
                __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong)
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(int)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(int) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(int) ((PyLongObject*)x)->ob_digit[0];
                }
            }
 #endif
#endif
            if (sizeof(int) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong)
            } else if (sizeof(int) <= sizeof(long long)) {
                __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong)
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            int val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (int) -1;
        }
    } else {
        int val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (int) -1;
        val = __Pyx_PyInt_As_int(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
    const long neg_one = (long) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(long) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(long) <= sizeof(unsigned long long)) {
            return PyLong_FromUnsignedLongLong((unsigned long long) value);
        }
    } else {
        if (sizeof(long) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(long) <= sizeof(long long)) {
            return PyLong_FromLongLong((long long) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(long),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
    const int neg_one = (int) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(int) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(int) <= sizeof(unsigned long long)) {
            return PyLong_FromUnsignedLongLong((unsigned long long) value);
        }
    } else {
        if (sizeof(int) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(int) <= sizeof(long long)) {
            return PyLong_FromLongLong((long long) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(int),
                                     little, !is_unsigned);
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
 #endif
#endif
static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
    const long neg_one = (long) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(long) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG)
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long) -1;
            }
            return (long) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
 #endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long) -1;
            }
            if (sizeof(long) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong)
            } else if (sizeof(long) <= sizeof(unsigned long long)) {
                __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong)
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(long) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
 #endif
#endif
            if (sizeof(long) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong)
            } else if (sizeof(long) <= sizeof(long long)) {
                __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong)
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            long val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (long) -1;
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long) -1;
        val = __Pyx_PyInt_As_long(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PyObject* __Pyx_PyInt_From_short(short value) {
    const short neg_one = (short) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (is_unsigned) {
        if (sizeof(short) < sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(short) <= sizeof(unsigned long)) {
            return PyLong_FromUnsignedLong((unsigned long) value);
        } else if (sizeof(short) <= sizeof(unsigned long long)) {
            return PyLong_FromUnsignedLongLong((unsigned long long) value);
        }
    } else {
        if (sizeof(short) <= sizeof(long)) {
            return PyInt_FromLong((long) value);
        } else if (sizeof(short) <= sizeof(long long)) {
            return PyLong_FromLongLong((long long) value);
        }
    }
    {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&value;
        return _PyLong_FromByteArray(bytes, sizeof(short),
                                     little, !is_unsigned);
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
 #endif
#endif
static CYTHON_INLINE short __Pyx_PyInt_As_short(PyObject *x) {
    const short neg_one = (short) -1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        if (sizeof(short) < sizeof(long)) {
            __PYX_VERIFY_RETURN_INT(short, long, PyInt_AS_LONG)
        } else {
            long val = PyInt_AS_LONG(x);
            if (is_unsigned && unlikely(val < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to short");
                return (short) -1;
            }
            return (short) val;
        }
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(short)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (short) ((PyLongObject*)x)->ob_digit[0];
                }
            }
 #endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to short");
                return (short) -1;
            }
            if (sizeof(short) <= sizeof(unsigned long)) {
                __PYX_VERIFY_RETURN_INT(short, unsigned long, PyLong_AsUnsignedLong)
            } else if (sizeof(short) <= sizeof(unsigned long long)) {
                __PYX_VERIFY_RETURN_INT(short, unsigned long long, PyLong_AsUnsignedLongLong)
            }
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(short)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(short) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(short) ((PyLongObject*)x)->ob_digit[0];
                }
            }
 #endif
#endif
            if (sizeof(short) <= sizeof(long)) {
                __PYX_VERIFY_RETURN_INT(short, long, PyLong_AsLong)
            } else if (sizeof(short) <= sizeof(long long)) {
                __PYX_VERIFY_RETURN_INT(short, long long, PyLong_AsLongLong)
            }
        }
        {
#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
            PyErr_SetString(PyExc_RuntimeError,
                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
#else
            short val;
            PyObject *v = __Pyx_PyNumber_Int(x);
 #if PY_MAJOR_VERSION < 3
            if (likely(v) && !PyLong_Check(v)) {
                PyObject *tmp = v;
                v = PyNumber_Long(tmp);
                Py_DECREF(tmp);
            }
 #endif
            if (likely(v)) {
                int one = 1; int is_little = (int)*(unsigned char *)&one;
                unsigned char *bytes = (unsigned char *)&val;
                int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                              bytes, sizeof(val),
                                              is_little, !is_unsigned);
                Py_DECREF(v);
                if (likely(!ret))
                    return val;
            }
#endif
            return (short) -1;
        }
    } else {
        short val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (short) -1;
        val = __Pyx_PyInt_As_short(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return ::std::complex< float >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      return x + y*(__pyx_t_float_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
      __pyx_t_float_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

#if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
        __pyx_t_float_complex z;
        float denom = b.real * b.real + b.imag * b.imag;
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
        return z;
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) {
        __pyx_t_float_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrtf(z.real*z.real + z.imag*z.imag);
          #else
            return hypotf(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
            __pyx_t_float_complex z;
            float r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    float denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(a, a);
                    case 3:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(z, a);
                    case 4:
                        z = __Pyx_c_prodf(a, a);
                        return __Pyx_c_prodf(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                }
                r = a.real;
                theta = 0;
            } else {
                r = __Pyx_c_absf(a);
                theta = atan2f(a.imag, a.real);
            }
            lnr = logf(r);
            z_r = expf(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cosf(z_theta);
            z.imag = z_r * sinf(z_theta);
            return z;
        }
    #endif
#endif

#if CYTHON_CCOMPLEX
  #ifdef __cplusplus
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return ::std::complex< double >(x, y);
    }
  #else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      return x + y*(__pyx_t_double_complex)_Complex_I;
    }
  #endif
#else
    static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
      __pyx_t_double_complex z;
      z.real = x;
      z.imag = y;
      return z;
    }
#endif

#if CYTHON_CCOMPLEX
#else
    static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) {
       return (a.real == b.real) && (a.imag == b.imag);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real + b.real;
        z.imag = a.imag + b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real - b.real;
        z.imag = a.imag - b.imag;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        z.real = a.real * b.real - a.imag * b.imag;
        z.imag = a.real * b.imag + a.imag * b.real;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) {
        __pyx_t_double_complex z;
        double denom = b.real * b.real + b.imag * b.imag;
        z.real = (a.real * b.real + a.imag * b.imag) / denom;
        z.imag = (a.imag * b.real - a.real * b.imag) / denom;
        return z;
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real = -a.real;
        z.imag = -a.imag;
        return z;
    }
    static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) {
       return (a.real == 0) && (a.imag == 0);
    }
    static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) {
        __pyx_t_double_complex z;
        z.real =  a.real;
        z.imag = -a.imag;
        return z;
    }
    #if 1
        static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) {
          #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
            return sqrt(z.real*z.real + z.imag*z.imag);
          #else
            return hypot(z.real, z.imag);
          #endif
        }
        static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) {
            __pyx_t_double_complex z;
            double r, lnr, theta, z_r, z_theta;
            if (b.imag == 0 && b.real == (int)b.real) {
                if (b.real < 0) {
                    double denom = a.real * a.real + a.imag * a.imag;
                    a.real = a.real / denom;
                    a.imag = -a.imag / denom;
                    b.real = -b.real;
                }
                switch ((int)b.real) {
                    case 0:
                        z.real = 1;
                        z.imag = 0;
                        return z;
                    case 1:
                        return a;
                    case 2:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(a, a);
                    case 3:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(z, a);
                    case 4:
                        z = __Pyx_c_prod(a, a);
                        return __Pyx_c_prod(z, z);
                }
            }
            if (a.imag == 0) {
                if (a.real == 0) {
                    return a;
                }
                r = a.real;
                theta = 0;
            } else {
                r = __Pyx_c_abs(a);
                theta = atan2(a.imag, a.real);
            }
            lnr = log(r);
            z_r = exp(lnr * b.real - theta * b.imag);
            z_theta = theta * b.real + lnr * b.imag;
            z.real = z_r * cos(z_theta);
            z.imag = z_r * sin(z_theta);
            return z;
        }
    #endif
#endif

static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
#else
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
#endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}

static PyObject *__Pyx_Generator_Next(PyObject *self);
static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value);
static PyObject *__Pyx_Generator_Close(PyObject *self);
static PyObject *__Pyx_Generator_Throw(PyObject *gen, PyObject *args);
static PyTypeObject *__pyx_GeneratorType = 0;
#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
#define __Pyx_Generator_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
#if 1 || PY_VERSION_HEX < 0x030300B0
static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    __Pyx_ErrFetch(&et, &ev, &tb);
    if (!et) {
        Py_XDECREF(tb);
        Py_XDECREF(ev);
        Py_INCREF(Py_None);
        *pvalue = Py_None;
        return 0;
    }
    if (unlikely(et != PyExc_StopIteration) &&
            unlikely(!PyErr_GivenExceptionMatches(et, PyExc_StopIteration))) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    if (likely(et == PyExc_StopIteration)) {
        if (likely(!ev) || !PyObject_IsInstance(ev, PyExc_StopIteration)) {
            if (!ev) {
                Py_INCREF(Py_None);
                ev = Py_None;
            }
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = ev;
            return 0;
        }
    }
    PyErr_NormalizeException(&et, &ev, &tb);
    if (unlikely(!PyObject_IsInstance(ev, PyExc_StopIteration))) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    Py_XDECREF(tb);
    Py_DECREF(et);
#if PY_VERSION_HEX >= 0x030300A0
    value = ((PyStopIterationObject *)ev)->value;
    Py_INCREF(value);
    Py_DECREF(ev);
#else
    {
        PyObject* args = PyObject_GetAttr(ev, __pyx_n_s_args);
        Py_DECREF(ev);
        if (likely(args)) {
            value = PyObject_GetItem(args, 0);
            Py_DECREF(args);
        }
        if (unlikely(!value)) {
            __Pyx_ErrRestore(NULL, NULL, NULL);
            Py_INCREF(Py_None);
            value = Py_None;
        }
    }
#endif
    *pvalue = value;
    return 0;
}
#endif
static CYTHON_INLINE
void __Pyx_Generator_ExceptionClear(__pyx_GeneratorObject *self) {
    PyObject *exc_type = self->exc_type;
    PyObject *exc_value = self->exc_value;
    PyObject *exc_traceback = self->exc_traceback;
    self->exc_type = NULL;
    self->exc_value = NULL;
    self->exc_traceback = NULL;
    Py_XDECREF(exc_type);
    Py_XDECREF(exc_value);
    Py_XDECREF(exc_traceback);
}
static CYTHON_INLINE
int __Pyx_Generator_CheckRunning(__pyx_GeneratorObject *gen) {
    if (unlikely(gen->is_running)) {
        PyErr_SetString(PyExc_ValueError,
                        "generator already executing");
        return 1;
    }
    return 0;
}
static CYTHON_INLINE
PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value) {
    PyObject *retval;
    assert(!self->is_running);
    if (unlikely(self->resume_label == 0)) {
        if (unlikely(value && value != Py_None)) {
            PyErr_SetString(PyExc_TypeError,
                            "can't send non-None value to a "
                            "just-started generator");
            return NULL;
        }
    }
    if (unlikely(self->resume_label == -1)) {
        PyErr_SetNone(PyExc_StopIteration);
        return NULL;
    }
    if (value) {
#if CYTHON_COMPILING_IN_PYPY
#else
        /* Generators always return to their most recent caller, not
         * necessarily their creator. */
        if (self->exc_traceback) {
            PyThreadState *tstate = PyThreadState_GET();
            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_XINCREF(tstate->frame);
            assert(f->f_back == NULL);
            f->f_back = tstate->frame;
        }
#endif
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
    } else {
        __Pyx_Generator_ExceptionClear(self);
    }
    self->is_running = 1;
    retval = self->body((PyObject *) self, value);
    self->is_running = 0;
    if (retval) {
        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
                            &self->exc_traceback);
#if CYTHON_COMPILING_IN_PYPY
#else
        /* Don't keep the reference to f_back any longer than necessary.  It
         * may keep a chain of frames alive or it could create a reference
         * cycle. */
        if (self->exc_traceback) {
            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
            PyFrameObject *f = tb->tb_frame;
            Py_CLEAR(f->f_back);
        }
#endif
    } else {
        __Pyx_Generator_ExceptionClear(self);
    }
    return retval;
}
static CYTHON_INLINE
PyObject *__Pyx_Generator_FinishDelegation(__pyx_GeneratorObject *gen) {
    PyObject *ret;
    PyObject *val = NULL;
    __Pyx_Generator_Undelegate(gen);
    __Pyx_PyGen_FetchStopIterationValue(&val);
    ret = __Pyx_Generator_SendEx(gen, val);
    Py_XDECREF(val);
    return ret;
}
static PyObject *__Pyx_Generator_Next(PyObject *self) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(__Pyx_Generator_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        ret = Py_TYPE(yf)->tp_iternext(yf);
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        return __Pyx_Generator_FinishDelegation(gen);
    }
    return __Pyx_Generator_SendEx(gen, Py_None);
}
static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self;
    PyObject *yf = gen->yieldfrom;
    if (unlikely(__Pyx_Generator_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        gen->is_running = 1;
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Send(yf, value);
        } else {
            if (value == Py_None)
                ret = PyIter_Next(yf);
            else
                ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
        }
        gen->is_running = 0;
        if (likely(ret)) {
            return ret;
        }
        return __Pyx_Generator_FinishDelegation(gen);
    }
    return __Pyx_Generator_SendEx(gen, value);
}
static int __Pyx_Generator_CloseIter(__pyx_GeneratorObject *gen, PyObject *yf) {
    PyObject *retval = NULL;
    int err = 0;
    if (__Pyx_Generator_CheckExact(yf)) {
        retval = __Pyx_Generator_Close(yf);
        if (!retval)
            return -1;
    } else {
        PyObject *meth;
        gen->is_running = 1;
        meth = PyObject_GetAttr(yf, __pyx_n_s_close);
        if (unlikely(!meth)) {
            if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyErr_WriteUnraisable(yf);
            }
            PyErr_Clear();
        } else {
            retval = PyObject_CallFunction(meth, NULL);
            Py_DECREF(meth);
            if (!retval)
                err = -1;
        }
        gen->is_running = 0;
    }
    Py_XDECREF(retval);
    return err;
}
static PyObject *__Pyx_Generator_Close(PyObject *self) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
    PyObject *retval, *raised_exception;
    PyObject *yf = gen->yieldfrom;
    int err = 0;
    if (unlikely(__Pyx_Generator_CheckRunning(gen)))
        return NULL;
    if (yf) {
        Py_INCREF(yf);
        err = __Pyx_Generator_CloseIter(gen, yf);
        __Pyx_Generator_Undelegate(gen);
        Py_DECREF(yf);
    }
    if (err == 0)
#if PY_VERSION_HEX < 0x02050000
        PyErr_SetNone(PyExc_StopIteration);
#else
        PyErr_SetNone(PyExc_GeneratorExit);
#endif
    retval = __Pyx_Generator_SendEx(gen, NULL);
    if (retval) {
        Py_DECREF(retval);
        PyErr_SetString(PyExc_RuntimeError,
                        "generator ignored GeneratorExit");
        return NULL;
    }
    raised_exception = PyErr_Occurred();
    if (!raised_exception
        || raised_exception == PyExc_StopIteration
#if PY_VERSION_HEX >= 0x02050000
        || raised_exception == PyExc_GeneratorExit
        || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit)
#endif
        || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration))
    {
        if (raised_exception) PyErr_Clear();      /* ignore these errors */
        Py_INCREF(Py_None);
        return Py_None;
    }
    return NULL;
}
static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
    PyObject *typ;
    PyObject *tb = NULL;
    PyObject *val = NULL;
    PyObject *yf = gen->yieldfrom;
    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
        return NULL;
    if (unlikely(__Pyx_Generator_CheckRunning(gen)))
        return NULL;
    if (yf) {
        PyObject *ret;
        Py_INCREF(yf);
#if PY_VERSION_HEX >= 0x02050000
        if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) {
            int err = __Pyx_Generator_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Generator_Undelegate(gen);
            if (err < 0)
                return __Pyx_Generator_SendEx(gen, NULL);
            goto throw_here;
        }
#endif
        gen->is_running = 1;
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Throw(yf, args);
        } else {
            PyObject *meth = PyObject_GetAttr(yf, __pyx_n_s_throw);
            if (unlikely(!meth)) {
                Py_DECREF(yf);
                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
                    gen->is_running = 0;
                    return NULL;
                }
                PyErr_Clear();
                __Pyx_Generator_Undelegate(gen);
                gen->is_running = 0;
                goto throw_here;
            }
            ret = PyObject_CallObject(meth, args);
            Py_DECREF(meth);
        }
        gen->is_running = 0;
        Py_DECREF(yf);
        if (!ret) {
            ret = __Pyx_Generator_FinishDelegation(gen);
        }
        return ret;
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
    return __Pyx_Generator_SendEx(gen, NULL);
}
static int __Pyx_Generator_traverse(PyObject *self, visitproc visit, void *arg) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
    Py_VISIT(gen->closure);
    Py_VISIT(gen->classobj);
    Py_VISIT(gen->yieldfrom);
    Py_VISIT(gen->exc_type);
    Py_VISIT(gen->exc_value);
    Py_VISIT(gen->exc_traceback);
    return 0;
}
static int __Pyx_Generator_clear(PyObject *self) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
    Py_CLEAR(gen->closure);
    Py_CLEAR(gen->classobj);
    Py_CLEAR(gen->yieldfrom);
    Py_CLEAR(gen->exc_type);
    Py_CLEAR(gen->exc_value);
    Py_CLEAR(gen->exc_traceback);
    return 0;
}
static void __Pyx_Generator_dealloc(PyObject *self) {
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
    PyObject_GC_UnTrack(gen);
    if (gen->gi_weakreflist != NULL)
        PyObject_ClearWeakRefs(self);
    if (gen->resume_label > 0) {
        PyObject_GC_Track(self);
#if PY_VERSION_HEX >= 0x030400a1
        if (PyObject_CallFinalizerFromDealloc(self))
#else
        Py_TYPE(gen)->tp_del(self);
        if (self->ob_refcnt > 0)
#endif
            return;                     /* resurrected.  :( */
        PyObject_GC_UnTrack(self);
    }
    __Pyx_Generator_clear(self);
    PyObject_GC_Del(gen);
}
static void __Pyx_Generator_del(PyObject *self) {
    PyObject *res;
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
    if (gen->resume_label <= 0)
        return ;
#if PY_VERSION_HEX < 0x030400a1
    assert(self->ob_refcnt == 0);
    self->ob_refcnt = 1;
#endif
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
    res = __Pyx_Generator_Close(self);
    if (res == NULL)
        PyErr_WriteUnraisable(self);
    else
        Py_DECREF(res);
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
#if PY_VERSION_HEX < 0x030400a1
    /* Undo the temporary resurrection; can't use DECREF here, it would
     * cause a recursive call.
     */
    assert(self->ob_refcnt > 0);
    if (--self->ob_refcnt == 0)
        return; /* this is the normal path out */
    /* close() resurrected it!  Make it look like the original Py_DECREF
     * never happened.
     */
    {
        Py_ssize_t refcnt = self->ob_refcnt;
        _Py_NewReference(self);
        self->ob_refcnt = refcnt;
    }
#if CYTHON_COMPILING_IN_CPYTHON
    assert(PyType_IS_GC(self->ob_type) &&
           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
    /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
     * we need to undo that. */
    _Py_DEC_REFTOTAL;
#endif
    /* If Py_TRACE_REFS, _Py_NewReference re-added self to the object
     * chain, so no more to do there.
     * If COUNT_ALLOCS, the original decref bumped tp_frees, and
     * _Py_NewReference bumped tp_allocs:  both of those need to be
     * undone.
     */
#ifdef COUNT_ALLOCS
    --Py_TYPE(self)->tp_frees;
    --Py_TYPE(self)->tp_allocs;
#endif
#endif
}
static PyMemberDef __pyx_Generator_memberlist[] = {
    {(char *) "gi_running",
#if PY_VERSION_HEX >= 0x02060000
     T_BOOL,
#else
     T_BYTE,
#endif
     offsetof(__pyx_GeneratorObject, is_running),
     READONLY,
     NULL},
    {0, 0, 0, 0, 0}
};
static PyMethodDef __pyx_Generator_methods[] = {
    {__Pyx_NAMESTR("send"), (PyCFunction) __Pyx_Generator_Send, METH_O, 0},
    {__Pyx_NAMESTR("throw"), (PyCFunction) __Pyx_Generator_Throw, METH_VARARGS, 0},
    {__Pyx_NAMESTR("close"), (PyCFunction) __Pyx_Generator_Close, METH_NOARGS, 0},
    {0, 0, 0, 0}
};
static PyTypeObject __pyx_GeneratorType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    __Pyx_NAMESTR("generator"),         /*tp_name*/
    sizeof(__pyx_GeneratorObject),      /*tp_basicsize*/
    0,                                  /*tp_itemsize*/
    (destructor) __Pyx_Generator_dealloc,/*tp_dealloc*/
    0,                                  /*tp_print*/
    0,                                  /*tp_getattr*/
    0,                                  /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
    0,                                  /*tp_compare*/
#else
    0,                                  /*reserved*/
#endif
    0,                                   /*tp_repr*/
    0,                                  /*tp_as_number*/
    0,                                  /*tp_as_sequence*/
    0,                                  /*tp_as_mapping*/
    0,                                  /*tp_hash*/
    0,                                  /*tp_call*/
    0,                                  /*tp_str*/
    0,                                  /*tp_getattro*/
    0,                                  /*tp_setattro*/
    0,                                  /*tp_as_buffer*/
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, /* tp_flags*/
    0,                                  /*tp_doc*/
    (traverseproc) __Pyx_Generator_traverse,   /*tp_traverse*/
    0,                                  /*tp_clear*/
    0,                                  /*tp_richcompare*/
    offsetof(__pyx_GeneratorObject, gi_weakreflist), /* tp_weaklistoffse */
    0,                                  /*tp_iter*/
    (iternextfunc) __Pyx_Generator_Next, /*tp_iternext*/
    __pyx_Generator_methods,            /*tp_methods*/
    __pyx_Generator_memberlist,         /*tp_members*/
    0,                                  /*tp_getset*/
    0,                                  /*tp_base*/
    0,                                  /*tp_dict*/
    0,                                  /*tp_descr_get*/
    0,                                  /*tp_descr_set*/
    0,                                  /*tp_dictoffset*/
    0,                                  /*tp_init*/
    0,                                  /*tp_alloc*/
    0,                                  /*tp_new*/
    0,                                  /*tp_free*/
    0,                                  /*tp_is_gc*/
    0,                                  /*tp_bases*/
    0,                                  /*tp_mro*/
    0,                                  /*tp_cache*/
    0,                                  /*tp_subclasses*/
    0,                                  /*tp_weaklist*/
#if PY_VERSION_HEX >= 0x030400a1
    0,                                  /*tp_del*/
#else
    __Pyx_Generator_del,                /*tp_del*/
#endif
#if PY_VERSION_HEX >= 0x02060000
    0,                                  /*tp_version_tag*/
#endif
#if PY_VERSION_HEX >= 0x030400a1
    __Pyx_Generator_del,                /*tp_finalize*/
#endif
};
static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
                                                  PyObject *closure) {
    __pyx_GeneratorObject *gen =
        PyObject_GC_New(__pyx_GeneratorObject, &__pyx_GeneratorType_type);
    if (gen == NULL)
        return NULL;
    gen->body = body;
    gen->closure = closure;
    Py_XINCREF(closure);
    gen->is_running = 0;
    gen->resume_label = 0;
    gen->classobj = NULL;
    gen->yieldfrom = NULL;
    gen->exc_type = NULL;
    gen->exc_value = NULL;
    gen->exc_traceback = NULL;
    gen->gi_weakreflist = NULL;
    PyObject_GC_Track(gen);
    return gen;
}
static int __pyx_Generator_init(void) {
    __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr;
    __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
    __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
    if (__pyx_GeneratorType == NULL) {
        return -1;
    }
    return 0;
}

static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        #if PY_VERSION_HEX < 0x02050000
        return PyErr_Warn(NULL, message);
        #else
        return PyErr_WarnEx(NULL, message, 1);
        #endif
    }
    return 0;
}

static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__");
    if (!d) {
        PyErr_Clear();
        d = PyDict_New();
        if (!d)
            goto bad;
        Py_INCREF(d);
        if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0)
            goto bad;
    }
    tmp.fp = f;
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    cobj = PyCapsule_New(tmp.p, sig, 0);
#else
    cobj = PyCObject_FromVoidPtrAndDesc(tmp.p, (void *)sig, 0);
#endif
    if (!cobj)
        goto bad;
    if (PyDict_SetItemString(d, name, cobj) < 0)
        goto bad;
    Py_DECREF(cobj);
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(cobj);
    Py_XDECREF(d);
    return -1;
}

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%.200s.%.200s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if (!strict && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        if (PyErr_Warn(NULL, warning) < 0) goto bad;
        #else
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
        #endif
    }
    else if ((size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%.200s.%.200s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = (start + end) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,            /*int argcount,*/
        0,            /*int kwonlyargcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,      /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_globals = 0;
    PyFrameObject *py_frame = 0;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str));
}
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
#if PY_VERSION_HEX < 0x03030000
        char* defenc_c;
        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
        if (!defenc) return NULL;
        defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        {
            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
            char* c;
            for (c = defenc_c; c < end; c++) {
                if ((unsigned char) (*c) >= 128) {
                    PyUnicode_AsASCIIString(o);
                    return NULL;
                }
            }
        }
#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/
        *length = PyBytes_GET_SIZE(defenc);
        return defenc_c;
#else /* PY_VERSION_HEX < 0x03030000 */
        if (PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (PyUnicode_IS_ASCII(o)) {
            *length = PyUnicode_GET_DATA_SIZE(o);
            return PyUnicode_AsUTF8(o);
        } else {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
        return PyUnicode_AsUTF8AndSize(o, length);
#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
#endif /* PY_VERSION_HEX < 0x03030000 */
    } else
#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII  || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */
#if PY_VERSION_HEX >= 0x02060000
    if (PyByteArray_Check(o)) {
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
    } else
#endif
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_MAJOR_VERSION < 3
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%.4s__ returned non-%.4s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
 #if CYTHON_USE_PYLONG_INTERNALS
  #include "longintrepr.h"
 #endif
#endif
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
#if PY_MAJOR_VERSION < 3
  if (likely(PyInt_CheckExact(b)))
      return PyInt_AS_LONG(b);
#endif
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
     #if CYTHON_USE_PYLONG_INTERNALS
       switch (Py_SIZE(b)) {
       case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
       case  0: return 0;
       case  1: return ((PyLongObject*)b)->ob_digit[0];
       }
     #endif
    #endif
  #if PY_VERSION_HEX < 0x02060000
    return PyInt_AsSsize_t(b);
  #else
    return PyLong_AsSsize_t(b);
  #endif
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}


#endif /* Py_PYTHON_H */
