I am trying to process several MODIS images. I selected a sub dataset and saved them as geotiff files. In the next step I want to extract a regional subset and also change the projection from MODIS sinusoidal to WGS 84. However, after each processed file a cmd window pops up with the error code (usually 0) when I use QGIS to run the script and after a while my entire computer freezes.
Originally I used the os.system() command, which forced me to close the cmd window in order to process the next file from QGIS, in the OSGeo Shell it just stopped the script.
What can I do?
This is my code. Input/Output directories and extensions (both .tif) are defined at the beginning. The .prj file contains details about the source spatial reference set. Entire code + input and some output files here: https://www.dropbox.com/sh/xj2raarioz27z2q/AAAOveRhl_cprQ44GxR3NQaIa?dl=0
#coordinates spatial subset xmin = 50.0 ymin = 8.6 xmax = 51.0 ymax = 9.6 #Loop for all HDF Files in directory filelist = os.listdir(inputdirectory) for files in filelist: if files.endswith(inputwildcard): print 'processing ', files # Create spatial subset #proj = '+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs' inputname = inputdirectory + files subsetfile = outputdirectory + files[:-4] + regionextension + outputextension subset = 'gdalwarp -to SRC_METHOD=NO_GEOTRANSFORM -overwrite -of GTiff -s_srs D:\\MODIS\\6842.prj -t_srs EPSG:4326 -te ' + str(xmin) + ' ' + str(ymin) + ' ' + str(xmax) + ' ' + str(ymax) + ' ' + inputname + ' ' + subsetfile # print subset # sys.exit(0) try: subprocess.Popen(subset, shell=False) except: print 'Some error' sys.exit(0)