-
Notifications
You must be signed in to change notification settings - Fork 132
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
TypeError : cell_to_boundary() got an unexpected keyword argument 'geo_json' #380
Comments
Could you give an example of the behavior you're expecting? Also, this is for v3.7. You may want to try the new v4.0: |
when I use the function I try to pass it explicitly the assignment of a value to the geo_json argurment but it does not like when i do that. the example is What I expect to do: useGeoJsonFormat = True
cell_value = '827507fffffffff'
h3.cell_to_boundary(cell_value, geo_json=useGeoJsonFormat) This thows the error in the title What I end up having to do that works and is a work around useGeoJsonFormat = True
cell_value = '827507fffffffff'
h3.cell_to_boundary(cell_value, useGeoJsonFormat) |
Looking through the source code, myself, I'm not sure that EDIT: I don't see it in the Cython, either, though I didn't expect it there; more that it'd be at a higher level restructuring it's output. EDIT2: I did a local check of the repo and there's only one place where the string
So I think this feature was accidentally dropped during the rewrite for H3 4.0 vs 3.x. @tomrussell-willdan I would say if you need this feature, at the moment you should use h3-py's 3.7.x release, calling |
thanks. I think for now we will stick on 4.0 and just flip the output ourselves. So is the plan to continue having arguements for geo_json conformity and it was just accidently not included or is the plan to not continue supporting it those arguements? |
@tomrussell-willdan with your solution I get:
It seems the flag is gone, and the documentation is out of date (deprecating the flag, and the new naming convention make more sense than before to me).
from shapely import to_geojson
from shapely.geometry import Polygon
to_geojson(Polygon(h3.cell_to_boundary("827507fffffffff")))
NOTE this solution with shapely returns the coordinates in lat/lon ordering, not in lon/lat. If you are looking for lon/lat look under the @ajfriend message below.
Another option to get the geojson in lon/lat coordinates is to_geojson(Polygon([a[::-1] for a in h3.cell_to_boundary(x)])) |
You can see the Python docs for the newly-released v4 here: https://uber.github.io/h3-py/polygon_tutorial.html In v4, an easy way to get a d = h3.cells_to_geo(['827507fffffffff']) giving: {'type': 'Polygon',
'coordinates': (((-3.4710946837530763, 6.357653288041298),
(-2.159048476284375, 6.645580466394947),
(-1.9395631182409523, 8.00719366148785),
(-3.071080368716595, 9.072581251751162),
(-4.392258230519222, 8.74778122110663),
(-4.572995371627281, 7.395109809160045),
(-3.4710946837530763, 6.357653288041298)),)} which you could convert to a JSON string like: import json
json.dumps(d) giving: {"type": "Polygon", "coordinates": [[[-3.4710946837530763, 6.357653288041298], [-2.159048476284375, 6.645580466394947], [-1.9395631182409523, 8.00719366148785], [-3.071080368716595, 9.072581251751162], [-4.392258230519222, 8.74778122110663], [-4.572995371627281, 7.395109809160045], [-3.4710946837530763, 6.357653288041298]]]} We haven't yet added it, but maybe we should consider an option to give the GeoJSON string output, in addition to the dictionary output. (@SebKp, your solution above is close, but it results in lat/lng ordering instead of the lng/lat ordering that GeoJSON expects.) |
cell_to_boundary() not accepting direct assingment of arguement for unpacking.
The text was updated successfully, but these errors were encountered: