.. _impexp_cli_export_command: Export command -------------- **Synopsis** .. code-block:: bash impexp export [-hV] [--[no-]fail-fast] [--replace-ids] [--ade-extensions=] [-c=] [--compressed-format=] [--id-prefix=] [--log-file=] [--log-level=] -o= [--output-encoding=] [--pid-file=] [--plugins=] [--use-plugin=[, ...]]... [--worker-threads=] [[[-t=<[prefix:]name>[,<[prefix:]name>...]]... [--namespace=[,...]]...] [[-r=] [-R=]] [-i=[, ...] [-i=[,...]]...] [--db-id=[,...] [--db-id=[,...]]...] [-b= [--bbox-mode=] [-g=]] [[--count=] [--start-index=]] [-l=<0..4>[, <0..4>...] [-l=<0..4>[,<0..4>...]]... [--lod-mode=] [--lod-search-depth=<0..n|all>]] [[--no-appearance] | -a=[,...] [-a=[,...]]...] [-s= Provide an SQL SELECT statement to be used as SQL filter when querying the database. In general, any SELECT statement can be used as long as it returns a list of database IDs of the selected city objects (see :numref:`impexp_export_sql_filter` for more information). You can also use an @-file to provide the SELECT statement (see :numref:`impexp_cli_argument_files`). .. option:: -q, --xml-query= This option allows you to use a full-fledged XML query expression as filter for the export operation. Make sure the query expression is valid and adheres to the specification for XML query expressions provided in :numref:`impexp_xml_queries_chapter`. You can also use an @-file to provide the query expression (see :numref:`impexp_cli_argument_files`). This option **cannot be used with any other filter option** of the ``export`` command. .. include:: database-options.rst **Examples** .. code-block:: bash $ impexp export -H localhost -d citydb_v4 -u citydb_user -p my_password -o my_city.gml Export the entire database content as CityGML to the output file ``my_city.gml``. The 3DCityDB to connect to is supposed to be running on a PostgreSQL database on the same machine. The connection will be established to the ``citydb_v4`` database with the user ``citydb_user`` and the password ``my_password``. .. code-block:: bash $ impexp export -H localhost -d citydb_v4 -u citydb_user -p my_password \ -t Building -b 13.3508824,52.4799281,13.3578297,52.4862805,4326 \ -o my_city.json Only export ``Building`` features overlapping with the provided bounding box from the database. The coordinates of the bounding box are given in WGS84. For this reason, the fifth value ``4326`` of the :option:`-b` option denotes the SRID that is used by the target database for the WGS84 reference system. The output format is CityJSON. .. code-block:: bash $ impexp export -H localhost -d citydb_v4 -u citydb_user -p my_password \ -i ID_0815,ID_0816 -l 1,2,3 --lod-mode=maximum --compressed-format=citygml -o my_city.zip Export the top-level city objects with the identifiers ``ID_0815`` and ``ID_0816`` from the database if they have an LoD representation in either LoD 1, 2 or 3. From the matching LoD representations, only export the highest LoD. The output file will be a compressed ZIP archive containing a CityGML file with the exported city objects. .. code-block:: bash $ impexp export -H localhost -d citydb_v4 -u citydb_user -p my_password \ -s "select cityobject_id from cityobject_genericattrib \ where attrname='energy_level' and realval < 12" \ -o my_city.zip Export all city objects satisfying the given SQL SELECT statement. .. code-block:: bash $ impexp export -H localhost -d citydb_v4 -u citydb_user -p my_password \ -s "select cityobject_id from cityobject_genericattrib \ where attrname='energy_level' and realval < 12" \ -o my_city.zip Export all city objects satisfying the given SQL SELECT statement. .. code-block:: bash $ impexp export -H localhost -d citydb_v4 -u citydb_user -p my_password \ @/path/to/xml-query -o my_city.gml Export all city objects satisfying the given XML query expression. To avoid possible system limitations on the length of the command line, the XML query is stored in a separate argument file called ``xml-query`` which is referenced from the command line using the @-file notation. The content of the ``xml-query`` file is shown below: .. code-block:: bash -q ' \ \ bldg:Building \ \ \ \ \ 13.3508824 52.4799281 \ 13.3578297 52.4862805 \ \ \ \ \ \ bldg:measuredHeight \ \ \ \ 20 \ \ ' According to this query expression, only the first 20 buildings satisfying the provided bounding box filter and sorted by their *bldg:measuredHeight* attribute will be exported. .. note:: For the above @-file ``xml-query`` to work, the following requirements must be met: - The entire XML query expression is the value of the :option:`-q` option and, thus, must be put on a single line in the argument file. Either avoid line breaks in your XML or escape them using a backslash ``\`` character like in the above example. - Since the XML query expression contains whitespace, it must be put in double or single quotes. When using double quotes, all double quotes of the query expression itself must be escaped. To avoid escaping, the above example uses single quotes.