omniscale / imposm3

Imposm imports OpenStreetMap data into PostGIS
http://imposm.org/docs/imposm3/latest/
Apache License 2.0
710 stars 156 forks source link

Unified value tags #217

Closed mnameghi closed 4 years ago

mnameghi commented 4 years ago

Hi I want to import data something like this. All values from tags like garden,park,grass and ... replaced with a word. for example: "green" Is this possible?

ImreSamu commented 4 years ago

you can ask questions in the community mailing list: https://groups.google.com/forum/#!forum/imposm

All values from tags like garden,park,grass and ... replaced with a word. for example: "green"

my2c/imho:

example mapping file for creating osm_green , osm_blue tables.

tables:
  # osm_green table definition:
  green:
    columns:
    - name: osm_id
      type: id
    - name: geometry
      type: geometry
    mapping:
      landuse:
      - park
      - forest
      - grass
      - wood
      leisure:
      - park
      - nature_reserve
      natural:
      - wood
    type: polygon

  # osm_blue table definition:
  blue:
    columns:
    - name: osm_id
      type: id
    - name: geometry
      type: geometry
    mapping:
      natural:
      - water
      waterway:
      - riverbank
    type: polygon

and if you need a single view (osm_colors) , just create ...

create view osm_colors as
          select 'green'::text as color , * from osm_green
union all select 'blue'::text  as color , * from osm_blue
;

test:

appx=# select color , count(*) as _cnt 
appx-# from osm_colors
appx-# group by 1;
 color | _cnt 
-------+------
 green | 2374
 blue  |  132
(2 rows)

appx=# \d+ osm_colors
                                   View "public.osm_colors"
  Column  |          Type           | Collation | Nullable | Default | Storage  | Description 
----------+-------------------------+-----------+----------+---------+----------+-------------
 color    | text                    |           |          |         | extended | 
 id       | integer                 |           |          |         | plain    | 
 osm_id   | bigint                  |           |          |         | plain    | 
 geometry | geometry(Geometry,4326) |           |          |         | main     | 
View definition:
 SELECT 'green'::text AS color,
    osm_green.id,
    osm_green.osm_id,
    osm_green.geometry
   FROM osm_green
UNION ALL
 SELECT 'blue'::text AS color,
    osm_blue.id,
    osm_blue.osm_id,
    osm_blue.geometry
   FROM osm_blue;