# 7.4. Query and Export Commands¶

These commands are used to query and export simple features. Required parameters are indicated with a *.

## 7.4.1. convert¶

The convert command is used to directly transform data in one format into another, without ingesting them into GeoMesa. For example, it could be used to convert CSV files to GeoJSON.

Argument Description
-C, --converter * The GeoMesa converter used to create SimpleFeatures
-s, --spec * The SimpleFeatureType specification to create
-f, --feature-name The name of the schema
-q, --cql CQL filter to select features to export
-m, --max-features Limit the number of features exported
-F, --output-format Output format used for export
-o, --output Output to a file instead of standard out
--hints Query hints used to modify the query
--index Specific index used to run the query
--no-header Don’t export the type header, for CSV and TSV formats
--gzip Level of gzip compression to use for output, from 1-9

See export and ingest for a description of the arguments.

## 7.4.2. explain¶

The explain command can be used to debug queries that are slow or problematic. Without actually running the query, it will show a variety of data, including the index being used, any query hints extracted, the exact ranges being scanned and filters being applied.

Argument Description
-c, --catalog * The catalog table containing schema metadata
-f, --feature-name * The name of the schema
-q, --cql * CQL filter to select features to export
-a, --attributes Specific attributes to export
--hints Query hints used to modify the query
--index Specific index used to run the query

See export for a description of the arguments.

## 7.4.3. export¶

Export features in a variety of formats.

See Moving and Migrating Data for details on how the export/import commands can be used to move data between clusters.

Argument Description
-c, --catalog * The catalog table containing schema metadata
-f, --feature-name * The name of the schema
-q, --cql CQL filter to select features to export
-a, --attributes Specific attributes to export
-m, --max-features Limit the number of features exported
-F, --output-format Output format used for export
-o, --output Output to a file instead of standard out
--hints Query hints used to modify the query
--index Specific index used to run the query
--no-header Don’t export the type header, for CSV and TSV formats
--gzip Level of gzip compression to use for output, from 1-9

The --attributes argument can be used to select a subset of attributes to export, or to transform the attributes using filter functions. A simple projection can be specified as a comma-delimited list:

--attributes name,age,geom


The feature ID can be specified along with other attribute names, with the reserved word id:

--attributes id,name,age,geom


Transforms can be accomplished by specifying transform functions:

--attributes id,name,name_transform=strConcat(name, 'foo')


For a full list of transforms, see the GeoTools documentation. Note that not all functions work in transforms, however.

The --output-format argument defines the encoding used for export. Currently, it can be one of:

• arrow Apache Arrow streaming file format
• avro Apache Avro format
• bin Custom minimal binary encoding
• csv, tsv
• geojson, json
• gml Geography Markup Language
• shp ESRI Shapefile
• leaflet Export data to a leaflet map and open in the default browser, if possible
• null suppress output entirely

Note

The leaflet format is intended for testing and small scale data exploration and visualization only. For production map generation it is highly recommended to use GeoServer. Additionally, the resulting file from this command requires the use of an online browser to open in order to access online resources.

The --output argument can be used to export to a file. By default, export data is written to the standard output stream.

The --hints argument can be used to set query hints. Hints should be specified as key1=value1;key2=value2, etc. Note that due to shell expansion, the hint string will likely need to be quoted. See Analytic Querying for examples of query hints that can be set. Note that query hints may cause errors if they don’t correspond to the output format specified.

The --index argument can be used to force the query to run against a particular index, instead of using the best index as determined through query planning. The argument should be the name of an index, e.g. id or z3. See Index Overview for a list of valid indices. Note that not all schemas will have all index types.

The --gzip argument can be used to compress the output through gzip encoding. It can be specified as a number between 1-9. Higher numbers indicate more compression, lower numbers indicate faster compression.