avatorl / Deneb-Vega-Help

Do you need help with Deneb custom visual for Power BI and/or Vega visualization grammar? Create an issue here to get assistance from Deneb community expert Andrzej Leszkiewicz.
3 stars 0 forks source link

Symbols from latitude longitude table constantly visible in orthographic projection #1

Closed KRShea closed 4 months ago

KRShea commented 4 months ago

Good morning,

I have been trying to modify the Vega earthquakes example to use in Deneb, but one issue that I am running into is that using a table with latitude and longitude rather than a geojson results in plotted symbols being constantly visible regardless of map rotation.

In the attached example, the blue dots represent two North American cities, but appear in Europe when the map is rotated. I have tried converting the coordinates to geopoints (attached), plotting the raw lat and long, and converting to geoshapes to plot as shapes (which doesn't work at all).

Submitting in the Deneb forum because ultimately this will be used in Deneb where I don't believe it is possible to use a geojson unless I hardcode values.

earthquakes_example_blue.json

issue_image
avatorl commented 4 months ago

See older version of my earthquakes globe implementation: https://raw.githubusercontent.com/avatorl/Deneb-Vega/87f8a61c77c46fff735b7b4ac43f5a6c407a2bbd/earthquakes-globe/earthquakes-globe.json

In that version I used .csv file as an earthquakes data source instead of geojson. In your case it will be a "dataset" from Power BI instead of the .csv file.

In both "fill" and "size" properties of the dots the following part of the formula returns 1 if a dot is on the visible side of the globe and 0 if a dot is on the invisible side of the globe:

(abs(globeRotationAngle)<=90?datum.longitude>=(globeRotationAngle-90)&&datum.longitude<=(globeRotationAngle+90)?1:0:globeRotationAngle<-90?datum.longitude>(globeRotationAngle-90+360)||datum.longitude<(globeRotationAngle+90)?1:0:globeRotationAngle>90?datum.longitude>(globeRotationAngle-90)||datum.longitude<(globeRotationAngle-180-90)?1:0:0)

If you will use the code as is, dots on the invisible side of the globe are small but visible anyway because "scaleSize" scale range starts from 0.1 (minimal dot size is 0.1). You can change "range" to [0, 10] to fully hide them.

  {
      "name": "scaleSize",
      "type": "pow",
      "domain": [0, 2, 6, 9],
      "range": [0.1, 10],
      "exponent": 2
    }

Or you update the scales using different approach. This version was just an experiment, it's not an example of proper scaling.

KRShea commented 4 months ago

Awesome this is exactly what I needed! Wish it were as easy as using geoshapes but it works!