Comments (4)
Thanks for the issue! Feedback like this is super helpful for me to think through pain points in the API and how we can smooth it out.
Honestly, I was hoping for more of these before releasing the final v4.0. So if you have any more, please do keep them coming!
I'll take a look at this and #365
from h3-py.
This should be fixed with https://github.com/uber/h3-py/releases/tag/v4.0.0b5, so I'll close this. Please let me know if you have any issues!
from h3-py.
I think the main issue here is that we don't handle the z-coordinate if it is present: #368
Also, you're having to reverse the coordinates because GeoPandas and GeoJSON use lng/lat coordinate order, while H3 is expecting lat/lng coordinate order. But ideally, we should just handle that translation automatically for you with functions like h3.geo_to_h3shape()
.
Once we implement #368, your code should be just:
usa = gpd.read_file('https://raw.githubusercontent.com/scdoshi/us-geojson/master/geojson/nation/US.geojson')
usa = usa.geometry[0]
shape = h3.geo_to_h3shape(usa)
However, in the meantime until #368, you can remove the z coordinate manually:
usa = gpd.read_file('https://raw.githubusercontent.com/scdoshi/us-geojson/master/geojson/nation/US.geojson')
usa = usa.geometry[0]
from shapely.ops import transform
def to_2d(x,y,z):
return x,y
usa = transform(to_2d, usa)
shape = h3.geo_to_h3shape(usa)
from h3-py.
Also, see the comments in https://gist.github.com/rmania/8c88377a5c902dfbc134795a7af538d8 for some potentially faster methods using WKT.
from h3-py.
Related Issues (20)
- h3.polyfill fails for simple polygon, works for subpolygon
- Support Python version 4.1 HOT 1
- Move cython test to its own folder HOT 5
- Update codecov action
- Unexpected Behavior with Multipolygons of Certain Seas in H3 Library (v4.0.0b2) HOT 8
- polyfill - how to get all intersected h3 polygons HOT 5
- Docs build action should trigger on PRs
- API reference needs to be updated with Polygon interface
- Update to [email protected] HOT 2
- h3.h3shape_to_cells | Error message unclear HOT 2
- Cannot use H3Poly to generate polygons HOT 2
- Add ability to handle (multi)polygons with Z-coordinate
- "geo_to_h3" and "h3_to_parent" return different values. HOT 2
- Handle point objects with __geo_interface__
- Example repo for a cython package that cimports h3-py HOT 2
- install location not inside site-packages HOT 4
- H3 Bug converting between geo and cell HOT 1
- ModuleNotFoundError: No module named 'h3._cy.cells' HOT 1
- Generate hexagons over areas not entirely within a polygon? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from h3-py.