domingo, 18 de outubro de 2015

OpenStreetmap Extrair bordas

./osmconvert latest-brazil.osm.pbf --out-o5m > latest-brazil.o5m

./osmfilter latest-brazil.o5m --keep="all boundary=administrative admin_level=2 =3" > brazil_borders.osm

10 admin_level values for Brazil:

https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dadministrative


1 - N/A
2 - Fronteira Nacional (National Border)
3 - Regiões (Sul, Sudeste, Centro-Oeste, Norte, Nordeste. (Regions)
4 - Unidades Federativas (Estados e Distrito Federal. (States)
5 - Mesorregiões (Meso-regions)  http://en.wikipedia.org/wiki/pt:Mesorregi%C3%B5es
6 - Regiões Metropolitanas. (Metropolitan Areas)
7 - Microrregiões (Micro-regions)
8 - Municípios e Regiões Administrativas do Distrito Federal (Municipalities)
9 - Distrito e Sub-Prefeituras (Districts)
10 - Bairros e Sub-Distritos (Suburbs and Neighborhoods).

osmfilter brazil-latest.o5m  --keep="natural=coastline" > brazil_coastline.osm




Exemplos de uso do osmfilter

./osmfilter norway.osm --keep="highway=primary =secondary waterway=river" >streets.osm
./osmfilter switzerland.o5m --keep="highway=cycleway and lit=yes" >litcycles.osm
./osmfilter europe.o5m --keep= --keep-relations="route=bus" --out-o5m >bus_lines.o5m
./osmfilter bayern.o5m --keep="admin_level=6 and name=Nürnberger\ Land" -o=nbg_boundaries.osm


--keep-nodes="fixme=" --keep-ways= --keep-relations=
--keep= --keep-nodes="fixme="

drop objetos
./osmfilter europe.o5m --keep="highway=" --drop="access=no" -o=good_ways.osm

--drop-nodes
--drop-ways
--drop-relations


--keep="place=city or ( place=town and population>=10000 )"
--keep="name=main* and highway=*ary and source=*aerial*"


./osmfilter a.o5m --keep-tags="all amenity=restaurant =fast_food" -o=food.osm
./osmfilter a.o5m --keep-tags="all highway= waterway= name=" -o=ways.o5m

./osmfilter a.o5m --drop-tags="oneway= name=" -o=plain_ways.o5m


./osmfilter a.o5m --keep="route=" --drop-author -o=b.o5m


./osmfilter a.o5m --keep="route=" --drop-version -o=b.o5m



Getting Tag Statistics
To decide which items to keep and which items to drop, an overview over all tags used in a file would be helpful. There are four different output formats. The following sections will introduce these formats with the help of examples. All outputs have been clipped to 10 lines length.
List of all Keys
./osmfilter bremen.o5m --out-key
          5 Boden
          1 EE
         84 FIXME
          1 Fone
          7 StrVz
        113 TMC:cid_58:tabcd_1:Class
         78 TMC:cid_58:tabcd_1:Direction
        107 TMC:cid_58:tabcd_1:LCLversion
        110 TMC:cid_58:tabcd_1:LocationCode
         47 TMC:cid_58:tabcd_1:NextLocationCode
The first column shows the number of occurrences.
To specify a group of neighboring keys, you may use a wildcard at the end, for example:
--out-key=addr:*
List of all Keys, sorted by Occurrence
./osmfilter bremen.o5m --out-count
      28199 highway
      22794 building
      21365 name
      18754 created_by
      17751 source
      11842 addr:housenumber
      11835 addr:street
       5925 addr:postcode
       5724 foot
       5543 addr:city
List of a Key's Values
./osmfilter bremen.o5m --out-key=railway
        156 abandoned
          6 abandoned_tram
         16 buffer_stop
          2 bumper_stop
          9 construction
         31 crossing
         31 disused
          8 halt
        269 level_crossing
         38 platform
List of a Key's Values, sorted by Occurrence
./osmfilter bremen.o5m --out-count=railway |head
       1570 rail
        269 level_crossing
        192 tram
        182 tram_stop
        156 abandoned
        126 spur
         81 razed
         38 platform
         31 crossing
         31 disused
Parameter File
The command line argument can get very long if you specify complex filters. Please use a parameter file instead and refer to this file with --parameter-file=. For example:
./osmfilter europe.o5m --parameter-file=my_parameters >line_1.o5m
File "my_parameters":
-v

--keep=

--keep-relations=
all
route=bus
line=1

--drop-tags=
operator=
direction=

--out-o5m
Empty lines are used to separate the parameters. Linefeeds within parameters will be converted to spaces.
Benchmarks
Planet Pistes
16GB ram, 7200rpm disk
 $ time ./osmfilter new-planet-latest.o5m --keep="piste:type= or aerialway=" > pistes.osm

 real 12m5.413s
 user 4m30.465s
 sys 0m28.742s
Planet Waterways & Naturals
 $ time ./osmfilter planet-121207.o5m --keep= --keep-ways="natural= or waterway=" --keep-relations="natural= or waterway=" -o=planet-natural-temp.o5m

 real 8m6.760s
 user 5m27.622s
 sys 0m35.670s



FONTE: http://wiki.openstreetmap.org/wiki/Osmfilter










Nenhum comentário: