-
Notifications
You must be signed in to change notification settings - Fork 202
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
fio command for calculating new properties #273
Comments
@perrygeo Yes! I have been thinking about this as well but have not had a reason to dig in. I have a This could look something like: fio \
cat infile.geojson \
buffer --dist 100 \
simplify --tolerance 10 \
reproject --dst-crs EPSG:4326 \
calc --new area "shape(f['geometry']).area" \
load --driver GeoJSON out.geojson Or maybe just reading from stdin and writing to stdout with fio cat infile.geojson | \
buffer --dist 100 \
simplify --tolerance 10 \
reproject --dst-crs EPSG:4326 \
calc --new area "shape(feature['geometry']).area" |\
fio load --driver GeoJSON out.geojson Or as its own subcommand with an initial command to open the file and a final command to save: fio pipe \
open infile.geojson \
buffer --dist 100 \
simplify --tolerance 10 \
reproject --dst-crs EPSG:4326 \
calc --new area "shape(feature['geometry']).area" \
save --driver GeoJSON out.geojson |
@geowurster Thanks for pointing out As for the click command chaining, it looks great, cleaner syntax for sure. And it avoids serializing-deserializing at each command, firing up a new interpreter, etc. A bit OT for this issue but where does #173 stand? command-chaining vs pipes aside, what do you think about the interface ( |
@perrygeo I only pointed out #173 is held up by some design decisions that are dictated by whether or not the current CLI can be made chain-able or if chaining will need to be relegated to a subcommand. Each have their pros and cons. I haven't had time to experiment with it but it miiiiiiight be possible to make the current CLI chain-able. As far as the syntax and use of Python expressions go, see my comment in #272. |
Does @geowurster's the original example would become
simple enough and more general-purpose. If we had dot notation in pyin, it starts looking even better at the expense of being a little bit longer
So is there any value in a |
@perrygeo No need to import Unfortunately Another option is to depend on |
@geowurster @perrygeo is this one resolved or is it still active? |
I'd love to see something like this, the geojson cli equivalent to "attribute table calculator" which is core functionality in many GIS workflows. Just waiting for some consensus on if/how it should be implemented in fiona. Still an open conversation, let's not close just yet. My take: adding this functionality would be simple and generically useful. I've developed lots of feature processing functions which do more specialized tasks (e.g. add a new Is that a good idea? Are there other general json processing tools that already do this? Or is this the realm of python code and doesn't really fit the command line? |
Agreed that a command line field calculator would be a great addition. Seems like |
fio calc
could take a stream of GeoJSON features on stdin calculate additional properties.For each feature, it could evaluate one or more expressions, place the derived variable(s) in the
properties
dict then print the feature to stdout.So for this input:
You might have a CLI something like this
which would yield
There are obviously some details to work out
If there's interest in the general idea, I can get started on a PR
The text was updated successfully, but these errors were encountered: