Hi,
I’m trying to write a query to count how many residential units (houses + appartments) there are within every suburb of this small municipality, which has 5 ‘suburbs’.
For the sake of simplicity in this thread I’m assuming there are two kinds of residential buildings:
- Those without “building:flats” tag are assumed to be 1 residential unit per building.
- Those with “building:flats” tag, then extract the tag’s value and add it up to the total.
Below is the code:
// Count residential units within every suburb of a municipality
[out:csv(name, total)];
{{geocodeArea:Maristela, Laranjal Paulista}}->.a;
// select suburbs
rel[admin_level=10](area.a);
map_to_area;
// for each suburb
foreach->.suburb(
// select and classify buildings
wr[building][!"building:flats"](area.suburb)->.houses;
wr[building]["building:flats"](area.suburb)->.apartments;
// for each apartment building
make counter n_apartments = 0;
foreach.apartments (
n_apartments = n_apartments + t['building:flats']; //**ERROR
);
// print stats
make stat name = suburb.set(t["name"]), total = houses.count(wr) + n_apartments; //**ERROR
out;
);
I’m getting error in the lines 18 and 21. The variable ‘n_apartments’ is read as “Unknown type” even though I’ve used ‘make’ to create it as a counter. I’ve tried to get around to it, but no avail.
Any help is appreciated,
5 posts - 2 participants
Ce sujet de discussion accompagne la publication sur https://community.openstreetmap.org/t/overpass-sum-the-values-of-a-tag-in-every-object-in-a-set/6365