mirror of
https://github.com/rasterio/rasterio.git
synced 2025-12-08 17:36:12 +00:00
parent
2373213ba9
commit
2629a84e39
@ -1,6 +1,10 @@
|
||||
Changes
|
||||
=======
|
||||
|
||||
Next
|
||||
----
|
||||
- Add single value options to rio info command (#139).
|
||||
|
||||
0.12.1 (2014-09-02)
|
||||
-------------------
|
||||
- Add missing rasterio.rio package (#135).
|
||||
|
||||
@ -22,7 +22,7 @@ from rasterio.transform import Affine, guard_transform
|
||||
|
||||
__all__ = [
|
||||
'band', 'open', 'drivers', 'copy', 'check_dtype', 'pad']
|
||||
__version__ = "0.12.1"
|
||||
__version__ = "0.13"
|
||||
|
||||
log = logging.getLogger('rasterio')
|
||||
class NullHandler(logging.Handler):
|
||||
|
||||
27
scripts/rio
27
scripts/rio
@ -18,6 +18,7 @@ import rasterio.tool
|
||||
import rasterio.warp
|
||||
|
||||
from rasterio.rio.cli import cli
|
||||
from rasterio.rio.info import info
|
||||
from rasterio.rio.merge import merge
|
||||
|
||||
|
||||
@ -88,32 +89,6 @@ def write_features(file, collection,
|
||||
# module. Longer ones, e.g. insp() shall call functions imported from
|
||||
# rasterio.tool.
|
||||
|
||||
# Info command.
|
||||
@cli.command(short_help="Print information about a data file.")
|
||||
@click.argument('src_path', type=click.Path(exists=True))
|
||||
@click.option('--meta', 'aspect', flag_value='meta', default=True,
|
||||
help="Show data file structure (default).")
|
||||
@click.option('--tags', 'aspect', flag_value='tags',
|
||||
help="Show data file tags.")
|
||||
@click.option('--indent', default=2, type=int,
|
||||
help="Indentation level for pretty printed output")
|
||||
@click.option('--namespace', help="Select a tag namespace.")
|
||||
@click.pass_context
|
||||
def info(ctx, src_path, aspect, indent, namespace):
|
||||
verbosity = ctx.obj['verbosity']
|
||||
logger = logging.getLogger('rio')
|
||||
try:
|
||||
with rasterio.drivers(CPL_DEBUG=verbosity>2):
|
||||
with rasterio.open(src_path) as src:
|
||||
if aspect == 'meta':
|
||||
pprint.pprint(src.meta, indent=indent)
|
||||
elif aspect == 'tags':
|
||||
pprint.pprint(src.tags(ns=namespace), indent=indent)
|
||||
sys.exit(0)
|
||||
except Exception:
|
||||
logger.exception("Failed. Exception caught")
|
||||
sys.exit(1)
|
||||
|
||||
# Insp command.
|
||||
@cli.command(short_help="Open a data file and start an interpreter.")
|
||||
@click.argument('src_path', type=click.Path(exists=True))
|
||||
|
||||
@ -84,3 +84,34 @@ def test_cli_bounds_seq_collection_multi(tmpdir):
|
||||
assert json_texts[0].strip() == '{"bbox": [-78.898133, 23.564991, -76.599438, 25.550874], "features": [{"bbox": [-78.898133, 23.564991, -76.599438, 25.550874], "geometry": {"coordinates": [[[-78.898133, 23.564991], [-76.599438, 23.564991], [-76.599438, 25.550874], [-78.898133, 25.550874], [-78.898133, 23.564991]]], "type": "Polygon"}, "properties": {"id": "0", "title": "tests/data/RGB.byte.tif"}, "type": "Feature"}], "type": "FeatureCollection"}'
|
||||
assert json_texts[1].strip() == '{"bbox": [-78.898133, 23.564991, -76.599438, 25.550874], "features": [{"bbox": [-78.898133, 23.564991, -76.599438, 25.550874], "geometry": {"coordinates": [[[-78.898133, 23.564991], [-76.599438, 23.564991], [-76.599438, 25.550874], [-78.898133, 25.550874], [-78.898133, 23.564991]]], "type": "Polygon"}, "properties": {"id": "1", "title": "tests/data/RGB.byte.tif"}, "type": "Feature"}], "type": "FeatureCollection"}'
|
||||
|
||||
|
||||
def test_cli_info_count():
|
||||
result = subprocess.check_output(
|
||||
'if [ `rio info tests/data/RGB.byte.tif --count` -eq 3 ]; '
|
||||
'then echo "True"; fi',
|
||||
shell=True)
|
||||
assert result.decode('utf-8').strip() == 'True'
|
||||
|
||||
|
||||
def test_cli_info_nodata():
|
||||
result = subprocess.check_output(
|
||||
'if [ `rio info tests/data/RGB.byte.tif --nodata` = "0.0" ]; '
|
||||
'then echo "True"; fi',
|
||||
shell=True)
|
||||
assert result.decode('utf-8').strip() == 'True'
|
||||
|
||||
|
||||
def test_cli_info_dtype():
|
||||
result = subprocess.check_output(
|
||||
'if [ `rio info tests/data/RGB.byte.tif --dtype` = "uint8" ]; '
|
||||
'then echo "True"; fi',
|
||||
shell=True)
|
||||
assert result.decode('utf-8').strip() == 'True'
|
||||
|
||||
|
||||
def test_cli_info_shape():
|
||||
result = subprocess.check_output(
|
||||
'if [[ `rio info tests/data/RGB.byte.tif --shape` == "718 791" ]]; '
|
||||
'then echo "True"; fi',
|
||||
shell=True)
|
||||
assert result.decode('utf-8').strip() == 'True'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user