我是新来的osm2pqsgl。我已经为整个欧洲下载了一个osm.pbf文件,我想将这些数据添加到我的Postgres数据库中。然而,我只对points感兴趣,不对linestrings或polygon感兴趣,在points中我只对这些标记及其信息感兴趣(比如denomination或name)。
我已经编辑了style文件,从osm2pgsql到下面
node,way historic text polygon
node,way natural text polygon
node,way religion text linear
node,way tourism text polygonPoint的osm.pbf文件中导入osm2pgsql功能tag的tag特性,例如从带有osm2pgsql的osm.pbf文件中导入tourism发布于 2022-03-23 09:44:26
最后,我使用了来自osm2pgsql的osm2pgsql选项并创建了一个.lua文件。这里有tag religion。
local tables = {}
-- this creates the table for point and its columns
tables.religion = osm2pgsql.define_node_table('religion_point', {
{ column = 'osm_type', type = 'text', not_null = true },
{ column = 'name', type = 'text', not_null = true},
{ column = 'geom', type = 'point' },
}, { schema = 'public' })
-- tags we don't need
local function clean_tags(tags)
tags.odbl = nil
tags.created_by = nil
tags.source = nil
tags['source:ref'] = nil
return next(tags) == nil
end
function osm2pgsql.process_node(object)
-- We are only interested in religion details
-- replace here with the tag you want to import i.e. natural, historic, ...
if not object.tags.religion then
return
end
clean_tags(object.tags)
-- Using grab_tag() removes from remaining key/value saved to Pg
local osm_type = object:grab_tag('religion')
local name = object:grab_tag('name')
tables.religion:add_row({
osm_type = osm_type,
tags = json.encode(object.tags),
name = name,
geom = { create = 'point' }
})
end然后用
$ osm2pgsql -c -d <DATABASENAME> -U postgres -H localhost -O flex -S ./<NAME>.lua ./<FILENAME>.osm.pbf脚本的源
https://stackoverflow.com/questions/70541035
复制相似问题