Skip to content

Conversation

@mattkolb
Copy link

I regularly go through the following process to go from ndjson (convenient for modifying data) to geojson (to project) and then to topojson to simplify and use.
($states; $objects)
| ndjson-reduce 'p.features.push(d), p' '{type: "FeatureCollection", features: []}'
| geostitch
| geoproject 'd3.geoMercator().rotate([" . (0 - $row[centroid_x]) . ", " . (0 - $row[centroid_y]) . "]).fitSize([$px_width, $px_height], d)'
| geo2topo all=-
| toposimplify --filter-all -p 1

The issue is that I need all of the data in a single geojson file so that I can use .fitSize() and maintain the same scale for all layers, but then when using it, I would much rather have the topojson split into layers.

The pull request would allow you to change the geo2topo command to "| geo2topo --split-layers" and use ndjson-map to specify the layer as a property of each like this:

($states | ndjson-map 'd.properties.layer = "states", d'; $objects | ndjson-map 'd.properties.layer = "objects", d')
| ndjson-reduce 'p.features.push(d), p' '{type: "FeatureCollection", features: []}'
| geostitch
| geoproject 'd3.geoMercator().rotate([" . (0 - $row[centroid_x]) . ", " . (0 - $row[centroid_y]) . "]).fitSize([$px_width, $px_height], d)'
| geo2topo --split-layers
| toposimplify --filter-all -p 1

I regularly go through the following process to go from ndjson (convenient for modifying data) to geojson (to project) and then to topojson to simplify and use.
($states; $objects) 
| ndjson-reduce 'p.features.push(d), p' '{type: \"FeatureCollection\", features: []}'
| geostitch
| geoproject 'd3.geoMercator().rotate([" . (0 - $row[centroid_x]) . ", " . (0 - $row[centroid_y]) . "]).fitSize([$px_width, $px_height], d)'
| geo2topo all=-
| toposimplify --filter-all -p 1

The issue is that I need all of the data in a single geojson file so that I can use .fitSize() and maintain the same scale for all layers, but then when using it, I would much rather have the topojson split into layers.

The pull request would allow you to change the geo2topo command to "| geo2topo --split-layers" and use ndjson-map to specify the layer as a property of each like this:

($states | ndjson-map 'd.properties.layer = "states", d'; $objects | ndjson-map 'd.properties.layer = "objects", d') 
| ndjson-reduce 'p.features.push(d), p' '{type: \"FeatureCollection\", features: []}'
| geostitch
| geoproject 'd3.geoMercator().rotate([" . (0 - $row[centroid_x]) . ", " . (0 - $row[centroid_y]) . "]).fitSize([$px_width, $px_height], d)'
| geo2topo --split-layers
| toposimplify --filter-all -p 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant