Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@cligj.use_rs_opt
def cmd(sequence, use_rs):
click.echo("%s" % sequence)
click.echo("%s" % use_rs)
@use_rs_opt
@click.pass_context
@with_context_env
def bounds(ctx, precision, explode, with_id, with_obj, use_rs):
"""Print the bounding boxes of GeoJSON objects read from stdin.
Optionally explode collections and print the bounds of their
features.
To print identifiers for input objects along with their bounds
as a {id: identifier, bbox: bounds} JSON object, use --with-id.
To print the input objects themselves along with their bounds
as GeoJSON object, use --with-obj. This has the effect of updating
input objects with {id: identifier, bbox: bounds}.
"""
logger = logging.getLogger(__name__)
@cligj.use_rs_opt
@click.option("--gather-properties", default=False, is_flag=True,
help="any non-standard keys will be moved to Features.properties")
@click.option("--flatten", default=False, is_flag=True,
help="flatten Feature.properties")
@click.option("--string-id", default=False, is_flag=True,
help="casts the Feature.id (if exists) to a string")
@click.option("--add-id", default=False, is_flag=True,
help="add an auto-incrementing integer as the Feature.id")
@click.option("--add-uuid", default=False, is_flag=True,
help="add a unique string identifier as the Feature.id")
@click.option("--add-id-from-property", nargs=1, default=False,
help="add a Feature.id from specified Feature.properties object")
@click.option("--override-id", default=False, is_flag=True,
help="Allow options that manipulate Feature.id to overwrite")
@click.option("--type-first", default=False, is_flag=True,
help="Put type element at beginning of FeatureCollection")
@use_rs_opt
@geojson_type_collection_opt(True)
@geojson_type_feature_opt(False)
@geojson_type_bbox_opt(False)
@click.pass_context
def bounds(ctx, input, precision, indent, compact, projection, sequence,
use_rs, geojson_type):
"""Write bounding boxes to stdout as GeoJSON for use with, e.g.,
geojsonio
$ rio bounds *.tif | geojsonio
"""
import rasterio.warp
verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 1
logger = logging.getLogger('rio')
dump_kwds = {'sort_keys': True}
@use_rs_opt
@geojson_type_collection_opt(True)
@geojson_type_feature_opt(False)
@geojson_type_bbox_opt(False)
@click.pass_context
def bounds(ctx, input, precision, indent, compact, projection, dst_crs,
sequence, use_rs, geojson_type):
"""Write bounding boxes to stdout as GeoJSON for use with, e.g.,
geojsonio
$ rio bounds *.tif | geojsonio
If a destination crs is passed via dst_crs, it takes precedence over
the projection parameter.
"""
import rasterio.warp
dump_kwds = {'sort_keys': True}
@cligj.use_rs_opt
@click.pass_context
@with_context_env
def distrib(ctx, use_rs):
"""Distribute features from a collection.
Print the features of GeoJSON objects read from stdin.
"""
logger = logging.getLogger(__name__)
stdin = click.get_text_stream('stdin')
try:
source = helpers.obj_gen(stdin)
for i, obj in enumerate(source):
obj_id = obj.get('id', 'collection:' + str(i))
features = obj.get('features') or [obj]
for j, feat in enumerate(features):
if obj.get('type') == 'FeatureCollection':
@use_rs_opt
@click.pass_context
@with_context_env
def filter(ctx, filter_expression, use_rs):
"""
Filter GeoJSON features by python expression.
Features are read from stdin.
The expression is evaluated in a restricted namespace containing:
- sum, pow, min, max and the imported math module
- shape (optional, imported from shapely.geometry if available)
- bool, int, str, len, float type conversions
- f (the feature to be evaluated,
allows item access via javascript-style dot notation using munch)
The expression will be evaluated for each feature and, if true,
@cligj.use_rs_opt
@cligj.geojson_type_feature_opt(True)
@cligj.geojson_type_bbox_opt(False)
@click.option('--band/--mask', default=True,
help="Choose to extract from a band (the default) or a mask.")
@click.option('--bidx', 'bandidx', type=int, default=None,
help="Index of the band or mask that is the source of shapes.")
@click.option('--sampling', type=int, default=1,
help="Inverse of the sampling fraction; "
"a value of 10 decimates.")
@click.option('--with-nodata/--without-nodata', default=False,
help="Include or do not include (the default) nodata regions.")
@click.option('--as-mask/--not-as-mask', default=False,
help="Interpret a band as a mask and output only one class of "
"valid data shapes.")
@click.pass_context
def shapes(
@use_rs_opt
@geojson_type_feature_opt(True)
@geojson_type_bbox_opt(False)
@click.option('--band/--mask', default=True,
help="Choose to extract from a band (the default) or a mask.")
@click.option('--bidx', 'bandidx', type=int, default=None,
help="Index of the band or mask that is the source of shapes.")
@click.option('--sampling', type=int, default=1,
help="Inverse of the sampling fraction; "
"a value of 10 decimates.")
@click.option('--with-nodata/--without-nodata', default=False,
help="Include or do not include (the default) nodata regions.")
@click.option('--as-mask/--not-as-mask', default=False,
help="Interpret a band as a mask and output only one class of "
"valid data shapes.")
@click.pass_context
def shapes(
@cligj.use_rs_opt
def pointquery(features, raster, band, indent, nodata,
interpolate, property_name, sequence, use_rs):
"""
Queries the raster values at the points of the input GeoJSON Features.
The raster values are added to the features properties and output as GeoJSON
Feature Collection.
If the Features are Points, the point geometery is used.
For other Feauture types, all of the verticies of the geometry will be queried.
For example, you can provide a linestring and get the profile along the line
if the verticies are spaced properly.
You can use either bilinear (default) or nearest neighbor interpolation.
"""
results = gen_point_query(