Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Wurster committed Jul 1, 2016
1 parent 7f2168b commit 10c8ba4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
25 changes: 11 additions & 14 deletions rasterio/rio/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def __call__(self):
@cligj.precision_opt
@cligj.indent_opt
@cligj.compact_opt
@cligj.projection_geographic_opt
@cligj.projection_projected_opt
@cligj.sequence_opt
@cligj.use_rs_opt
Expand All @@ -102,38 +101,36 @@ def blocks(

"""Write dataset blocks as GeoJSON features.
This command writes features describing a rasters internal tiling scheme,
which are often used to visually get a feel for how a windowed operation
might work. Rasters that are not tiled internally can still have internal
blocks that are not square, and this command does not differentiate between
the two.
This command writes features describing a raster's internal blocks, which
are used directly for raster I/O. These features can be used to visualize
how a windowed operation would operate using those blocks.
Output features have two JSON encoded properties: block and window. Block
is a two element array like `[0, 0]` describing the window's position
is a two element array like '[0, 0]' describing the window's position
in the input band's window layout. Window is a two element array
containing two more two element arrays like `[[0, 256], [0, 256]]` and
containing two more two element arrays like '[[0, 256], [0, 256]' and
describes the range of pixels the window covers in the input band. Values
are JSON encoded for better interoperability.
Block windows are extracted from the dataset (all bands must have matching
block windows) by default, or from the band specified using the `--bidx`
block windows) by default, or from the band specified using the '--bidx
option:
\b
$ rio shapes --bidx 3 tests/data/RGB.byte.tif
By default a GeoJSON `FeatureCollection` is written, but the `--sequence`
By default a GeoJSON 'FeatureCollection' is written, but the --sequence'
option produces a GeoJSON feature stream instead.
\b
$ rio shapes tests/data/RGB.byte.tif --sequence
Output features are reprojected to `WGS84` unless the `--projected` flag is
provided, which causes the outupt to be kept in the input datasource's
Output features are reprojected to 'WGS84' unless the '--projected' flag is
provided, which causes the output to be kept in the input datasource's
coordinate reference system.
For more information on exactly what blocks and windows represent, see
`src.block_windows()`.
'src.block_windows()'.
"""

verbosity = ctx.obj['verbosity'] if ctx.obj else 1
Expand All @@ -156,7 +153,7 @@ def blocks(
src=src,
bidx=bidx,
precision=precision,
geographic=projection == 'geographic')
geographic=projection != 'projected')

write_features(
stdout, collection,
Expand Down
12 changes: 7 additions & 5 deletions tests/test_rio_blocks.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
"""Unittests for $ rio blocks"""


import itertools as it
import json
import os
import re

import numpy as np
import six

import rasterio
from rasterio.warp import transform_bounds
from rasterio.compat import zip_longest
from rasterio.rio.main import main_group


Expand All @@ -24,10 +21,15 @@ def check_features_block_windows(features, src, bidx):
GeoJSON features.
src : RasterReader
Open input datasource.
Returns
-------
bool
``True`` if the two block/window streams match and ``False`` otherwise.
"""

out = []
iterator = six.moves.zip_longest(features, src.block_windows(bidx=bidx))
iterator = zip_longest(features, src.block_windows(bidx=bidx))
for feat, (block, window) in iterator:

out.append(np.array_equal(
Expand Down

0 comments on commit 10c8ba4

Please sign in to comment.