Monday 20 April 2020

Visualising Earth in PowerBI Custom Visual

Early on in my 3D visualisation experimentation was a desire to recreate the PowerMap experiance.  I eventually managed to find a source of land and country boundaries, which I was able to project into a 3D scene and then plot points based on latitude and longitude.
Country data as map
After many hours searching, experimenting and crying, I found a formula for projecting the points onto a sphere so I could create the globe.
Country data as sphere
But my map data was not perfect, and I wantted a more realistic globe image.  So I downloaded some image data from NASA at https://visibleearth.nasa.gov/.  There Blue Marble collection of images was perfect for my needs.
3D Earth Visualisation
Daytime Globe View

Nighttime Map Visualisation
Night Map View

Using my limited experiance and skills of 3D and PowerBI visual development, I was able to create a PowerBI Cutom Visual with a much more realisitic look and feel.  Points can be plotted by latitude and longitude, or a country can be highlighted by name, ISO2 or ISO3.


3D Earth Visualisation

My projection code (which is the key to making this work..) is as follows:

    private projectAsMap(longnumberlatnumberrnumber): THREE.Vector3 {         let z = long / 180.0;         let y = lat / 180.0;         return new THREE.Vector3(r, -y, -z);     }     private projectAsGlobe(longnumberlatnumberrnumber): THREE.Vector3 {         let s = -long * (Math.PI / 180);         let t = (lat + 90) * (Math.PI / 180);         let x = r * Math.cos(s) * Math.sin(t);         let z = r * Math.sin(s) * Math.sin(t);         let y = r * Math.cos(t);         return new THREE.Vector3(xyz);     }

No comments:

Post a Comment