Monday, April 29, 2019

Create a Facebook 3D Photo of a digital elevation model using QGIS

Facebook has a 3D photo feature which brings perspective and movement to the Facebook news feed and timeline images. A live example can be seen embedded here:


Normally these images are created using RGB-D cameras, where D stands for depth. However it is also possible to workaround it without a RGB-D camera by uploading to Facebook two images - an RGB image and its corresponding grayscale depth image, and making sure the depth image has the same name as the RGB image with a '_depth' suffix. The depth image is grayscale only with values ranging from dark to light -  the dark pixels representing the furthest pixels and the light pixels representing the nearest pixels.

Using the ideas above, the following steps illustrate how to create a Facebook 3D Photo image from a SRTM digital elevation model (DEM) using QGIS.

  1. Startup QGIS. Create a new project. If the canvas background is not already black, select Project | Project Properties.

    The Project Properties dialog box appears.
  2. In the Background color field, change the color to black. Click OK.

    The canvas background becomes black.
  3. Drag and drop a DEM file onto the canvas e.g. srtm_54_07.tif.

     
  4.  Optional. To serve the purpose of having a background, an OpenStreetMap (OSM) layer is displayed behind the DEM layer.

  5. Optional. To display only DEM heights above an elevation of interest, e.g. 200 meters, right click on the DEM layer and choose Properties. Then add in a new transparent entry to the transparent pixel list from 0 to 200 meters, as shown below. Then click OK.

    The Layer Properties dialog box appears.



    The DEM display is updated.

  6. Make a duplicate of the DEM layer by right clicking on the DEM layer and choosing Duplicate. Rename the copy as 'depth' as it will serve to generate a depth image later on.

  7. Right click on the top most DEM layer and choose Properties. In the Layer properties dialog box, click Style.

  8. Change the Render Type to Hillshade. Click OK.

    The DEM layer is now rendered as a hill shade.
  9. Make a duplicate copy of the hill shaded DEM layer by right clicking the layer and choosing Duplicate. Rename the copy as 'hillshade' as shown below.

  10. Right click on the top most DEM layer and choose Properties. Select the Style tab.

  11. In the Rendering type field, choose Singleband pseudocolor. Choose a suitable color gradient e.g. Spectral and toggle Invert if necessary. Choose a suitable Blending mode e.g. Screen.

  12. Click OK.

    The DEM layer is rendered with a colored gradient.
  13. With the gradient colored, hill shaded and OSM layers displayed on and the depth layer displayed off, export out the canvas by selecting Project | Save as image and specifying an output file name e.g. srtm.png.

    The srtm image is generated.
  14. Now turn off the gradient, hill shaded and OSM layers. Turn on the depth layer as shown below.




    Select Project | Save as image to export out the depth image with a '_depth' suffix e.g. srtm_depth.png.

    The srtm_depth image is generated.
  15. Now open up Facebook in a browser and click the Post Photo/Video button.

    The File Upload dialog box appears.
  16. Browse and select the generated srtm.png and srtm_depth.png files. Click Open.

    Facebook generates the 3D Photo.


    A live example is available here at https://www.facebook.com/permalink.php?story_fbid=1251984134967474&id=101193703379862

No comments:

Post a Comment