Geometry File IO¶
When reading a search geometry from file, the default file parsers should be sufficient for most use cases. However, if your geometry file contains multiple data layers or non-standard encodings, then you can use additional options to help parse the file.
Supported Formats¶
The pwfdf-api supports the following vector feature file formats for geometry queries:
Format |
Description |
Extensions |
|---|---|---|
CSV |
Comma Separated Value |
|
DGN |
Microstation DGN |
|
DXF |
AutoCAD DXF |
|
FlatGeobuf |
FlatGeobuf |
|
GML |
Geography Markup Language |
|
GPKG |
GeoPackage vector |
|
GPX |
GPS Exchange Format |
|
GeoJSON |
GeoJSON |
|
GeoJSONSeq |
Sequence of GeoJSON features |
|
MapInfo File |
MapInfo TAB and MIF/MID |
|
OGR_GMT |
GMT ASCII Vectors |
|
OpenFileGDB |
ESRI File Geodatabase Vector |
|
Shapefile |
ESRI Shapefile / DBF |
|
SQLite |
SQLite / Spatialite RDBMS |
|
Note
The values in the first column are the supported values of the geometry driver option.
Format Driver¶
By default, pwfdf-api will use the geometry file extension to determine the format driver used to read the file. Refer to the geometry format table for the formats inferred by various extensions.
If your file uses a non-standard file extension, then use the --geometry-driver option to specify the file format. For example:
pwfdf assessments --geometry my-file.unusual --geometry-driver Shapefile
The supported format selectors are the values in the first column of the geometry format table.
If your file uses a non-standard file extension, then use the geometry_driver input to specify the file format. For example:
assessments(geometry="my-file.unusual", geometry_driver="Shapefile")
The supported format selectors are the values in the first column of the geometry format table.
Multiple Layers¶
Some GIS formats can hold multiple data layers. For example, File Geodatabases and GeoJSON Feature Collections. If your geometry file contains multiple layers, then by default, the command will parse the first layer as the geometry. Use the --geometry-layer or --geometry-index option to select a different layer as the geometry.
Use --geometry-layer to reference a layer by name:
pwfdf assessments --geometry my-data.gdb --geometry-layer MyLayerName
Or --geometry-index to reference a layer by index:
pwfdf assessments --geometry my-data.gdb --geometry-index 2
Note that layer indices use 0-indexing, so the first layer has an index of 0, second layer has an index of 1, etc.
Some GIS formats can hold multiple data layers. For example, File Geodatabases and GeoJSON Feature Collections. If your geometry file contains multiple layers, then by default, the command will parse the first layer as the geometry. Use the geometry_layer input to select a different layer as the geometry.
Set geometry_layer equal to a string to reference a layer by name:
assessments(geometry="my-data.gdb", geometry_layer="MyLayerName")
Or set the input to an integer to reference a layer by index:
assessments(geometry="my-data.gdb", geometry_layer=2)
Note that layer indices use 0-indexing, as per standard Python conventions.
Encoding¶
If the format driver fails to detect the encoding of your data, you can use the --geometry-encoding option to specify the encoding explicitly. For example:
pwfdf assessments --geometry my-file.shp --geometry-encoding Windows-1252
If the format driver fails to detect the encoding of your data, you can use the geometry_encoding option to specify the encoding explicitly. For example:
assessments(geometry="my-file.shp", geometry_encoding="Windows-1252")