Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (4)
New upstream version 1.0.5
· 16d6e5a7
Bas Couwenberg
authored
Sep 20, 2018
16d6e5a7
Merge tag 'upstream/1.0.5'
· 4acd6678
Bas Couwenberg
authored
Sep 20, 2018
Upstream version 1.0.5
4acd6678
New upstream release.
· ebdd4f10
Bas Couwenberg
authored
Sep 20, 2018
ebdd4f10
Set distribution to unstable.
· 5c630ea4
Bas Couwenberg
authored
Sep 20, 2018
5c630ea4
Show whitespace changes
Inline
Side-by-side
CHANGES.txt
View file @
5c630ea4
Changes
=======
1.0.5 (2018-09-19)
------------------
Bug fixes:
- The fill value for boundless reads was ignored in Rasterio versions 1-1.0.4
but now applies (#1471).
- An invalid shortcut has been eliminated a Rasterio now prroduces a proper
mask in the boundless masked read case (#1449).
- Loss of a row or column in geometry_window() and mask() has been fixed
(#1472).
1.0.4 (2018-09-17)
------------------
...
...
Makefile
View file @
5c630ea4
...
...
@@ -15,6 +15,9 @@ clean:
find
.
-name
'__pycache__'
-delete
-print
-o
-name
'*.pyc'
-delete
-print
touch
rasterio/
*
.pyx
sdist
:
python setup.py sdist
test
:
py.test
--maxfail
1
-v
--cov
rasterio
--cov-report
html
--pdb
tests
...
...
debian/changelog
View file @
5c630ea4
rasterio (1.0.5-1) unstable; urgency=medium
* Team upload.
* New upstream release.
-- Bas Couwenberg <sebastic@debian.org> Thu, 20 Sep 2018 07:19:02 +0200
rasterio (1.0.4-1) unstable; urgency=medium
* Team upload.
...
...
rasterio/__init__.py
View file @
5c630ea4
...
...
@@ -43,7 +43,7 @@ import rasterio.path
__all__
=
[
'
band
'
,
'
open
'
,
'
pad
'
,
'
Env
'
]
__version__
=
"
1.0.
4
"
__version__
=
"
1.0.
5
"
__gdal_version__
=
gdal_version
()
# Rasterio attaches NullHandler to the 'rasterio' logger and its
...
...
rasterio/_env.pyx
View file @
5c630ea4
...
...
@@ -181,7 +181,6 @@ cdef class ConfigEnv(object):
while
self
.
options
:
key
,
val
=
self
.
options
.
popitem
()
del_gdal_config
(
key
)
log
.
debug
(
"
Unset option %s in env %r
"
,
key
,
self
)
def
get_config_options
(
self
):
return
{
k
:
get_gdal_config
(
k
)
for
k
in
self
.
options
}
...
...
rasterio/_io.pyx
View file @
5c630ea4
...
...
@@ -375,7 +375,7 @@ cdef class DatasetReaderBase(DatasetBase):
else
:
vrt_doc
=
_boundless_vrt_doc
(
self
,
nodata
=
ndv
,
width
=
max
(
self
.
width
,
window
.
width
)
+
1
,
self
,
nodata
=
ndv
,
hidenodata
=
bool
(
fill_value
),
width
=
max
(
self
.
width
,
window
.
width
)
+
1
,
height
=
max
(
self
.
height
,
window
.
height
)
+
1
,
transform
=
self
.
window_transform
(
window
)).
decode
(
'
ascii
'
)
...
...
@@ -390,9 +390,6 @@ cdef class DatasetReaderBase(DatasetBase):
None
,
resampling
=
resampling
)
if
masked
:
if
all_valid
:
mask
=
np
.
ma
.
nomask
else
:
mask
=
np
.
zeros
(
out
.
shape
,
'
uint8
'
)
mask
=
~
vrt
.
_read
(
indexes
,
mask
,
Window
(
0
,
0
,
window
.
width
,
window
.
height
),
None
,
masks
=
True
).
astype
(
'
bool
'
)
...
...
rasterio/env.py
View file @
5c630ea4
...
...
@@ -3,6 +3,7 @@
import
attr
from
functools
import
wraps
,
total_ordering
import
logging
import
os
import
re
import
threading
import
warnings
...
...
@@ -15,7 +16,7 @@ from rasterio.dtypes import check_dtype
from
rasterio.errors
import
(
EnvError
,
GDALVersionError
,
RasterioDeprecationWarning
)
from
rasterio.path
import
parse_path
,
UnparsedPath
,
ParsedPath
from
rasterio.session
import
Session
,
AWSSession
from
rasterio.session
import
Session
,
AWSSession
,
DummySession
from
rasterio.transform
import
guard_transform
...
...
@@ -105,11 +106,8 @@ class Env(object):
"
RASTERIO_ENV
"
: True
}
def __init__(
self, session=None, aws_unsigned=False, aws_access_key_id=None,
aws_secret_access_key=None, aws_session_token=None,
region_name=None, profile_name=None, session_class=AWSSession,
**options):
def __init__(self, session=None, aws_unsigned=False, profile_name=None,
session_class=AWSSession, **options):
"""
Create a new GDAL/AWS environment.
Note: this class is a context manager. GDAL isn
'
t
configured
...
...
@@ -119,16 +117,8 @@ class Env(object):
----------
session : optional
A Session object.
aws_unsigned : bool, optional (default: False)
If True, requests will be unsigned.
aws_access_key_id : str, optional
An access key id, as per boto3.
aws_secret_access_key : str, optional
A secret access key, as per boto3.
aws_session_token : str, optional
A session token, as per boto3.
region_name : str, optional
A region name, as per boto3.
aws_unsigned : bool, optional
Do not sign cloud requests.
profile_name : str, optional
A shared credentials profile name, as per boto3.
session_class : Session, optional
...
...
@@ -165,6 +155,20 @@ class Env(object):
...
print
(
src
.
profile
)
"""
aws_access_key_id
=
options
.
pop
(
'
aws_access_key_id
'
,
None
)
# Before 1.0, Rasterio only supported AWS. We will special
# case AWS in 1.0.x. TODO: warn deprecation in 1.1.
if
aws_access_key_id
:
warnings
.
warn
(
"
Passing abstract session keyword arguments is deprecated.
"
"
Pass a Rasterio AWSSession object instead.
"
,
RasterioDeprecationWarning
)
aws_secret_access_key
=
options
.
pop
(
'
aws_secret_access_key
'
,
None
)
aws_session_token
=
options
.
pop
(
'
aws_session_token
'
,
None
)
region_name
=
options
.
pop
(
'
region_name
'
,
None
)
if
(
'
AWS_ACCESS_KEY_ID
'
in
options
or
'
AWS_SECRET_ACCESS_KEY
'
in
options
):
raise
EnvError
(
...
...
@@ -182,14 +186,7 @@ class Env(object):
)
session
=
AWSSession
(
session
=
session
)
self
.
session
=
session
else
:
# Before 1.0, Rasterio only supported AWS. We will special
# case AWS in 1.0.x. TODO: warn deprecation in 1.1.
warnings
.
warn
(
"
Passing abstract session keyword arguments is deprecated.
"
"
Pass a Rasterio AWSSession object instead.
"
,
RasterioDeprecationWarning
)
elif
aws_access_key_id
or
profile_name
or
aws_unsigned
:
self
.
session
=
AWSSession
(
aws_access_key_id
=
aws_access_key_id
,
aws_secret_access_key
=
aws_secret_access_key
,
...
...
@@ -197,6 +194,10 @@ class Env(object):
region_name
=
region_name
,
profile_name
=
profile_name
,
aws_unsigned
=
aws_unsigned
)
elif
'
AWS_ACCESS_KEY_ID
'
in
os
.
environ
:
self
.
session
=
AWSSession
()
else
:
self
.
session
=
DummySession
()
self
.
options
=
options
.
copy
()
self
.
context_options
=
{}
...
...
@@ -272,7 +273,6 @@ class Env(object):
val
=
get_gdal_config
(
key
,
normalize
=
False
)
if
val
is
not
None
:
local
.
_discovered_options
[
key
]
=
val
log
.
debug
(
"
Discovered option: %s=%s
"
,
key
,
val
)
defenv
(
**
self
.
options
)
self
.
context_options
=
{}
...
...
@@ -299,8 +299,6 @@ class Env(object):
while
local
.
_discovered_options
:
key
,
val
=
local
.
_discovered_options
.
popitem
()
set_gdal_config
(
key
,
val
,
normalize
=
False
)
log
.
debug
(
"
Set discovered option back to:
'
%s=%s
"
,
key
,
val
)
local
.
_discovered_options
=
None
log
.
debug
(
"
Exited env context: %r
"
,
self
)
...
...
@@ -337,7 +335,6 @@ def setenv(**options):
raise
EnvError
(
"
No GDAL environment exists
"
)
else
:
local
.
_env
.
update_config_options
(
**
options
)
log
.
debug
(
"
Updated existing %r with options %r
"
,
local
.
_env
,
options
)
def
hascreds
():
...
...
@@ -402,7 +399,6 @@ def ensure_env_credentialled(f):
session
=
Session
.
from_path
(
None
)
with
env_ctor
(
session
=
session
):
log
.
debug
(
"
Credentialized: {!r}
"
.
format
(
getenv
()))
return
f
(
*
args
,
**
kwds
)
return
wrapper
...
...
rasterio/features.py
View file @
5c630ea4
...
...
@@ -410,8 +410,10 @@ def geometry_window(dataset, shapes, pad_x=0, pad_y=0, north_up=True,
right
,
bottom
=
(
right
,
bottom
)
*
dataset
.
transform
window
=
dataset
.
window
(
left
,
bottom
,
right
,
top
)
window
=
window
.
round_offsets
(
op
=
'
floor
'
,
pixel_precision
=
pixel_precision
)
window
=
window
.
round_shape
(
op
=
'
ceil
'
,
pixel_precision
=
pixel_precision
)
window_floored
=
window
.
round_offsets
(
op
=
'
floor
'
,
pixel_precision
=
pixel_precision
)
w
=
math
.
ceil
(
window
.
width
+
window
.
col_off
-
window_floored
.
col_off
)
h
=
math
.
ceil
(
window
.
height
+
window
.
row_off
-
window_floored
.
row_off
)
window
=
Window
(
window_floored
.
col_off
,
window_floored
.
row_off
,
w
,
h
)
# Make sure that window overlaps raster
raster_window
=
Window
(
0
,
0
,
dataset
.
width
,
dataset
.
height
)
...
...
rasterio/rio/main.py
View file @
5c630ea4
...
...
@@ -91,11 +91,13 @@ def main_group(
ctx
.
obj
=
{}
ctx
.
obj
[
"
verbosity
"
]
=
verbosity
ctx
.
obj
[
"
aws_profile
"
]
=
aws_profile
envopts
=
{
"
CPL_DEBUG
"
:
(
verbosity
>
2
)}
if
aws_profile
or
aws_no_sign_requests
:
ctx
.
obj
[
"
env
"
]
=
rasterio
.
Env
(
session
=
AWSSession
(
profile_name
=
aws_profile
,
aws_unsigned
=
aws_no_sign_requests
,
requester_pays
=
aws_requester_pays
,
)
,
CPL_DEBUG
=
(
verbosity
>
2
)
)
),
**
envopts
)
else
:
ctx
.
obj
[
"
env
"
]
=
rasterio
.
Env
(
**
envopts
)
rasterio/session.py
View file @
5c630ea4
...
...
@@ -145,9 +145,6 @@ class AWSSession(Session):
if
session
:
self
.
_session
=
session
else
:
if
not
aws_access_key_id
and
not
profile_name
:
self
.
_session
=
boto3
.
Session
()
else
:
self
.
_session
=
boto3
.
Session
(
aws_access_key_id
=
aws_access_key_id
,
...
...
@@ -164,6 +161,7 @@ class AWSSession(Session):
def
credentials
(
self
):
"""
The session credentials as a dict
"""
creds
=
{}
if
self
.
_creds
:
if
self
.
_creds
.
access_key
:
# pragma: no branch
creds
[
'
aws_access_key_id
'
]
=
self
.
_creds
.
access_key
if
self
.
_creds
.
secret_key
:
# pragma: no branch
...
...
rasterio/vrt.py
View file @
5c630ea4
...
...
@@ -69,7 +69,7 @@ class WarpedVRT(WarpedVRTReaderBase, WindowMethodsMixin,
self
.
stop
()
def
_boundless_vrt_doc
(
src_dataset
,
nodata
=
None
,
width
=
None
,
height
=
None
,
transform
=
None
):
def
_boundless_vrt_doc
(
src_dataset
,
nodata
=
None
,
hidenodata
=
False
,
width
=
None
,
height
=
None
,
transform
=
None
):
"""
Make a VRT XML document.
"""
nodata
=
nodata
or
src_dataset
.
nodata
...
...
@@ -94,6 +94,10 @@ def _boundless_vrt_doc(src_dataset, nodata=None, width=None, height=None, transf
nodatavalue
=
ET
.
SubElement
(
vrtrasterband
,
'
NoDataValue
'
)
nodatavalue
.
text
=
str
(
nodata
)
if
hidenodata
:
hidenodatavalue
=
ET
.
SubElement
(
vrtrasterband
,
'
HideNoDataValue
'
)
hidenodatavalue
.
text
=
"
1
"
colorinterp
=
ET
.
SubElement
(
vrtrasterband
,
'
ColorInterp
'
)
colorinterp
.
text
=
ci
.
name
.
capitalize
()
...
...
tests/data/red.tif
View file @
5c630ea4
No preview for this file type
tests/test_boundless_read.py
View file @
5c630ea4
...
...
@@ -59,3 +59,24 @@ def test_hit_ovr(red_green):
image
=
numpy
.
moveaxis
(
data
,
0
,
-
1
)
assert
image
[
0
,
0
,
0
]
==
17
assert
image
[
0
,
0
,
1
]
==
204
def
test_boundless_mask_not_all_valid
():
"""
Confirm resolution of issue #1449
"""
with
rasterio
.
open
(
"
tests/data/red.tif
"
)
as
src
:
masked
=
src
.
read
(
1
,
boundless
=
True
,
masked
=
True
,
window
=
Window
(
-
1
,
-
1
,
66
,
66
))
assert
not
masked
.
mask
.
all
()
assert
masked
.
mask
[:,
0
].
all
()
assert
masked
.
mask
[:,
-
1
].
all
()
assert
masked
.
mask
[
0
,
:].
all
()
assert
masked
.
mask
[
-
1
,
:].
all
()
def
test_boundless_fill_value
():
"""
Confirm resolution of issue #1471
"""
with
rasterio
.
open
(
"
tests/data/red.tif
"
)
as
src
:
filled
=
src
.
read
(
1
,
boundless
=
True
,
fill_value
=
5
,
window
=
Window
(
-
1
,
-
1
,
66
,
66
))
assert
(
filled
[:,
0
]
==
5
).
all
()
assert
(
filled
[:,
-
1
]
==
5
).
all
()
assert
(
filled
[
0
,
:]
==
5
).
all
()
assert
(
filled
[
-
1
,
:]
==
5
).
all
()
tests/test_env.py
View file @
5c630ea4
...
...
@@ -314,6 +314,7 @@ def test_ensured_env_no_credentializing(gdalenv):
@requires_gdal21
(
reason
=
"
S3 access requires 2.1+
"
)
@credentials
@pytest.mark.network
def
test_open_https_vsicurl
(
gdalenv
):
"""
Read from HTTPS URL.
"""
...
...
@@ -725,3 +726,16 @@ def test_require_gdal_version_chaining():
message
=
'
parameter
"
something=else
"
requires GDAL >= {0}
'
.
format
(
version
)
assert
message
in
exc_info
.
value
.
args
[
0
]
def
test_rio_env_no_credentials
(
tmpdir
,
monkeypatch
,
runner
):
"""
Confirm that we can get drivers without any credentials
"""
credentials_file
=
tmpdir
.
join
(
'
credentials
'
)
monkeypatch
.
setenv
(
'
AWS_SHARED_CREDENTIALS_FILE
'
,
str
(
credentials_file
))
monkeypatch
.
delenv
(
'
AWS_ACCESS_KEY_ID
'
,
raising
=
False
)
# Assert that we don't have any AWS credentials by accident.
with
pytest
.
raises
(
Exception
):
rasterio
.
open
(
"
s3://mapbox/rasterio/RGB.byte.tif
"
)
with
rasterio
.
Env
()
as
env
:
assert
env
.
drivers
()
tests/test_features.py
View file @
5c630ea4
...
...
@@ -172,7 +172,7 @@ def test_geometry_window_pixel_precision(basic_image_file):
with
rasterio
.
open
(
basic_image_file
)
as
src
:
window
=
geometry_window
(
src
,
[
geom2
],
north_up
=
False
,
pixel_precision
=
6
)
assert
window
.
flatten
()
==
(
1
,
2
,
3
,
3
)
assert
window
.
flatten
()
==
(
1
,
2
,
4
,
3
)
def
test_geometry_window_north_up
(
path_rgb_byte_tif
):
...
...
@@ -190,7 +190,7 @@ def test_geometry_window_north_up(path_rgb_byte_tif):
with
rasterio
.
open
(
path_rgb_byte_tif
)
as
src
:
window
=
geometry_window
(
src
,
[
geometry
],
north_up
=
True
)
assert
window
.
flatten
()
==
(
326
,
256
,
16
7
,
167
)
assert
window
.
flatten
()
==
(
326
,
256
,
16
8
,
167
)
def
test_geometry_window_pad
(
basic_image_file
,
basic_geometry
):
...
...
tests/test_rio_info.py
View file @
5c630ea4
...
...
@@ -442,3 +442,14 @@ def test_info_subdatasets():
assert
result
.
exit_code
==
0
assert
len
(
result
.
output
)
==
93
assert
result
.
output
.
startswith
(
'
netcdf:tests/data/RGB.nc:Band1
'
)
def
test_info_no_credentials
(
tmpdir
,
monkeypatch
):
credentials_file
=
tmpdir
.
join
(
'
credentials
'
)
monkeypatch
.
setenv
(
'
AWS_SHARED_CREDENTIALS_FILE
'
,
str
(
credentials_file
))
monkeypatch
.
delenv
(
'
AWS_ACCESS_KEY_ID
'
,
raising
=
False
)
runner
=
CliRunner
()
result
=
runner
.
invoke
(
main_group
,
[
'
info
'
,
'
tests/data/RGB.byte.tif
'
])
assert
result
.
exit_code
==
0
tests/test_session.py
View file @
5c630ea4
...
...
@@ -111,6 +111,6 @@ def test_foreign_session_factory_s3():
def
test_requester_pays
():
"""
GDAL is configured with requester pays
"""
sesh
=
AWSSession
(
requester_pays
=
True
)
sesh
=
AWSSession
(
aws_access_key_id
=
'
foo
'
,
aws_secret_access_key
=
'
bar
'
,
requester_pays
=
True
)
assert
sesh
.
_session
assert
sesh
.
get_credential_options
()[
'
AWS_REQUEST_PAYER
'
]
==
'
requester
'