I want to make a multispectral image from cero to do some tests on it. Something really simple like 5 completely uniform bands with salt and pepper noise on them or a square of different values at the center. Clearly this would just be a stack of matrices, a multidimensional array, which is pretty straight forward to generate. I want to achieve this using python and gdal but gdal is being pretty hermetic, I don't get the hang of it at all. I ideally would want to create a geotiff file. Could anyone help me on this? some pointers or some gdal tutorial which is very gentle? Thank you all.
Tell me more
×
Geographic Information Systems Stack Exchange is a question and answer site for
cartographers, geographers and GIS professionals. It's 100% free, no registration required.
|
You want the gdal.band.WriteArray method. There's an example in the GDAL API tutorial (reproduced below):
For generating the random data,look at the numpy.random module. Here's a more complete working example:
|
|||||
|
|
I know it's not what you asked for, but if all you want is multispectral or hyperspectral sample data - this test data for the Opticks project might work. Alternately, you can get LANDSAT data directly from Earth Explorer. This site has example code to convert a 2D numpy array to a single-band geoTIFF, and a multi-band geoTIFF to a 3D numpy array. EDIT: Further research finds a page of example code with the 'missing example', 3D numpy array -> multi-band geoTIFF. |
|||||
|

