Animate Map with Blender: Difference between revisions
From wikiluntti
Line 15: | Line 15: | ||
== Python: Adjust the scale of the 3d map == | == Python: Adjust the scale of the 3d map == | ||
<syntaxhighlight lang="python3"> | Load the image, concatenate and scale it. Then save. <syntaxhighlight lang="python3"> | ||
import rasterio | import rasterio | ||
import numpy as np | import numpy as np | ||
Line 39: | Line 39: | ||
im = im.convert("L") | im = im.convert("L") | ||
im.save( "heightModel1.png" ) | im.save( "heightModel1.png" ) | ||
</syntaxhighlight> | </syntaxhighlight>Easy, fast. | ||
== Blender == |
Revision as of 19:06, 3 June 2024
Introduction
Download Data
Download data from https://www.maanmittauslaitos.fi/ . The Licence is Maanmittauslaitoksen avoimien aineistojen CC 4.0 -lisenssi. There can be found
- Map
- Air photos
- Height model
GIMP: Make a larger image
Change the Canvas size of each three downloaded image
- Image → Canvas Size. Height to 2x.
Superpose the images: make it larger.
Python: Adjust the scale of the 3d map
Load the image, concatenate and scale it. Then save.
import rasterio
import numpy as np
from PIL import Image
names = ['Q4121F.tif', 'Q4122E.tif']
imgs = []
for n in names:
imgs.append(rasterio.open(n))
image = imgs[0].read(1)
print( np.shape(image) )
for img in imgs[1:]:
tmp = img.read(1)
image = np.concatenate( (tmp, image ), 0)
print( np.shape(image) )
print( image.max() )
print( image.min() )
image = 256*(image-image.min())/(image.max()-image.min())
im = Image.fromarray( image )
im = im.convert("L")
im.save( "heightModel1.png" )
Easy, fast.