Deck.gl: Hexagons rendered at (0, 0)

Created on 23 Jul 2018  路  18Comments  路  Source: visgl/deck.gl




Issue

I'm trying to recreate the hexagon example, but the hexagons aren't being rendered at the correct locations.

The data is the road accidents in the UK as per

data = {
  return d3.csv('https://raw.githubusercontent.com/uber-common/deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv', row => {
    return {lng: +row.lng, lat: +row.lat};
  })

Actual Result

In this screenshot I'm showing two layers - a scatterplot and a hexagon

screen shot 2018-07-23 at 12 40 30 pm

The scatterplot has rendered as expected - the blue dots over the UK

The hexagons have rendered at coordinates (0, 0) (you can see a small blue dot at location (0, 0) off the central-east coast of Africa at the bottom of the image), and I don't know why.

If it helps, this is the log of the hexagon and scatterplot layers

screen shot 2018-07-23 at 12 50 11 pm

Code Example

The two functions I'm using to create the hexagon and scatterplots are:

const hexagonLayer = new deck.HexagonLayer({
  id: 'hexagon'
  data,
  pickable: true,
  extruded: true,
  elevationRange: [0, 1000],
  elevationScale: 250,
  opacity: 1,
  getPosition: d => [d.lng, d.lat]
});
const scatterLayer = new deck.ScatterplotLayer({
  id: 'scatterplot',
  data,
  radiusScale: 1,
  radiusMinPixels: 1,
  getRadius: d => d.radius,
  getPosition: d => [d.lng, d.lat],
  getColor: d => hexToRgb( d.fill_colour )
});

Both functions are using the same getPosition: d => [d.lng, d.lat] function, and receive the same data object.

Background / extra detail

I'm an R programmer, not a javascript programmer, so I may have missed something obvious.

I'm making an R package (github repo here) which wraps deck.gl. Therefore my js functions are slightly different to the examples, as I have to receive the data from R.

The hexagon.js is here

The scatterplot.js is here

To Do List

  • [ ] Add label and assign to milestone
  • [ ] Coding
  • [ ] Test

Most helpful comment

Ok, found it, unlike other aggregation layers (Grid and ScreenGrid), HexagonLayer, aggregation depends on viewport, so when viewport is changed, we need to re-trigger the aggregation. PR coming up ...

Correction: PR updated : aggregate only once but with a valid viewport. No re-aggregation on viewport change. (like pan, zoom etc)

All 18 comments

@SymbolixAU
You are not providing getColor prop for hexagon layers, so the blue-dot you are seeing could be part of ScatterplotLayaer.
Couple of suggestions, 1. Can you increase elevationScale to see if it gets rendered. 2. Do not render scatterplot and see if anything rendered for hexagon. But otherwise your props seems to be fine and anything you are not set should use default values.
Also keep an eye on console to see if there are any errors.

@1chandu
is there a getColor prop? thegetColorValue says it's optional too.

Looking closer, the 'blue dot' is actually a 'scatter' dot on top of a yellow hexagon.

If I remove the scatter layer you can see the hexagon at (0, 0)

The small yellow 'dot' in the center
screen shot 2018-07-26 at 9 06 11 am

zooming in:
screen shot 2018-07-26 at 9 06 21 am

The console is not showing any warnings or errors
screen shot 2018-07-26 at 9 06 37 am

Not an error per-se, but of interest is the centroid is set to [0,0]

screen shot 2018-07-27 at 12 02 02 pm

And for what it's worth, I can get all the other layers rendered without issue

How are the centroids calculated, does this perhaps require a d3 library installed?

I'm encountering the same issue with the hexagon layer, a hexagons array of length 1 at [0,0] with all the items nested in the points array (as shown in the bottom screenshot of the console)

For me it seems an issue with the initial load state, once I manipulate the data and call my render method again (with the same data used initially), it works, displaying hexagons with the correct colors / elevations etc. so none of that is a problem, it seem an issue with the initial load.

There are no reported errors from deck.gl in the console

I'm using this in a Pure JS context.

Did you find a workaround @SymbolixAU ?

Dump of the layer on initial load (with single hex plotted issue):
image

Dump of the layer once data toggled back and forth using exact same data (displaying correctly):
image

@SymbolixAU @oller , I was able to reproduce this on my end. The problem is , when the first time hexbins are generated the viewport is not properly set yet, resulting in wrong projections. As a temporary work around if you update radius, which re-triggers the hex-bin aggregation, everything renders fine, I am looking into this.

Ok, found it, unlike other aggregation layers (Grid and ScreenGrid), HexagonLayer, aggregation depends on viewport, so when viewport is changed, we need to re-trigger the aggregation. PR coming up ...

Correction: PR updated : aggregate only once but with a valid viewport. No re-aggregation on viewport change. (like pan, zoom etc)

An update from my tests

versions: v6.1.0 and v6.1.1 of deckgl.min.js

  • Hexagons are still not rendered on the map
  • The console is showing hexagon data (and a hexagon-layer object) with centroids

screen shot 2018-09-26 at 3 50 29 pm

Likewise, having followed this issue's progress and noted it was added into the 6.1.1 milestone, I can confirm this still isn't resolved in 6.1.1 version in my scenario either.

Any update on this @1chandu? It'd be a shame to see all that work you put in not make a release. Thanks again!

Same issue in v6.2.0 of deckgl.min.js

@1chandu is this related to https://github.com/uber/deck.gl/issues/2215?

Closing this, remaining work is tracked in #2215

Sorry too soon, keeping it open due to this comment:

Same issue in v6.2.0 of deckgl.min.js

2376 published in deck.[email protected]. @SymbolixAU can you give it a try?

Wahey! Works for me in 6.2.1!

Thanks again for all your efforts with this lib!

Awesome! 6.2.1 is now my new favourite number.

hexagons

Thanks @Pessimistress @1chandu and the rest of the Deck.gl team

Was this page helpful?
0 / 5 - 0 ratings

Related issues

heumsi picture heumsi  路  4Comments

nagix picture nagix  路  3Comments

jacklam718 picture jacklam718  路  4Comments

SymbolixAU picture SymbolixAU  路  4Comments

patilvikram picture patilvikram  路  3Comments