Package: cligj
Common arguments and options for GeoJSON processing commands, using Click.cligjis for Python developers who create command line interfaces for geospatial data.cligjallows you to quickly build consistent, well-tested and interoperable CLIs for handling GeoJSON.Argumentsfiles_in_argMultiple filesfiles_inout_argMultiple files, last of which is an output file.features_in_argGeoJSON Features input which accepts multiple representations of GeoJSON features
and returns the input data as an iterable of GeoJSON Feature-like dictionariesOptionsverbose_optquiet_optformat_optJSON formatting optionsindent_optcompact_optCoordinate precision optionprecision_optGeographic (default), projected, or Mercator switchprojection_geographic_optprojection_projected_optprojection_mercator_optFeature collection or feature sequence switchsequence_optuse_rs_optGeoJSON output mode optiongeojson_type_collection_optgeojson_type_feature_optdef geojson_type_bbox_optExampleHere’s an example of a command that writes out GeoJSON features as a collection
or, optionally, a sequence of individual features. Since most software that
reads and writes GeoJSON expects a text containing a single feature collection,
that’s the default, and a LF-delimited sequence of texts containing one GeoJSON
feature each is a feature that is turned on using the--sequenceoption.
To write sequences of feature texts that conform to theGeoJSON Text Sequences
standard(and might contain
pretty-printed JSON) with the ASCII Record Separator (0x1e) as a delimiter, use
the--rsoptionWarningFuture change warning
GeoJSON sequences (–sequence), not collections (–no-sequence), will be
the default in version 1.0.0.importclickimportcligjimportjsondefprocess_features(features):forfeatureinfeatures:# TODO process feature hereyieldfeature@click.command()@cligj.features_in_arg@cligj.sequence_opt@cligj.use_rs_optdefpass_features(features,sequence,use_rs):ifsequence:forfeatureinprocess_features(features):ifuse_rs:click.echo(u'\x1e',nl=False)click.echo(json.dumps(feature))else:click.echo(json.dumps({'type':'FeatureCollection','features':list(process_features(features))}))On the command line, the generated help text explains the usageUsage: pass_features [OPTIONS] FEATURES...

Options:
--sequence / --no-sequence  Write a LF-delimited sequence of texts
                            containing individual objects or write a single
                            JSON text containing a feature collection object
                            (the default).
--rs / --no-rs              Use RS (0x1E) as a prefix for individual texts
                            in a sequence as per http://tools.ietf.org/html
                            /draft-ietf-json-text-sequence-13 (default is
                            False).
--help                      Show this message and exit.And can be used like this$catdata.geojson{'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'id': '1'}, {'type': 'Feature', 'id': '2'}]}$pass_featuresdata.geojson{'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'id': '1'}, {'type': 'Feature', 'id': '2'}]}$catdata.geojson|pass_features{'type': 'FeatureCollection', 'features': [{'type': 'Feature', 'id': '1'}, {'type': 'Feature', 'id': '2'}]}$catdata.geojson|pass_features--sequence{'type': 'Feature', 'id': '1'}
{'type': 'Feature', 'id': '2'}$catdata.geojson|pass_features--sequence--rs^^{'type': 'Feature', 'id': '1'}
^^{'type': 'Feature', 'id': '2'}In this example,^^represents 0x1e.