digital-guard / preserv

Digital Preservation Project
http://git.digital-guard.org/preserv
Apache License 2.0
0 stars 0 forks source link

Building OpenStreetMap #99

Closed 0e1 closed 2 years ago

0e1 commented 2 years ago

A consulta a seguir informa a quantidade de building nos dados do OpenStreetMap (_pk0004.03). Essa tag possui uma variedade de valores possíveis, descritos em Buildings.

ingest88=# SELECT count(osm_id) FROM jplanet_osm_polygon WHERE tags->'building' is not null;
  count  
---------
 6809336
(1 row)

Nos dados, 363 valores estão presentes. Os principais, acima de 1000 geometrias, são listados a seguir.

É válido fazer uma filtragem desses valores antes da ingestão dos dados? Eu acho que não.

A view utilizada na ingestão é:

psql $(pg_uri_db) -c "CREATE VIEW vw{{file}}_{{tabname}} AS SELECT way, tags - ARRAY['addr:housenumber','addr:street'] || jsonb_objslice(ARRAY['addr:housenumber','addr:street'], tags, ARRAY['house_number','via_name']) AS tags FROM jplanet_osm_polygon WHERE tags->'building' IS NOT NULL AND country_id = {{country_id}}::smallint "
SELECT tags->'building' AS building_type, count(osm_id)
FROM jplanet_osm_polygon
WHERE tags->'building' is not null
GROUP BY tags->'building'
ORDER BY count(osm_id) DESC;

                               building_type                               |  count  
---------------------------------------------------------------------------+---------
 "yes"                                                                     | 5768760
 "house"                                                                   |  704095
 "residential"                                                             |  105205
 "apartments"                                                              |   43715
 "roof"                                                                    |   27982
 "industrial"                                                              |   25660
 "school"                                                                  |   17248
 "commercial"                                                              |   15089
 "construction"                                                            |   11323
 "retail"                                                                  |    9946
 "church"                                                                  |    9607
 "university"                                                              |    7484
 "shed"                                                                    |    6970
 "public"                                                                  |    4362
 "warehouse"                                                               |    3748
 "farm"                                                                    |    3707
 "garage"                                                                  |    3465
 "hospital"                                                                |    3079
 "ruins"                                                                   |    2351
 "greenhouse"                                                              |    2201
 "detached"                                                                |    2121
 "terrace"                                                                 |    2050
 "farm_auxiliary"                                                          |    1903
 "hotel"                                                                   |    1833
 "chapel"                                                                  |    1798
 "storage_tank"                                                            |    1782
 "office"                                                                  |    1681
 "carport"                                                                 |    1673
 "semidetached_house"                                                      |    1465
 "cowshed"                                                                 |    1320
 "service"                                                                 |    1296
 "poultry_house"                                                           |    1208
 "transportation"                                                          |    1154
 "hangar"                                                                  |    1082
0e1 commented 2 years ago

Foi decidido fazer a ingestão dos building junto com os pontos em geoaddress por meio da função ST_PointOnSurface.

A consulta a seguir ilustra a quantidade de pontos resultante:


ingest88=# SELECT count(*)  FROM (
SELECT way, tags - ARRAY['addr:housenumber','addr:street'] || jsonb_objslice(ARRAY['addr:housenumber','addr:street'], tags, ARRAY['house_number','via_name']) AS tags FROM jplanet_osm_point WHERE tags ?| ARRAY['addr:housenumber','addr:street']
UNION ALL
SELECT ST_PointOnSurface(way) AS way, tags - ARRAY['addr:housenumber','addr:street'] || jsonb_objslice(ARRAY['addr:housenumber','addr:street'], tags, ARRAY['house_number','via_name']) AS tags FROM jplanet_osm_polygon WHERE tags ?| ARRAY['addr:housenumber','addr:street'] AND tags ?& ARRAY['building']
) t
;
  count  
---------
 1101237
(1 row)