Skip to content

Commit 49bd7ae

Browse files
committed
Fix USA subunits layer, clean up land, coastlines layers
1 parent 4018b70 commit 49bd7ae

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

topojson/bin/process_geodata.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ async function createLandLayer({ bounds, name, resolution, source }) {
142142
const outputFilePath = `${outputDirGeojson}/${name}_${resolution}m/land.geojson`;
143143
const commands = [
144144
inputFilePath,
145-
'-dissolve',
145+
'-dissolve2',
146146
bounds.length ? `-clip bbox=${bounds.join(',')}` : '',
147147
`-o ${outputFilePath}`
148148
].join(' ');
@@ -200,7 +200,10 @@ async function createLakesLayer({ name, resolution, source }) {
200200
}
201201

202202
async function createSubunitsLayer({ name, resolution, source }) {
203-
const filter = ['AUS', 'BRA', 'CAN', 'USA'].map((id) => `adm0_a3 === "${id}"`).join(' || ');
203+
// Only include USA for 'usa' scope since the UN and NE borders don't match exactly and slivers of Canada creep in
204+
const filter = (name === 'usa' ? ['USA'] : ['AUS', 'BRA', 'CAN', 'USA'])
205+
.map((id) => `adm0_a3 === "${id}"`)
206+
.join(' || ');
204207
const inputFilePath = `${outputDirGeojson}/${getNEFilename({ resolution, source })}.geojson`;
205208
const outputFilePath = `${outputDirGeojson}/${name}_${resolution}m/subunits.geojson`;
206209
const commands = [
@@ -365,7 +368,8 @@ const commandsCountries50m = [
365368
`-each 'if (globalid === "{9FD54A50-0BFB-4385-B342-1C3BDEE5ED9B}") iso3cd = "XBT"'`, // Bir Tawil
366369
`-each 'if (iso3cd) iso3cd = iso3cd.toUpperCase()'`,
367370
`-filter '${filters.countries}'`,
368-
'-clean',
371+
// Snap polygons to clean up land, coastlines layers
372+
'-clean snap-interval=0.00013',
369373
`-o ${outputFilePathCountries50m}`
370374
].join(' ');
371375
await mapshaper.runCommands(commandsCountries50m);

0 commit comments

Comments
 (0)