Overpass introduction/scripts

From OpenStreetMap Wiki
Jump to navigation Jump to search

Overpass / MapCSS script for high voltage lines in The Netherlands

[out:json][timeout:1000];
Template:GeocodeArea:nederland->.a;
(
  rel[route=power](Template:Bbox);
);
out ;
>;
out ;
{{style:
relation node, relation way, relation relation {
  color:#000;fill-color:#000;
}
node,
node[power=tower]
{ opacity: 0.0 ; fill-opacity: 0.0 ; color:#000000 ; fill-color: #AAAAAA ; symbol-size:6; width:2 ; 
}

relation node[power=cable], 
relation way[power=cable], 
relation relation[power=cable]
{ color:#66FF66; width:4 ; }
way
{ opacity:1.0; fill-opacity: 1.0 ; }
way[power=line]
{ color:#990000; fill-color:#990000; width:5; }
way[power=line][voltage=~/50000/],
way[route=power][voltage=~/50000/]
{ color:#bb0000; fill-color:#bb0000; width:5; }
way[power=line][voltage=~/380000/],
way[route=power][voltage=~/380000/]
{ color:#ff8888; fill-color:#ff8888; width:7; }
way[power=line][voltage=~/150000/],
way[route=power][voltage=~/150000/]
{ color:#dd4444; fill-color:#dd4444; width:5; }
way[power=line][voltage=~/220000/],
way[route=power][voltage=~/220000/]
{ color:#dd4444; fill-color:#dd4444; width:5; }
way[power=cable]
{ color:#888800; fill-color:#888800; width:5; }
way[power=cable][voltage=~/50000/]
{ color:#000044; fill-color:#000044; width:5; }
way[power=cable][voltage=~/300000/], 
way[power=cable][voltage=~/320000/],
way[power=cable][voltage=~/380000/],
way[power=cable][voltage=~/450000/]
{ color:#6666CC ; fill-color:#6666CC ; width:7; }
way[power=cable][voltage=~/600000/]
{ color:#8888FF ; fill-color:#8888FF ; width:9; }
way[power=cable][voltage=~/110000/], 
way[power=cable][voltage=~/150000/],
way[power=cable][voltage=~/155000/]
{ color:#222277 ; fill-color:#222277 ; width:5; }

 way[power=cable][voltage=~/220000/]
{ color:#4444AA ; fill-color:#4444AA ; width:5; }
}}

Overpass/MapCSS script for hydro power plants in the Nile

[out:json][timeout:2500];

(
{{geocodeArea:Egypt}};
{{geocodeArea:Sudan}};
{{geocodeArea:South Sudan}};
{{geocodeArea:Ethiopia}};
{{geocodeArea:Uganda}};
)->.a ;

//rel(50793); // Nile
(
wr[waterway=river][name~Nile](Template:Bbox)(area.a);
wr[waterway=river]["name:en"~Nile](Template:Bbox)(area.a);
)->.b;                 
 
(
wr[boundary=administrative][admin_level=2](Template:Bbox)(area.a);
)->.c;                 

(
.b;  
.c;  
wr(around.b:1000)[power=plant]["plant:source"=hydro](Template:Bbox)(area.a);
);
 
out body;
>;
out skel qt;

// see for power sources https://wiki.openstreetmap.org/wiki/Key:plant:source
 
{{style:

node
{ opacity:0.0; }

node, 
way, 
rel 
{ weight:2 ; }

node[waterway=river], 
way[waterway=river], 
rel[waterway=river] 
{ color: blue ; }

node[plant:output:electricity], 
way[plant:output:electricity], 
rel[plant:output:electricity] 
{ 
  text: 
    eval('tag("plant:source") . 
    " - " . 
    tag("plant:output:electricity") . 
    " - " .
    tag("name")') ; 
}

}}

Overpass/MapCSS script for supermarkets in Amsterdam

// https://wiki.openstreetmap.org/wiki/MapCSS/0.2
[out:json][timeout:25];
area[name="Amsterdam"]->.a;
//node[shop=supermarket][!brand](area.a) ;
node[shop=supermarket](area.a) ;
 
out count ;
>;
out;
  
{{style:
node[brand=~/Albert Heijn/]  { icon-image: url("https://www.infodisiac.com/osm/icons/ah8.png") ; icon-width:30 ; icon-height:26 ; }
node[name=~/Aldi/]           { icon-image: url("https://www.infodisiac.com/osm/icons/aldi6.png") ; icon-width:24 ; icon-height:25 ; }
node[name=~/Budget Food/]    { text:name ;}
node[name=~/Boni/]           { text:name ;}
node[name=~/"Boon's Markt"/] { text:name ;}
node[name=~/Dagwinkel/]      { text:name ;}
node[name=~/Dekamarkt/]      { text:name ;}
node[name=~/Deen/]           { text:name ;}
node[name=~/Dirk/]           { icon-image: url("https://www.infodisiac.com/osm/icons/dirk5.png") ; icon-width:28 ; icon-height:20 ; }
node[name=~/Ekoplaza/]       { text:name ;}
node[name=~/Hoogvliet/]      { icon-image: url("https://www.infodisiac.com/osm/icons/hoogvliet4.png") ; }
node[name=~/Jan Linders/]    { text:name ;}
node[brand=~/Jumbo/]         { icon-image: url("https://www.infodisiac.com/osm/icons/jumbo7.png") ; icon-width:26 ; icon-height:27 ; }
node[name=~/Landmarkt/]      { text:name ;}
node[name=~/Lekker Makkelijk/] { text:name ;}
node[name=~/Lidl/]           { icon-image: url("https://www.infodisiac.com/osm/icons/lidl4.png") ; icon-width:28 ; icon-height:28 ; }
node[name=~/Makro/]          { text:name ;}
node[name=~/MCD/]            { text:name ;}
node[name=~/Nettorama/]      { text:name ;}
node[name=~/ODIN/]           { text:name ;}
node[name=~/Pakgro/]         { text:name ;}
node[name=~/PLUS/]           { icon-image: url("https://www.infodisiac.com/osm/icons/plus2.png") ; icon-width:28 ; icon-height:33 ; }
node[name=~/Poiesz/]         { text:name ;}
node[name=~/Pryma/]          { text:name ;}
node[name=~/Sligro/]         { text:name ;}
node[name=~/Spar/]           { icon-image: url("https://www.infodisiac.com/osm/icons/spar5.png") ; }
node[name=~/Voedselbank*/]   { icon-image: url("https://www.infodisiac.com/osm/icons/voedselbank.png")}
node[name=~/Vomar/]          { icon-image: url("https://www.infodisiac.com/osm/icons/vomar2.png") ; icon-width:30 ; icon-height:30 ; }

node[!brand]                 { text:name; fill-color:black; fill-opacity:0.4; }

}}

//https://wiki.openstreetmap.org/wiki/WikiProject_Netherlands/Shops

Overpass/MapCSS script for public transport by rail in Amsterdam

// https://wiki.openstreetmap.org/wiki/Overpass_API
// https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL
// https://github.com/mapbox/mapping/wiki/Overpass:-Out-Syntax

[timeout:200]
[out:json];
area[name="Amsterdam"]->.a ;
(
  node(area.a)["railway"="station"]["station"!~"subway"]["tram"!~"yes"]({{bbox}});
  node(area.a)["railway"="station"]["station"="subway"]({{bbox}});
  nwr(area.a)["railway"="tram"]["railway"!="switch"]({{bbox}});
  nwr(area.a)["railway"="rail"]({{bbox}});
  nwr(area.a)["railway"="subway"]({{bbox}});
  nwr(area.a)["route"="tram"]({{bbox}});
);
out;
>;
out meta qt ;

{{style:
node
{ 
  opacity: 1;
  fill-opacity:0.5 ; 
  color: orange;
  fill-color:orange;
  symbol-size:0.01 ;
}
 
node[railway=station]
{ 
  text: name;
  color: blue; fill-color:blue ;
  symbol-size:8 ;
  width:2 ;
}

way[railway=rail]
{ 
  color: blue; fill-color:blue ;
  symbol-size:8 ;
  width:2 ;
}

node[station=subway]
{
  text: name;
  color: red;
  fill-color:red;
  symbol-size: 6 ;   
  width:4 ;
}

way[railway=subway]
{
  color: red;
  fill-color:red;
  symbol-size: 6 ;   
  width:4 ;
}

node[railway=tram],
way[railway=tram],
rel[railway=tram]
{
  color: orange;
  fill-color:orange;
  symbol-size: 3 ;   
}

node[route=tram_stop]
{ 
  text:name ;
  color: blue; fill-color:blue ;
  symbol-size:3 ;
  width:2 ;
}

node[railway=tram_stop],
way[railway=tram_stop],
rel[railway=tram_stop]
{
  color: orange;
  fill-color:orange;
  symbol-size: 2 ;   
}
}}

Overpass/MapCSS script for places of worship In Leiden

[out:json][timeout:400];
 {{geocodeArea:Leiden}}->.searchArea;
  
nw["amenity"="place_of_worship"]({{bbox}})(area.searchArea);
   
out body;
>;
out meta qt;
 
{{style: 
 
node, area
{ 
  color:red; 
  fill-color:red; 
  symbol-size: 3 ; 
  text: eval('tag("start_date") . " - " . tag("religion") . " - " . tag("denomination")');
}
 
node[denomination=catholic],way[denomination=catholic]
{ 
  color:purple; 
  fill-color:purple; 
  // test: convert 1418 into 15th century
  // text: eval('(int(tag("start_date") / 100)+1) . "th century"') ; 
}
 
node[denomination=protestant],way[denomination=protestant]
{ 
  color:blue; 
  fill-color:blue; 
} 
 
node[religion=muslim],way[religion=muslim]
{ 
  color:green; 
  fill-color:green; 
} 
 
}}
  
//  text: eval('(int(tag("start_date") / 100)+1) . "th century"') ; 
 
//  tag("start_date") => 1948
//  / 100             => 19.48
//  int ( )           => 19
//  +1                => 20
// ."th century"      => 20th century

Overpass/MapCSS script for green power in The Netherlands

// uncheck in Settings 'Don't display small features as POIs.'

[out:json][timeout:200];
area[name="Nederland"]->.ned;
(
nwr[power=plant]["plant:source"="wind"]({{bbox}})(area.ned);
nwr[power=plant]["plant:source"="solar"]({{bbox}})(area.ned);
nwr[power=plant]["plant:source"="biomass"]({{bbox}})(area.ned);
nwr[power=plant]["plant:source"="waste"]({{bbox}})(area.ned);
nwr[power=plant]["plant:source"="osmotic"]({{bbox}})(area.ned);
nwr[power=generator]["generator:source"="wind"]({{bbox}})(area.ned);
nwr[power=generator]["generator:source"="biomass"]({{bbox}})(area.ned);
nwr[power=generator]["generator:source"="waste"]({{bbox}})(area.ned);
nwr[power=generator]["generator:source"="osmotic"]({{bbox}})(area.ned);
);                 
out body;
>;
out meta qt;

// see for power sources https://wiki.openstreetmap.org/wiki/Key:plant:source

{{style:

node, way, tag
{ symbol-size:2 ; }

node[name][plant:source], 
way[name][plant:source], 
rel[name][plant:source]
{ color:orange ; fill-color:orange ; }

node[name][plant:source=biomass], 
way[name][plant:source=biomass], 
rel[name][plant:source=biomass]
{ color:green ; fill-color:green ; symbol-size:7 ;  width:5 }

node[name][plant:source=hydro], 
way[name][plant:source=hydro], 
rel[name][plant:source=hydro]
{ color:cyan ; fill-color:cyan ; symbol-size:7 ;  width:5 }

node[name][plant:source=coal], 
way[name][plant:source=coal], 
rel[name][plant:source=coal]
{ color:black ; fill-color:black ;  width:5 }

node[name][plant:source=gas], 
way[name][plant:source=gas], 
rel[name][plant:source=gas]
{ color:purple ; fill-color:purple ;  width:5 }

node[name][plant:source=nuclear], 
way[name][plant:source=nuclear], 
rel[name][plant:source=nuclear]
{ color:gray ; fill-color:gray ;  width:5 }

node[name][plant:source=waste], 
way[name][plant:source=waste], 
rel[name][plant:source=waste]
{ color:brown ; fill-color:brown ; symbol-size:7 ; width:5 }

node[name][plant:source=osmotic], 
way[name][plant:source=osmotic], 
rel[name][plant:source=osmotic]
{ color:purple ; fill-color:purple ; symbol-size:7 ;  width:5 }

node[name][plant:source=battery], 
way[name][plant:source=battery], 
rel[name][plant:source=battery]
{ color: magenta ; fill-color:magenta ;  width:5 }

node[plant:source=wind], 
way[plant:source=wind], 
rel[plant:source=wind],
node[generator:source=wind], 
way[generator:source=wind], 
rel[generator:source=wind]
{ color: blue ; fill-color:blue ; }


node[plant:source=solar], 
way[plant:source=solar], 
rel[plant:source=solar]
{ color: red ; fill-color:red ; symbol-size:4 ; width:4 }
 
}}

Overpass/MapCSS script for nuclear power production in Europe

 [out:json][timeout:1000];
 (
 nwr[power=plant]["plant:source"="nuclear"]({{bbox}});
 nwr[power=generator]["generator:source"="nuclear"]({{bbox}});
 );                 
 out body;
 >;
 out meta qt;
 // see for power sources https://wiki.openstreetmap.org/wiki/Key:plant:source

 {{style:
 node, way, tag
 { symbol-size:5; }
 node[plant:output:electricity!="yes"], 
 way[plant:output:electricity!="yes"], 
 rel[plant:output:electricity!="yes"], 
 node[generator:output:electricity!="yes"], 
 way[generator:output:electricity!="yes"], 
 rel[generator:output:electricity!="yes"]
 { 
   text: 
     eval('tag("plant:output:electricity") . 
     tag("generator:output:electricity")') ; 
 }
 }}

Overpass/MapCSS script for energy production in Zeeland

[out:json][timeout:100];
area[name="Zeeland"]->.a;
(
nwr[power=plant]({{bbox}})(area.a);
nwr[power=generator][location!=roof]({{bbox}})(area.a);
);                 
out body;
>;
out skel qt;
 
// see for power sources https://wiki.openstreetmap.org/wiki/Key:plant:source
 
{{style:
 
node[plant:source], 
way[plant:source], 
rel[plant:source]
{ text: plant:source ; }
 
node[name][plant:source], 
way[name][plant:source], 
rel[name][plant:source]
{ 
  text: 
    eval('tag("plant:source")') ; 
}
   
node[plant:output:electricity], 
way[plant:output:electricity], 
rel[plant:output:electricity] 
{ 
  text: 
    eval('tag("plant:source") . " " .
    tag("plant:output:electricity")') ;  
}
  
node[name][plant:source], 
way[name][plant:source], 
rel[name][plant:source]
{ color:orange ; fill-color:orange ; }
 
node[name][plant:source=biomass], 
way[name][plant:source=biomass], 
rel[name][plant:source=biomass]
{ color:green ; fill-color:green ; }
 
node[name][plant:source=hydro], 
way[name][plant:source=hydro], 
rel[name][plant:source=hydro]
{ color:cyan ; fill-color:cyan ; }
 
node[name][plant:source=coal], 
way[name][plant:source=coal], 
rel[name][plant:source=coal]
{ color:black ; fill-color:black ; }
 
node[name][plant:source=gas], 
way[name][plant:source=gas], 
rel[name][plant:source=gas]
{ color:purple ; fill-color:purple ; }
 
node[name][plant:source=nuclear], 
way[name][plant:source=nuclear], 
rel[name][plant:source=nuclear]
{ color:gray ; fill-color:gray ; }
 
node[name][plant:source=waste], 
way[name][plant:source=waste], 
rel[name][plant:source=waste]
{ color:brown ; fill-color:brown ; }
 
node[name][plant:source=battery], 
way[name][plant:source=battery], 
rel[name][plant:source=battery]
{ color: magenta ; fill-color:magenta ; }
 
node[generator:output:electricity][generator:source!=solar], 
way[generator:output:electricity][generator:source!=solar], 
rel[generator:output:electricity][generator:source!=solar] 
{ color: blue ; fill-color:blue ; symbol-size: 5 ; }
 
node[plant:source=wind], 
way[plant:source=wind], 
rel[plant:source=wind],
node[generator:source=wind], 
way[generator:source=wind], 
rel[generator:source=wind]
{ color: blue ; fill-color:blue ; symbol-size: 3 ; }
 
node[plant:source=solar], 
way[plant:source=solar], 
rel[plant:source=solar],
node[generator:source=solar], 
way[generator:source=solar], 
rel[generator:source=solar]
{ color: red ; fill-color:red ; width:3 ;}

}}