-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-areas.js
More file actions
54 lines (53 loc) · 1.45 KB
/
build-areas.js
File metadata and controls
54 lines (53 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import fs from "fs";
import { mask } from "@turf/mask";
import { union } from "@turf/union";
import queryOverpass from "query-overpass";
queryOverpass(
`nwr[wikidata=Q1370][type=boundary]; out geom;`,
(error, data) => {
if (error) {
console.error(error);
} else {
data = data.features.filter((f) => f.geometry.type === "Polygon")[0];
fs.writeFileSync("va-area.geojson", JSON.stringify(data));
data = mask(data);
fs.writeFileSync("va-mask.geojson", JSON.stringify(data));
}
},
);
queryOverpass(
`nwr[wikidata=Q43421][type=boundary]; out geom;`,
(error, data) => {
if (error) {
console.error(error);
} else {
data = data.features.filter((f) => f.geometry.type === "Polygon")[0];
fs.writeFileSync("rva-area.geojson", JSON.stringify(data));
data = mask(data);
fs.writeFileSync("rva-mask.geojson", JSON.stringify(data));
}
},
);
queryOverpass(
`
(
nwr[wikidata=Q43421][type=boundary];
nwr[wikidata=Q341639][type=boundary];
nwr[wikidata=Q340608][type=boundary];
);
out geom;
`,
(error, data) => {
if (error) {
console.error(error);
} else {
data.features = data.features.filter(
(f) => f.geometry.type === "Polygon",
);
data = union(data);
fs.writeFileSync("greater-rva-area.geojson", JSON.stringify(data));
data = mask(data);
fs.writeFileSync("greater-rva-mask.geojson", JSON.stringify(data));
}
},
);