[Talk-us-massachusetts] various import methods, round-tripping, osc
Greg Troxel
gdt at lexort.com
Thu Aug 2 19:36:20 UTC 2018
(This note is pretty far down in the weeds of import processing, and a
bit note-to-self, but I wanted to ask here before asking on
dev at openstreetmap.org.)
I am starting down the path of using osm2pgsql to read data from a
geofabrik extract (essentially, all OSM objects that are in
Massachusetts, and probably all ways that contain a node in mass, and
all relations that contain something already in the set). A script to
do this is at
https://github.com/yyatsyn/MassGIS-address-import
This produces a bunch of tables:
massgis=# \d
List of relations
Schema | Name | Type | Owner
--------+--------------------+-------+-------
public | geography_columns | view | gdt
public | geometry_columns | view | gdt
public | planet_osm_line | table | gdt
public | planet_osm_point | table | gdt
public | planet_osm_polygon | table | gdt
public | planet_osm_roads | table | gdt
public | raster_columns | view | gdt
public | raster_overviews | view | gdt
public | spatial_ref_sys | table | gdt
(9 rows)
and e.g. "planet_osm_point" has a column for many tags, plus a "tags"
column of type hstore that has key/value pairs for the rest of the tags
that don't merit a column. We can certainly add the other addr tags to
the config file so they get columns.
Assume code is written to figure out what we want to change. Now we
need to write two things:
a file that is like the input extract, but modified, to use for
testing
some number of osc files, that say "update this object like so"
I don't see in the osm2pgsql world any way to write a file back out from
a postgis database. That seems like something people would want to do,
and useful for testing.
In creating a changeset, to e.g. add address tags to a building way, one
has to use the "modify" operation in the API:
https://wiki.openstreetmap.org/wiki/OsmChange
which requires supplying all the previous tags. It seems that these are
all in columns, including the tags hstore column, so this is doable. I
am wondering if there is code for this already, but it doesn't seem
hard.
All of this is making me thing of a custom style file for osm2pgsql that
uses only the tags that we really need, which I think are all the
address tags, the highway tag (to find roads), and the name tag (for
road name, and maybe building name). Thus the rest will be in the
hstore object and easy to iterate over.
There seems to be an osm2pgsql notion of dropping some tags, but I think
that's about tags that everybody agrees never should have been in the
db in the first place.
There is also imposm, but it seems to be an alternative implementation
of osm2pgsql, and not quite baked:
https://wiki.openstreetmap.org/wiki/Imposm
so I don't think it's a good idea to head down that path.
Any wisdom appreciated.
More information about the Talk-us-massachusetts
mailing list