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.

Caution

Geometry file parsing is only supported for standard installations. If you used a slim install, then attempting to parse a geometry file will raise an error.

Supported Formats

When parsing geometry files, the pwfdf-api always supports the following vector feature file formats:

Format

Description

Extensions

FlatGeobuf

FlatGeobuf

.fgb

GPKG

GeoPackage vector

.gpkg

GeoJSON

GeoJSON

.json, .geojson

GeoJSONSeq

Sequence of GeoJSON features

.geojsons, .geojsonl

OpenFileGDB

ESRI File Geodatabase Vector

.gdb

Shapefile

ESRI Shapefile / DBF

.shp, .dbf, .shz, .shp.zip

Depending on your GDAL version, additional formats may also be supported. The following formats are usually supported, although not guaranteed:

Format

Description

Extensions

CSV

Comma Separated Value

.csv

GML

Geography Markup Language

.gml, .xml

GPX

GPS Exchange Format

.gpx

MapInfo File

MapInfo TAB and MIF/MID

.tab, .mid, .mif

OGR_GMT

GMT ASCII Vectors

.gmt

SQLite

SQLite / Spatialite RDBMS

.sqlite, .db

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")