NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Is there a way to import a relation using the flex style when that relation doesn't have any related geometry data?

I'm trying to import a list of ski resorts in Scotland but one is not being imported correctly. I've done some digging and found that there is a relation which has a lot of ways as members, allowing me to group all those ways, but as there is no geometry field associated with that relation it doesn't appear in the database after I call add_row.

In a reduced test case I've found that if I remove the geometry field from the relevant database table, the relation is added correctly.

inspect = require('inspect')

local tables = {}

tables.relations_test = osm2pgsql.define_table({ name = 'relations_test', ids = { type = 'area', id_column = "id"}, columns = { { column = 'name', type = 'text' }, --{ column = 'geom', type = 'geometry' }, } })

function osm2pgsql.process_relation(object) if object:grab_tag('type') == "site" then

    print("Matched rel ",,

        name =,
      --  geom = { create = 'area' },


end If I remove the commented out lines in the above, my relation is not imported into the table. This suggests to me that each row requires a geometry.

If there any way to maintain the geometry field in the row (it's populated for other relations and ways) but allow it to be NULL?

asked 24 Aug '22, 15:15

DarkSnow's gravatar image

accept rate: 0%

It is not possible to have an empty geometry column with the add_row() function, it will be filtered out as you noticed. Luckily we have just recently released version 1.7.0 which has a new import() function which does basically the same as add_row(), but has "less magic" built in. If you don't have a geometry, it will happily add a NULL into that column (unless you declare the column as NOT NULL). See the osm2pgsql manual for details.

permanent link

answered 25 Aug '22, 06:35

Jochen%20Topf's gravatar image

Jochen Topf
accept rate: 31%

That's perfect Jochen, I've compiled the new version of osm2pgsql and I can now get the relation with a NULL geometry.

Perfect timing on the new version.

Thanks for the help.

permanent link

answered 26 Aug '22, 14:34

DarkSnow's gravatar image

accept rate: 0%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 24 Aug '22, 15:15

question was seen: 799 times

last updated: 26 Aug '22, 14:34

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum