5.2.3. Command-line interface

Synopsis

impexp export-table [-hV] [--ade-extensions=<folder>] [-c=<file>]
                    [-D=<char>] -l=<file> [--log-file=<file>]
                    [--log-level=<level>] -o=<file> [--pid-file=<file>]
                    [--plugins=<folder>] [--use-plugin=<plugin
                    [=true|false]>[,<plugin[=true|false]>...]]... [[[-t=<
                    [prefix:]name>[,<[prefix:]name>...]]...
                    [--namespace=<prefix=name>[,<prefix=name>...]]...]
                    [[-r=<version>] [-R=<timestamp[,timestamp]>]]
                    [-i=<id>[,<id>...] [-i=<id>[,<id>...]]...] [-b=<minx,
                    miny,maxx,maxy[,srid]>] [-s=<select>]]
                    [[-T=<database>] -H=<host> [-P=<port>] -d=<name>
                    [-S=<schema>] -u=<name> [-p[=<password>]]]
                    [@<filename>...]

Description

The export-table command exports attributes of the city objects stored in the 3D City Database in tabular form. It corresponds to the table export operation offered on the Table Export tab of the graphical user interface (see Section 5.2.2). The command provides a range of options to adapt the export process. In addition, you can also use the global options that are available for all commands of the Importer/Exporter command-line interface (see Section 4.9).

General options

-o, --output=<file>

Specify the output file to use for storing the exported attribute data. Use .csv as file extension to export the data as comma-separated values (CSV) file, which is also the default output format. Alternatively, you can export the data as Microsoft Excel (XLSX) file by choosing .xslx as file extension.

-l, --template=<file>

Provide the template file to use for the export. The template file defines the layout and content for the output file. See Section 5.2.2.2 for more information.

-D, --delimiter=<char>

Delimiter to use for separating values in the output CSV file. By default, a comma , is used as delimiter. This option is ignored when exporting as XLSX file.

Query and filter options

The export-table command offers additional options to define both thematic and spatial filters that are used to restrict the export to a subset of the top-level city objects stored in the 3D City Database.

-t, --type-name=<[prefix:]name>[,<[prefix:]name>...]

Comma-separated list of one or more names of the top-level feature types to be exported. The type names are case sensitive and shall match one of the official CityGML feature type names. To avoid ambiguities, you can use an optional prefix for each name. The prefix must be associated with the official XML namespace of the feature type. You can either use the official CityGML namespace prefixes listed in Table 4.11. Or you can use the --namespace option to declare your own prefixes.

--namespace=<prefix=name>[,<prefix=name>...]

Used to specify namespaces and their prefixes as comma-separated list of one or more prefix=name pairs. The prefixes can be used in other options such as --type-name.

-r, --feature-version=<version>

Specify the version of the top-level features to use for the export. Allowed values are latest, at, between, terminated, terminated_at and all. When choosing latest, only those features that have not been terminated in the database are exported, whereas all will export all features. You can also choose to export only features that were valid at a given timestamp using at or for a given time range using between. Likewise, terminated will return all terminated features whereas terminated_at will select features that were terminated at a given timestamp. In all cases, timestamps must be provided using the --feature-version-timestamp option. Further details about the feature version filter are available in Section 5.2.2.3.

-R, --feature-version-timestamp=<timestamp[,timestamp]>

One or two timestamps to be used with the --feature-version option. A timestamp can be given as date in the form YYYY-MM-DD or as date-time specified as YYYY-MM-DDThh:mm:ss[(+|-)hh:mm. The date-time format supports an optional UTC offset. Use one timestamp with the at and terminated_at values and two timestamps separated by comma with the between value of the --feature-version option.

-i, --resource-id=<id>[,<id>...]

Comma-separated list of one or more identifiers. Only top-level features having a matching value for their identifier attribute will be exported.

-b, --bbox=<minx,miny,maxx,maxy[,srid]>

2D bounding box to use as spatial filter. The bounding box is given by four coordinates that define its lower left and upper right corner. By default, the coordinates are assumed to be in the same CRS that is used by the 3DCityDB instance. Alternatively, you can provide the database srid of the CRS associated with the coordinates as fifth value (e.g. 4326 for WGS84). All values must be separated by commas. The bounding box is evaluated against the GMLID column of the CITYOBJECT table.

-s, --sql-select=<select>

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 Section 4.5.3 for more information). You can also use an @-file to provide the SELECT statement (see Section 4.9.9.3).

Database connection options

The following options allow you to define the connection details that shall be used for establishing a connection to the 3D City Database. You can also use environment variables for this purpose (see Section 4.9.8).

-T, --db-type=<database>

Specify the database system used for running the 3DCityDB. Allowed values are postgresql for PostgreSQL/PostGIS databases (default), and oracle for Oracle Spatial/Locator databases.

-H, --db-host=<host>

Specify the host name of the machine on which the 3DCityDB database server is running.

-P, --db-port=<port>

Specify the TCP port on which the 3DCityDB database server is listening for connections. The default value is 5432 for PostgreSQL and 1521 for Oracle.

-d, --db-name=<name>

Specify the name of the 3DCityDB database to connect to. When connecting to an Oracle database, provide the database SID or service name as value.

-S, --db-schema=<schema>

Name of the database schema to use when connecting to the 3DCityDB. If not provided, the citydb schema is used for PostgreSQL by default, whereas the schema of the user specified by the option --db-username is used under Oracle.

-u, --db-username=<name>

Connect to the 3DCityDB database server as the user given by name.

-p, --db-password[=<password>]

Specify the password to use when connecting to the 3DCityDB database server. You can either provide the password as value for this option or leave the value empty to be prompted to enter the password on the console before connecting to the database. If you skip this option completely, the impexp tool will try to connect to the database without a password. If the database server requires password authentication and a password is not available by other means, the connection attempt will fail in this case.

Examples

$ impexp export-table -H localhost -d citydb_v4 -u citydb_user -p my_password \
                      -l my_template.txt -o my_attributes.xslx

Export attributes according to the provided my_template.txt file (see Section 5.2.2.2) for all top-level city objects stored in the database. The attribute data is stored in the my_attributes.xslx file using XLSX as output format. 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.

$ impexp export-table -H localhost -d citydb_v4 -u citydb_user -p my_password \
                      -t Building -b 13.3508824,52.4799281,13.3578297,52.4862805,4326 \
                      -D ; -l my_template.txt -o my_attributes.csv

Only export attributes of 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 -b option denotes the SRID that is used by the target database for the WGS84 reference system. The output format is CSV and a semicolon ; is used as delimiter.

$ 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" \
                -l my_template.txt -o my_attributes.csv

Export attributes of all city objects satisfying the given SQL SELECT statement.