pysal / tobler

Spatial interpolation, Dasymetric Mapping, & Change of Support
https://pysal.org/tobler
BSD 3-Clause "New" or "Revised" License
145 stars 30 forks source link

add hexify function #111

Closed knaaptime closed 3 years ago

knaaptime commented 3 years ago

following the example of some similar code from the gdsbook, this adds a function to generate a geodataframe of h3 hexagons in the footprint of a given source gdf. I think its useful to have around and i imagine would be useful to generate a target for interpolation

codecov-io commented 3 years ago

Codecov Report

Merging #111 (ea73d91) into master (a5d8649) will increase coverage by 4.53%. The diff coverage is 84.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #111      +/-   ##
==========================================
+ Coverage   37.20%   41.74%   +4.53%     
==========================================
  Files          11       12       +1     
  Lines         508      551      +43     
==========================================
+ Hits          189      230      +41     
- Misses        319      321       +2     
Impacted Files Coverage Δ
tobler/util/util.py 68.25% <71.42%> (+11.11%) :arrow_up:
tobler/tests/test_utils.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a5d8649...ea73d91. Read the comment docs.

knaaptime commented 3 years ago

sweet

Thinking through it, one of the values of putting this in tobler is not stopping at generating the hex geometries but having methods to take your data into H3 (or other indexing systems like S2 down the line, as I suggest in the review). You have a bunch of data on different shapefiles with different geometries for the same region, and tobler helps you "align" them on a standard system like H3.

definitely agree, and had the same idea particularly when toying around with this notebook in binder. I think the way rasters are handled is probably a lot fater than the way we're doing it now, so happy to keep exploring this thread

knaaptime commented 3 years ago

anybody got any idea why the tests arent passing? I can see h3 is in the environment but still getting an import error..?

knaaptime commented 3 years ago

got it, on conda, h3 is the C library and h3-py is the package of python bindings (whereas the pypi package is just h3)

darribas commented 3 years ago

sweet

Thinking through it, one of the values of putting this in tobler is not stopping at generating the hex geometries but having methods to take your data into H3 (or other indexing systems like S2 down the line, as I suggest in the review). You have a bunch of data on different shapefiles with different geometries for the same region, and tobler helps you "align" them on a standard system like H3.

definitely agree, and had the same idea particularly when toying around with this notebook in binder. I think the way rasters are handled is probably a lot fater than the way we're doing it now, so happy to keep exploring this thread

Let's move this to a separate issue to figure out ways forward. That notebooks seems to use rasters as DataFrame objects? In any case, I think @martinfleis and I may have ideas. I'll leave you open the issue @knaaptime as I think you'll have a better sense of what'd level would be best to discuss ("transferring" data to h3? a meta method to "transfers" data from one geography to another and has defaults to H3 and other indexing systems? Something else?