PostgresOSM.subregion_table_exists

PostgresOSM.subregion_table_exists(subregion_name, layer_name, table_named_as_subregion=False, schema_named_as_layer=False)[source]

Check if a table (for a geographic region) exists.

Parameters
  • subregion_name (str) – name of a geographic region, which acts as a table name

  • layer_name (str) – name of an OSM layer (e.g. ‘points’, ‘railways’, …), which acts as a schema name

  • table_named_as_subregion (bool) – whether to use subregion name as table name, defaults to False

  • schema_named_as_layer (bool) – whether a schema is named as a layer name, defaults to False

Returns

True if the table exists, False otherwise

Return type

bool

Examples:

>>> from pydriosm.ios import PostgresOSM

>>> osmdb_test = PostgresOSM(database_name='osmdb_test')
Password (postgres@localhost:5432): ***
Connecting postgres:***@localhost:5432/osmdb_test ... Successfully.

>>> sr_name = 'rutland'
>>> lyr_name = 'pt'

>>> # (If the table, pt."rutland", does not exist)
>>> osmdb_test.subregion_table_exists(sr_name, lyr_name)
False

# (If the table, points.'Rutland', does not exist)
>>> osmdb_test.subregion_table_exists(sr_name, lyr_name,
...                                   table_named_as_subregion=True,
...                                   schema_named_as_layer=True)
False