0

I have a folder with 1000 tifs. I'd like to read 4 tifs, do some calculation and read the next 4 tifs. The problem is, that for example tif number 500 is missing. Now my current program stops right bevor tif number 500.

So my idea is that I check if the path exists with file_test and /directory and skip all missing values in the foor loop.

Directory: Set this keyword to return 1 (true) if File exists and is a directory. true =1, false = 0

for j = 0, 1102 do begin

PathEx = File_test(e:\Meteosat\Tiff\2016\06\17\MSG_201606170100_B4_L.tif', directory)

if PathEx = 1 then
B = READ_TIFF(e:\Meteosat\Tiff\2016\06\17\MSG_201606170100_B4_L.tif, GEOTIFF=tags)

if PathEx = 0 then
print, 'missing' and continue

end

I want to skip all missing paths. I don't know how to do this. I Also read something about .CONTINUE

But I have no clue how this works too. thank you! pampi

asynchronos
  • 583
  • 2
  • 14
pampi
  • 37
  • 6

1 Answers1

0

I am not sure you are using the correct syntax. Your code should be something like the following:

FOR j=0L, 1102L DO BEGIN
  PathEx = FILE_TEST('e:\Meteosat\Tiff\2016\06\17\MSG_201606170100_B4_L.tif', /DIRECTORY)
  IF (PathEx[0] EQ 0) THEN CONTINUE    ;;  This will jump to the next index
  b = READ_TIFF('e:\Meteosat\Tiff\2016\06\17\MSG_201606170100_B4_L.tif',GEOTIFF=tags)
ENDFOR

You should probably have a list of file names and then index those. Suppose you call them something like filenames and this is a [N]-element string array. Then you would do something like the following within the above loop:

file = filenames[j]
PathEx = FILE_TEST(file[0],/DIRECTORY)
IF (PathEx[0] EQ 0) THEN CONTINUE    ;;  This will jump to the next index
b = READ_TIFF(file[0],GEOTIFF=tags)

I should also mention that the variable b should either be an array or you should have an array defined outside the loop that you can store data into, otherwise all your operations within the FOR loop will be lost.

honeste_vivere
  • 308
  • 5
  • 11
  • I will try it! I did it with if (PathEx eq 0) then continue if (PathEx eq 0) then begin But this doesn't worked very well! Thanks! – pampi Jun 23 '18 at 13:47