Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update geo2topo #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Update geo2topo #8

wants to merge 2 commits into from

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