PostgresOSM.drop_subregion_table¶
-
PostgresOSM.
drop_subregion_table
(subregion_table_names, schema_names=None, table_named_as_subregion=False, schema_named_as_layer=False, confirmation_required=True, verbose=False)¶ Delete all or specific schemas/layers of subregion data from the database being connected.
- Parameters
subregion_table_names (str or list) – name of table for a subregion (or name of a subregion)
schema_names (list or None) – names of schemas for each layer of the PBF data, if
None
(default), the default layer names as schema namestable_named_as_subregion (bool) – whether to use subregion name as a table name, defaults to
False
schema_named_as_layer (bool) – whether a schema is named as a layer name, defaults to
False
confirmation_required (bool) – whether to ask for confirmation to proceed, defaults to
True
verbose (bool or int) – whether to print relevant information in console, defaults to
False
Examples:
>>> from pydriosm.ios import PostgresOSM >>> osmdb_test = PostgresOSM(database_name='osmdb_test') Password (postgres@localhost:5432): *** Connecting postgres:***@localhost:5432/osmdb_test ... Successfully. >>> # -- Import example data into the database ---------------------------------- >>> dat_dir = "tests" # Specify a temporary data directory >>> # Import PBF data of 'Rutland' (from Geofabrik free download server) >>> osmdb_test.import_subregion_osm_pbf( ... subregion_names='Rutland', data_dir=dat_dir, rm_osm_pbf=True, ... confirmation_required=False) >>> # (from BBBike free download server) >>> osmdb_test.DataSource = 'BBBike' >>> # Import PBF data of 'Victoria' and 'Waterloo' >>> osmdb_test.import_subregion_osm_pbf( ... subregion_names=['Victoria', 'Waterloo'], data_dir=dat_dir, ... parse_raw_feat=True, transform_geom=True, transform_other_tags=True, ... rm_osm_pbf=True, confirmation_required=False) >>> # Import shapefile data of 'Leeds' (from BBBike free download server) >>> leeds_shp = osmdb_test.Reader.read_shp_zip( ... subregion_name='Leeds', data_dir=dat_dir, rm_extracts=True, ... rm_shp_zip=True, download_confirmation_required=False) >>> osmdb_test.import_osm_data(leeds_shp, 'Leeds', confirmation_required=False) >>> # -- Delete all data of Rutland and Leeds ----------------------------------- >>> subregion_tbl_names = ['Rutland', 'Leeds'] >>> osmdb_test.drop_subregion_table(subregion_tbl_names, verbose=True) To drop tables from postgres:***@localhost:5432/osmdb_test: "Leeds" "Rutland" under the schemas: "buildings" "landuse" "lines" "multilinestrings" "multipolygons" "natural" "other_relations" "places" "points" "railways" "roads" "waterways" ? [No]|Yes: yes Dropping the tables ... "buildings"."Leeds" ... Done. "landuse"."Leeds" ... Done. "lines"."Rutland" ... Done. "multilinestrings"."Rutland" ... Done. "multipolygons"."Rutland" ... Done. "natural"."Leeds" ... Done. "other_relations"."Rutland" ... Done. "places"."Leeds" ... Done. "points"."Leeds" ... Done. "points"."Rutland" ... Done. "railways"."Leeds" ... Done. "roads"."Leeds" ... Done. "waterways"."Leeds" ... Done. >>> # -- Delete 'points' and 'other_relations' of Waterloo and Victoria --------- >>> subregion_tbl_names = ['Waterloo', 'Victoria'] >>> lyr_schema_names = ['points', 'other_relations'] >>> osmdb_test.drop_subregion_table(subregion_tbl_names, lyr_schema_names, ... verbose=True) To drop tables from postgres:***@localhost:5432/osmdb_test: "Victoria" "Waterloo" under the schemas: "other_relations" "points" ? [No]|Yes: yes Dropping the tables ... "other_relations"."Victoria" ... Done. "other_relations"."Waterloo" ... Done. "points"."Victoria" ... Done. "points"."Waterloo" ... Done. >>> # Delete the database 'osmdb_test' >>> osmdb_test.drop_database(verbose=True) To drop the database "osmdb_test" from postgres:***@localhost:5432 ? [No]|Yes: yes Dropping "osmdb_test" ... Done.