PostgresOSM.get_table_name

PostgresOSM.get_table_name(subregion_name, table_named_as_subregion=False)[source]

Get the default table name for a specific geographic (sub)region.

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

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

Returns:

default table name for storing the subregion data into the database

Return type:

str

Examples:

>>> from pydriosm.ios import PostgresOSM

>>> osmdb = PostgresOSM(database_name='osmdb_test')
Password (postgres@localhost:5432): ***
Creating a database: "osmdb_test" ... Done.
Connecting postgres:***@localhost:5432/osmdb_test ... Successfully.

>>> subrgn_name = 'london'

>>> tbl_name = osmdb.get_table_name(subrgn_name)
>>> tbl_name
'london'

>>> tbl_name = osmdb.get_table_name(subrgn_name, table_named_as_subregion=True)
>>> tbl_name
'Greater London'

>>> # Change the data source
>>> osmdb.data_source = 'BBBike'
>>> tbl_name = osmdb.get_table_name(subrgn_name, table_named_as_subregion=True)
>>> tbl_name
'London'

>>> # Delete the database 'osmdb_test'
>>> osmdb.drop_database(verbose=True)
To drop the database "osmdb_test" from postgres:***@localhost:5432
? [No]|Yes: yes
Dropping "osmdb_test" ... Done.

Note

In the examples above, the default data source is ‘Geofabrik’. Changing it to ‘BBBike’, the function may produce a different output for the same input, as a geographic (sub)region that is included in one data source may not always be available from the other.