Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3ec56ab

Browse filesBrowse files
committed
Fix land layer, clean up comments
1 parent d6ea8ab commit 3ec56ab
Copy full SHA for 3ec56ab

File tree

Expand file treeCollapse file tree

1 file changed

+10
-52
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-52
lines changed

‎tasks/topojson/process_geodata.mjs

Copy file name to clipboardExpand all lines: tasks/topojson/process_geodata.mjs
+10-52Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ function addCentroidsToGeojson(geojsonPath) {
5757
}
5858

5959
async function createLandLayer({ bounds, name, resolution, source }) {
60-
// TODO: Figure out way to only include North and Central America via filter, dissolve
61-
const inputFilePath = `${outputDirGeojson}/${unFilename}_${resolution}m/${source}.geojson`;
60+
const inputFilePath = `${outputDirGeojson}/${name}_${resolution}m/countries.geojson`;
6261
const outputFilePath = `${outputDirGeojson}/${name}_${resolution}m/land.geojson`;
6362
const commands = [
6463
inputFilePath,
@@ -216,54 +215,29 @@ async function convertLayersToTopojson({ name, resolution }) {
216215

217216
// Get polygon features from UN GeoJSON and patch Antarctica gap
218217
const inputFilePathUNGeojson = `${inputDir}/${unFilename}.geojson`;
219-
const inputFilePathAntarcticaPatch = './tasks/topojson/antarctica_patch.geojson';
220-
const outputFilePath50m = `${outputDirGeojson}/${unFilename}_50m/all_features.geojson`;
221-
const outputPath110m = `${outputDirGeojson}/${unFilename}_110m`;
222-
// const commandsAllFeatures = [
223-
// inputFilePathUNGeojson,
224-
// // inputFilePathAntarcticaPatch,
225-
// // 'combine-files',
226-
// `-filter 'iso3cd === "ATA"' target=1 + name=antarctica`,
227-
// // '-merge-layers target=antarctica,antarctica_patch force',
228-
// '-clean snap-interval=0.015 target=antarctica',
229-
// // '-dissolve2 target=antarctica copy-fields=objectid,iso3cd,m49_cd,nam_en,lbl_en,georeg,geo_cd,sub_cd,int_cd,subreg,intreg,iso2cd,lbl_fr,name_fr,globalid,stscod,isoclr,ct,FID',
230-
// // '-dissolve2 target=antarctica',
231-
// `-filter 'georeg !== "ANT"' target=1`,
232-
// '-merge-layers target=1,antarctica force name=all_features',
233-
// `-o target=1 ${outputFilePath50m}`
234-
// ].join(" ")
235218
const commandsAllFeaturesCommon = [
236219
inputFilePathUNGeojson,
237220
`-filter 'iso3cd === "ATA"' target=1 + name=antarctica`,
221+
// Use 'snap-interval' to patch gap in Antarctica
238222
'-clean snap-interval=0.015 target=antarctica',
223+
// Add rectangle to extend Antarctica to bottom of world
239224
'-rectangle bbox=-180,-90,180,-89 name=antarctica_rectangle',
240225
'-merge-layers target=antarctica,antarctica_rectangle force',
241226
'-dissolve2 target=antarctica copy-fields=objectid,iso3cd,m49_cd,nam_en,lbl_en,georeg,geo_cd,sub_cd,int_cd,subreg,intreg,iso2cd,lbl_fr,name_fr,globalid,stscod,isoclr,ct,FID',
227+
// Remove unpatched Antarctica
242228
`-filter 'georeg !== "ANT"' target=1`,
229+
// Merge patched Antarctica
243230
'-merge-layers target=1,antarctica force name=all_features',
244231
]
232+
233+
// Process 50m UN geodata
234+
const outputFilePath50m = `${outputDirGeojson}/${unFilename}_50m/all_features.geojson`;
245235
const commandsAllFeatures50m = [
246236
...commandsAllFeaturesCommon,
247237
`-o target=1 ${outputFilePath50m}`
248238
].join(" ")
249239
await mapshaper.runCommands(commandsAllFeatures50m);
250240

251-
// const geojson = getJsonFile(outputFilePath50m);
252-
// const simplifiedGeojson = {
253-
// ...geojson,
254-
// features: geojson.features.map((f) => simplify(f, { tolerance: 0.1, highQuality: true }))
255-
// };
256-
// if (!fs.existsSync(outputPath110m)) fs.mkdirSync(outputPath110m, { recursive: true });
257-
// fs.writeFileSync(`${outputPath110m}/all_features.geojson`, JSON.stringify(simplifiedGeojson));
258-
259-
// const commandsAllFeatures110m = [
260-
// outputFilePath50m,
261-
// '-simplify 7% rdp',
262-
// `-o ${outputFilePath110m}`
263-
// ].join(" ")
264-
// await mapshaper.runCommands(commandsAllFeatures110m);
265-
266-
// Process 50m UN geodata
267241
// Get countries from all polygon features
268242
const inputFilePathCountries50m = outputFilePath50m;
269243
const outputFilePathCountries50m = `${outputDirGeojson}/${unFilename}_50m/countries.geojson`;
@@ -276,7 +250,7 @@ const commandsCountries50m = [
276250
await mapshaper.runCommands(commandsCountries50m);
277251

278252
// Get land from all polygon features
279-
const inputFilePathLand50m = outputFilePath50m;
253+
const inputFilePathLand50m = outputFilePathCountries50m;
280254
const outputFilePathLand50m = `${outputDirGeojson}/${unFilename}_50m/land.geojson`;
281255
const commandsLand50m = [
282256
inputFilePathLand50m,
@@ -300,6 +274,7 @@ const outputFilePathCountries110m = `${outputDirGeojson}/${unFilename}_110m/coun
300274
const commandsCountries110m = [
301275
inputFilePathCountries110m,
302276
`-filter '${filters.countries}'`,
277+
// Use 'snap-interval' to fix alignment issues with USA and Alaska, Mexico
303278
'-clean snap-interval=0.015',
304279
`-o ${outputFilePathCountries110m}`
305280
].join(' ');
@@ -319,23 +294,6 @@ for (const resolution of resolutions) {
319294
for (const { source } of Object.values(vectors)) {
320295
await convertShpToGeo(getNEFilename({ resolution, source }));
321296
}
322-
323-
// // Get countries from all polygon features
324-
// const inputFilePathCountries = `${outputDirGeojson}/${unFilename}_${resolution}m/all_features.geojson`;
325-
// const outputFilePathCountries = `${outputDirGeojson}/${unFilename}_${resolution}m/countries.geojson`;
326-
// const commandsCountries = [
327-
// inputFilePathCountries,
328-
// `-filter '${filters.countries}'`,
329-
// `-o ${outputFilePathCountries}`
330-
// ].join(' ');
331-
// await mapshaper.runCommands(commandsCountries);
332-
333-
// // Get land from all polygon features
334-
// const inputFilePathLand = outputFilePathCountries;
335-
// // const inputFilePathLand = `${outputDirGeojson}/${unFilename}_${resolution}m/all_features.geojson`;
336-
// const outputFilePathLand = `${outputDirGeojson}/${unFilename}_${resolution}m/land.geojson`;
337-
// const commandsLand = [inputFilePathLand, '-dissolve2', `-clean -o ${outputFilePathLand}`].join(' ');
338-
// await mapshaper.runCommands(commandsLand);
339297
}
340298

341299
for (const resolution of resolutions) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.