STAC in Blender
Wed 19 January 2022Have you ever wondered how to use Spatiotemporal Asset Catalog (STAC) assets in Blender? Me too, and here's how I used Python in Blender to make an animation like this:
You can find my Python code here. If you have a plane object in your scene, "Plane", the script should do quite a few things:
- make a query to Element84's Earth Search API, but you could use whatever STAC API your heart desires. The query will retrieve 15 Sentinel-2 cloud-optimized geotiffs (COG) within a bounding box
- for each image, read the pixels from a window defined by the bounding box, and save them as a local jpeg
- it also creates a very special material, containing 15 (maybe 14...) mix shaders, each one pointing to all the previous mix shaders and an image. Each mix shader is also keyframed to transition between fully showing the previous images, or itself. The result is a material that appears to smoothly change from one image to the next in sync with its datetime value.
- the material is applied to the "Plane" object - I manually added a plane to the scene, but you could accomplish this through code, as well.
- finally, I set up a handler to animate the text.
That's it! It's a lot to digest, but have a look at the code and see if you can make sense of it. Let me know on Twitter how it goes!
PS: you can also swap out the "Plane" for other objects, like a cube below: