This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Remove Geofabrik subregion from database

0

Is there a way to delete just one region from a postgresql-gis database that was downloaded from geofabrik.de and imported using osm2pgsql?

...or to truncate all data from the necessary tables and start over with a fresh/empty database/table?

I followed the instructions at switch2osm and imported North American sub-region data (.osm.pbf) from geofabrik.de for the state of Maine using osm2pgsql.

They also have "special" sub regions for the entire US Northeast, which they say "may duplicate data already contained in the other sub regions".

Now that I know how to do it, I'd rather get rid of the Maine data from maine-latest.osm.pbf and replace it with the us-northeast-latest.osm.pbf data.

Is there a straightforward way to do this that I'm overlooking in the docs?

asked 04 Mar '19, 22:43

Sareneathenodny's gravatar image

Sareneathenodny
31112
accept rate: 0%

edited 04 Mar '19, 22:44


One Answer:

1

Actually, if you import a new region by default it'll remove any previous data, so you may not need to do anything.

answered 04 Mar '19, 22:50

SomeoneElse's gravatar image

SomeoneElse ♦
36.9k71370866
accept rate: 16%

Is that true for non-overlapping regions too? If I download and import north-america-latest.osm.pbf, then as a second, separate step import download and import central-america-latest.osm.pbf, will the data for North America be gone?

(04 Mar '19, 22:57) Sareneathenodny
1

Yes, the default action is "create" (which will remove previous data). "append" is available (but is very slow) if you really do want to append, and that can have problems due to unexpected overlaps between the two areas (think ferry routes).

If you want to upload two areas it's probably best to merge first and then load that.

(04 Mar '19, 22:59) SomeoneElse ♦

Ah. I see. My thought was to import the 5 separate US-subregions from geofabrik to get a map for just the USA, to save on disk space. So you're saying that could cause issues at the boundaries and that it would be best from a technical standpoint to just get the whole north-america file?

(04 Mar '19, 23:09) Sareneathenodny

If what you ultimately want is the whole of North America, yes. If you just want some subregions, combine them with osmosis or similar and load the result.

(05 Mar '19, 19:13) SomeoneElse ♦

Great, thanks!

(05 Mar '19, 20:06) Sareneathenodny

Source code available on GitHub .