Try this query to filter only buildings and output a geojson.
[out:json];
area[name="Ouro Preto"]->.b;
rel(area.b)[name="Ouro Preto"];
map_to_area -> .a;
way["building"](area.a);
out geom;
relation["building"](area.a);out;
way(r)[!"building:part"];
convert item ::=::,::geom=geom(),_osm_type=type();
out geom;
run the query from
https://overpass-turbo.eu/s/1Hab
sample output:
{
"version": 0.6,
"generator": "Overpass API 0.7.61.5 4133829e",
"osm3s": {
"timestamp_osm_base": "2024-02-09T22:14:53Z",
"timestamp_areas_base": "2024-02-09T18:24:03Z",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
},
"elements": [
{
"type": "way",
"id": 8609215,
"bounds": {
"minlat": -19.8758738,
"minlon": -43.9790817,
"maxlat": -19.8738722,
"maxlon": -43.9771127
},
"nodes": [
351982128,
61264141,
61264318,
61264301,
61264287,
61264270,
61264251,
61264235,
61264217,
61264202,
61264184,
61264171,
61264154,
351982127,
351982129,
6832228139,
351982135,
351982143,
351982142,
6383366111,
6832228138,
351982130,
351982128
],
"geometry": [
{ "lat": -19.8748955, "lon": -43.9773098 },
{ "lat": -19.8756889, "lon": -43.9771127 },
{ "lat": -19.8758738, "lon": -43.9779543 },
{ "lat": -19.8751530, "lon": -43.9781335 },
{ "lat": -19.8752195, "lon": -43.9784360 },
{ "lat": -19.8751560, "lon": -43.9784518 },
{ "lat": -19.8752450, "lon": -43.9788567 },
{ "lat": -19.8749198, "lon": -43.9789375 },
{ "lat": -19.8748302, "lon": -43.9785302 },
{ "lat": -19.8744404, "lon": -43.9786270 },
{ "lat": -19.8745230, "lon": -43.9790029 },
{ "lat": -19.8742060, "lon": -43.9790817 },
{ "lat": -19.8738722, "lon": -43.9775629 },
{ "lat": -19.8744116, "lon": -43.9774289 },
{ "lat": -19.8745176, "lon": -43.9773380 },
{ "lat": -19.8744760, "lon": -43.9772549 },
{ "lat": -19.8744502, "lon": -43.9771992 },
{ "lat": -19.8745940, "lon": -43.9771489 },
{ "lat": -19.8746999, "lon": -43.9771456 },
{ "lat": -19.8746981, "lon": -43.9771899 },
{ "lat": -19.8746942, "lon": -43.9772871 },
{ "lat": -19.8747283, "lon": -43.9772917 },
{ "lat": -19.8748955, "lon": -43.9773098 }
],
"tags": {
"building": "supermarket"
}
},
{
"type": "way",
"id": 31489703,
"bounds": {
"minlat": -19.8714245,
"minlon": -43.9798083,
"maxlat": -19.8711520,
"maxlon": -43.9795213
},
"nodes": [
351982912,
351982913,
351982914,
351982915,
351982918,
351982919,
351982921,
351982912
],
"geometry": [
{ "lat": -19.8711520, "lon": -43.9795750 },
{ "lat": -19.8713892, "lon": -43.9795213 },
{ "lat": -19.8714245, "lon": -43.9795562 },
{ "lat": -19.8714119, "lon": -43.9797681 },
{ "lat": -19.8712807, "lon": -43.9798083 },
{ "lat": -19.8712555, "lon": -43.9797118 },
{ "lat": -19.8711823, "lon": -43.9797198 },
{ "lat": -19.8711520, "lon": -43.9795750 }
],
"tags": {
"building": "yes",
"created_by": "Merkaartor 0.13"
}
},
{
"type": "way",
"id": 31489709,
"bounds": {
"minlat": -19.8710713,
"minlon": -43.9819487,
"maxlat": -19.8708947,
"maxlon": -43.9816778
},
"nodes": [
351982929,
351982931,
351982934,
351982942,
351982929
],
"geometry": [
{ "lat": -19.8709452, "lon": -43.9819487 },
{ "lat": -19.8710033, "lon": -43.9819380 },
{ "lat": -19.8710713, "lon": -43.9816778 },
{ "lat": -19.8708947, "lon": -43.9817154 },
{ "lat": -19.8709452, "lon": -43.9819487 }
],
"tags": {
"addr:city": "Belo Horizonte - MG",
"addr:housename": "Padaria Trigo Dourado",
"addr:housenumber": "540",
"addr:postcode": "31310-240",
"addr:street": "Rua Conceição do Mato Dentro",
"addr:suburb": "Ouro Preto",
"building": "yes",
"building:levels": "2",
"name": "Padaria Trigo Dourado",
"shop": "bakery"
}
},
{
"type": "way",
"id": 48414351,
"bounds": {
"minlat": -19.8653669,
"minlon": -43.9837218,
"maxlat": -19.8651555,
"maxlon": -43.9835352
},
"nodes": [
614918567,
614918572,
614918581,
614918602,
614918612,
614918613,
614918567
],
"geometry": [
{ "lat": -19.8651555, "lon": -43.9836955 },
{ "lat": -19.8652798, "lon": -43.9837218 },
{ "lat": -19.8653669, "lon": -43.9835903 },
{ "lat": -19.8652824, "lon": -43.9835352 },
{ "lat": -19.8652078, "lon": -43.9836456 },
{ "lat": -19.8651654, "lon": -43.9836613 },
{ "lat": -19.8651555, "lon": -43.9836955 }
],
"tags": {
"building": "yes"
}
},
{
"type": "way",
"id": 95953282,
"bounds": {
"minlat": -19.8706899,
"minlon": -43.9822847,
"maxlat": -19.8704980,
"maxlon": -43.9820407
},
"nodes": [
3322143376,
1111816144,
1111816153,
1111816154,
3322143376
],
"geometry": [
{ "lat": -19.8705413, "lon": -43.9822847 },
{ "lat": -19.8706899, "lon": -43.9821647 },
{ "lat": -19.8706638, "lon": -43.9820407 },
{ "lat": -19.8704980, "lon": -43.9820828 },
{ "lat": -19.8705413, "lon": -43.9822847 }
],
"tags": {
"amenity": "bank",
"brand": "Santander",
"brand:wikidata": "Q5835668",
"brand:wikipedia": "en:Santander Bank",
"building": "yes",
"name": "Santander",
"operator": "Santander",
"source": "Bing;survey"
}
},
{
"type": "way",
"id": 128328700,
"bounds": {
"minlat": -7.9956116,
"minlon": -34.8597882,
"maxlat": -7.9951364,
"maxlon": -34.8590839
},
"nodes": [
1418503461,
1418503494,
1418503498,
1418503475,
1418503453,
1418503442,
6139756591,
6139756592,
6139756590,
6139756589,
6139756588,
6139756587,
6139756586,
6139756585,
1418503485,
1418503444,
1418503461
],
"geometry": [
{ "lat": -7.9954107, "lon": -34.8592364 },
{ "lat": -7.9954121, "lon": -34.8591833 },
{ "lat": -7.9951364, "lon": -34.8591532 },
{ "lat": -7.9951397, "lon": -34.8590839 },
{ "lat": -7.9954373, "lon": -34.8590949 },
{ "lat": -7.9955110, "lon": -34.8591406 },
{ "lat": -7.9954858, "lon": -34.8595478 },
{ "lat": -7.9955345, "lon": -34.8595496 },
{ "lat": -7.9955385, "lon": -34.8594912 },
{ "lat": -7.9956116, "lon": -34.8595040 },
{ "lat": -7.9956089, "lon": -34.8595783 },
{ "lat": -7.9955431, "lon": -34.8595644 },
{ "lat": -7.9955362, "lon": -34.8596707 },
{ "lat": -7.9954823, "lon": -34.8596597 },
{ "lat": -7.9954591, "lon": -34.8597882 },
{ "lat": -7.9953623, "lon": -34.8597804 },
{ "lat": -7.9954107, "lon": -34.8592364 }
],
"tags": {
"building": "yes",
"name": "Antiga sede da TV Globo Nordeste"
}
},
{
"type": "way",
"id": 128351221,
"bounds": {
"minlat": -7.9836090,
"minlon": -34.8569200,
"maxlat": -7.9817932,
"maxlon": -34.8557339
},
"nodes": [
1418697907,
5830962193,
6871717953,
6871717951,
5830962194,
5830962189,
5830962190,
5830962188,
5830962187,
5830962191,
5830962192,
1418697904,
1418697910,
7424105933,
7424105934,
7424105935,
1418697894,
1418697907
],
"geometry": [
{ "lat": -7.9818608, "lon": -34.8566166 },
{ "lat": -7.9827253, "lon": -34.8562632 },
{ "lat": -7.9827373, "lon": -34.8562932 },
{ "lat": -7.9827671, "lon": -34.8563673 },
{ "lat": -7.9827792, "lon": -34.8563975 },
{ "lat": -7.9819014, "lon": -34.8567564 },
{ "lat": -7.9819671, "lon": -34.8569200 },
{ "lat": -7.9833803, "lon": -34.8563336 },
{ "lat": -7.9833285, "lon": -34.8561841 },
{ "lat": -7.9828217, "lon": -34.8563912 },
{ "lat": -7.9827653, "lon": -34.8562504 },
{ "lat": -7.9836090, "lon": -34.8559055 },
{ "lat": -7.9835402, "lon": -34.8557339 },
{ "lat": -7.9829463, "lon": -34.8559767 },
{ "lat": -7.9825149, "lon": -34.8561531 },
{ "lat": -7.9820811, "lon": -34.8563304 },
{ "lat": -7.9817932, "lon": -34.8564481 },
{ "lat": -7.9818608, "lon": -34.8566166 }
],
"tags": {
"building": "transportation",
"layer": "1"
}
},
{
"type": "way",
"id": 139818910,
"bounds": {
"minlat": -7.9990270,
"minlon": -34.8696357,
"maxlat": -7.9987831,
"maxlon": -34.8693902
},
"nodes": [
1532341701,
1532341703,
1532341698,
1532341695,
1532341711,
1532341700,
1532341710,
1532341702,
5782239142,
5782239143,
1532341704,
1532341689,
1532341707,
1532341708,
1532341713,
1532341714,
1532341687,
1532341721,
1532341688,
1532341701
],