I'm a little lost. I have a directory with some Landsat-8-scenes. There are files that end on
.hdf and they are always accompanied by a
.hdr file. What I wanted to do is to convert these scenes to a virtual mosaic, than clip the extent of the mosaic with a shapefile, and finally get a
-tif of the clipped mosaic. I do have some questions though:
I imported all the
.hdf-files into a list in python. I didn't use the
.hdr-file though. My
hdf_path-list looks like this:
'...HLS.L30.T34JDN.2018007.v1.4.hdf', '...HLS.L30.T34JDN.2018023.v1.4.hdf', '...HLS.L30.T34JDN.2018030.v1.4.hdf', '...HLS.L30.T34JDN.2018039.v1.4.hdf', '...HLS.L30.T34JDN.2018014.v1.4.hdf'
My first concrete question actually is, if it's a better idea to convert each single
.hdf to a
.vrt-file and them merge them together. Or is a
.vrt-file already kind of a mosaic?
I then looped over all the files and opened them with gdal to create
gdal-datasets. Like this:
gdal_datasets =  for i in hdf_path: dataset = gdal.Open(i) gdal_datasets.append(dataset)
The output looks like this:
print(gdal_datasets) [<osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at 0x7ffa01feef00> >, <osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *' at 0x7ffa0204ff90> >, ...
I finally used
gdal.BuildVRT to make the final
vrt = gdal.BuildVRT("my.vrt, gdal_datasets)
At this step it's executing forever and I don't really know if this is the right way to go. At the moment I import
osgeo. But maybe it'd be easier using
rasterio. But I just don't know exactly what to do. I'm sorry, I know there are some basic questions...
Not even mentioning the clipping to the extent of the shapefile about what I did't yet think at all...
Does anyone have an idea or a pointer?