load_wfs_to_postgres¶
Upload gebieden into PostgreSQL from the WFS service of api.data.amsterdam.nl with use of ogr2ogr.
- Add ogr2ogr path ENV if running locally in a virtual environment:
export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH
- Example command line:
load_wfs_to_postgres config.ini dev
usage: load_wfs_to_postgres [-h] config_path db_config
Positional Arguments¶
config_path | Type the relative path + name of the config file, for example: auth/config.ini |
db_config | Type ‘dev’ or ‘docker’ to load the proper port and ip settings in the config file |
functions¶
-
exception
load.load_wfs_to_postgres.
NonZeroReturnCode
¶ Used for subprocess error messages.
-
load.load_wfs_to_postgres.
load_layers
(pg_str)¶ Load layers into Postgres using a list of titles of each layer within the WFS service.
- Args:
pg_str: psycopg2 connection string:
'PG:host= port= user= dbname= password='
- Returns:
- Loaded layers into postgres using ogr2ogr.
-
load.load_wfs_to_postgres.
parser
()¶ Parser function to run arguments from commandline and to add description to sphinx.
-
load.load_wfs_to_postgres.
run_command_sync
(cmd, allow_fail=False)¶ Run a string in the command line.
- Args:
cmd: command line code formatted as a list:
['ogr2ogr', '-overwrite', '-t_srs', 'EPSG:28992','-nln',layer_name,'-F' ,'PostgreSQL' ,pg_str ,url]
Optional: allow_fail: True or false to return error code
- Returns:
- Excuted program or error message.
-
load.load_wfs_to_postgres.
scrub
(line)¶ Hide the login credentials of Postgres in the console.
-
load.load_wfs_to_postgres.
wfs2psql
(url, pg_str, layer_name, **kwargs)¶ Command line ogr2ogr string to load a WFS into PostGres.