Tuesday, March 31, 2020

Adapted to Earth Engine API changes (Mar. 31)

  • Google announced a while back that they are changing the JS and Python API to be supported by it's Cloud API
  • For me, that change broke several things, both in Python and in JS:
    • I was suddenly unable to d/l any geotiffs from EE to make models from, which took time to figure out.
    • Even then, none of my hillshade overlays showed up, again, that took some time to fix.
  • Impact: 
    • There was an outage of a couple of days that prevented any d/l. Several users got in contact with me; if you've been affected - I'm sorry!
    • But, nobody complained about the lack of hillshade overlays :)
    • Google has apparently decided to lower the maximum size that can be downloaded. It should not affect TouchTerrain, b/c I only request appropriately downsampled geotiffs from them anyway and our server also caps how many pixels you can process on it, but I have not tested this well. It's possible that users will run into the Google quota if they request very large models.
    • But, that pretty much kills the "download at source resolution" option I had and so I took it out. It's still available in standalone to make models at the exact same resolution as a local raster (geotiff). 
    • It is still possible to "export" large rasters into something running in the Google Cloud but I have no intentions to run our server in the Google cloud. At least not for the foreseeable future.
  • Silver lining: After going back to digging around the Earth Engine API I noticed a whole bunch of new terrain and terrain related datasets!  My next plan is to add some of these to Touchterrain.

Exporting Terrain models with real world coordinates

Exporting Terrain models with real world coordinates

  • Some people would like to import TouchTerrain model files (STLs or OBJs) into software for CAD or 3D Modelling. 
  • At my University (Iowa State), an architecture student imported terrain into Rhino, manually mach a building he designed to its correct place and CNC'd the entire thing!
  • Another request asked for the ability to import a TouchTerrain STL into Blender in order to make changes to it there. Specifically, to combine it with a GPS track in order to make the track visible when the 3D terrain is printed out (more about this later, provided this turns out to have worked ...): Update: this is now an official touchterrain option (thanks to KohlhardtC!), see the gpx option in the github ReadMe.

  • As a result, I decided to add an option to set the xyz coordinates of the vertices inside the STL/OBJ files as something in a global context. (Typically, the coordinates are in mm and the origin is the center of your buildplate ...)
  • Using unprojected lat/long coordinates is out of the question for many reasons (distortions, height, sphere vs plane, etc.), so the only real option is using UTM coordinates, which TouchTerrain already requests from EarthEngine. This makes the x/y coordinates be large numbers, something in 100,000s or even millions, with z (elevation) always in meters. 
  • These UTM x/y coordinates are distances from the intersection of the equator with Greenwich. Here's a web app that show those numbers for the (nearly) entire globe.
  • In theory, terrain models with these numbers, when imported into a 3D modelling system, should show up in the correct place and should also be correct with regard to other, UTM encoded, objects.
  • Sadly, the only system I remotely know how to use is Blender, for which these standard UTM coordinates did NOT work (at least for me)!

  • However, after looking into BlenderGIS, I realized that I could trick Blender in positioning the STL model in the correct place, if I first imported the geotiff of the terrain (which is always given in the zip folder you download). The trick seems to be to still use meters as units but set the origin (0,0,0) at the center of the geotiff.  For this to work, you need to use the "centered" option (see below).
  • I've documented my Blender adventure here (very detailed, illustrated instruction pdf and a zip with example files used). It only deals with draping gpx lines on the topography (which was added as an official option to standalone in version 3) but it will also show you how to center a touchterrain model for use with BlenderGIS. So I imagine this method should also work for placing other types of geometry (like buildings) onto the model using Blender.

  • Using ArcGIS Pro, I was able to import a OBJ terrain mesh from TouchTerrain (with the "UTM" option, see below) into a local 3D Scene and it does overlap nicely with its geotiff. I used the Import 3D Files (3D Analyst) function.
  • To show the fit, I've set the build in terrain to flat. The "shadow" over which the imported OBJ seems to be floating is the geotiff.
TouchTerrain 3D model of Sheep Mountain, imported as OBJ into ArcGIS Pro, local 3D Scene

  • So what now? Well, if you want to try using a TouchTerrain Model in the context of a 3D Modelling software, all you need to do is to set the manual option:
    • "use_geo_coords":"centered" will set the UTM origin to the center of the full tile
    • "use_geo_coords":"UTM" will use the official UTM x/y coordinates
  • Again, this is highly experimental and only tested in Blender (with "centered" and using BlenderGIS to import the geotiff first!) and ArcGIS Pro. If it works for you in another 3D software, please let me know! (If it fails, also let me know, maybe I can make it work ...)