5

How can I create a spatial binning similar to or directly using Uber from QGIS UI?

Are there plugins available to achieve the desired task?

2
  • 3
    If you explain how Uber H3 does spatial binning, you're more likely to get a useful answer. Otherwise the only people who can answer would be those who know both Uber H3 and QGIS, which may be a very small number of people.
    – csk
    Feb 1 '19 at 17:36
  • It looks like eng.uber.com/h3 and mostly consists of hexagons. A solution in python would also be great. Feb 1 '19 at 18:42
7

You can play with it using my #30DayMapChallenge hexagon demo https://github.com/ThomasG77/30DayMapChallenge/blob/master/day4_hexagons/data/h3-processing.py

Except the fact I do no use an UI, I combine both QGIS and Uber H3 Python library.

I clearly do not use all parts of the H3 Python library. I suppose the example could help you getting started.

4
  • Thanks Thomas. You're implementation was very helpful. I adapted it to generate hex grids for the extent of an input layer: github.com/maphew/code/blob/master/gis/qgis/… Feb 3 at 7:00
  • Thanks mat wilkie. I cant run the script.I get the error: File "<string>", line 55, in <module> IndexError: list index out of range
    – Torsten
    Mar 2 at 20:03
  • At github.com/maphew/code/blob/master/gis/qgis/…, the code is mylayer = QgsProject.instance().mapLayersByName(area_of_interest)[0]. It means QgsProject.instance().mapLayersByName(area_of_interest) is an empty list [] and you can't get the first element with [0]. That's why it throws an error
    – ThomasG77
    Mar 2 at 22:40
  • Thanks Thomas. That bug is now fixed, and a couple more besides. Results posted at gis.stackexchange.com/a/408312/108 Aug 14 at 5:58
5

I adapted @ThomasG77's 30 day challenge script into something that can be run from the Qgis processing toolbox.

Using Uber's H3 hex grid system in Qgis

https://github.com/maphew/code/tree/master/gis/qgis - h3-grid-from-layer.py

Usage

after Preparation has been completed

From Qgis:

  1. Select a template layer in table of contents to get extent from
    1. Optionally select specific features
  2. Processing tool box >> Open existing script: h3-grid-from-layer.py
  3. OR: Plugins >> Python console >> Open editor >> load script: h3-grid-from-layer.py
  4. Edit variables (particularly min/max resolution levels)
  5. Run

There is an error message of "it seems there is no valid script to run", but it works anyway.

screenshot: select extents layer, open script screenshot: edit min/max hexes screenshot: result

1

There's the official https://github.com/uber/h3-py

Python bindings for H3, a hierarchical hexagonal geospatial indexing system https://uber.github.io/h3/

but I haven't tried it myself.

1
1

Use the Create Grid tool in QGIS, and select hexagons.

For a more thorough, but still brief walk-through, see Jonathan Soma's blog.

(This is for creating a hex grid, it will not be specific to Uber's H3 grids. If you know the positioning and spacing of that grid you could use those numbers with this tool.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.