<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><table><tbody><tr><td class=""><br></td>
<td class=""><p>I have numerous hdf files dowloaded from ftp site and saved it to my
local directory.The hdf files has level 1 and level 2(e.g.
A2001037040000.L1A_LAC.hdffiles.hdf,
A2001037040000.L2_LAC.hdffiles.hdf). How will I project the level 2
files ONLY in batch process and automatically create a directory for the
projected files?And what should I do so that I would be able to
project/process the newest files I have downloaded EVERYDAY, this means
that the projection should update everyday and if there are files added
that should only be projected?</p>
<p>IMPORTANT: The hdf files for today aren't available yet so the newest
files to be projected/processed are those files uploaded yesterday
because all the files uploaded in the ftp site are delayed one day.</p>
<p>Thanks in advance for your help! </p>
<p>Code:</p><pre style class=""><code><span class="">def</span><span class=""> projectData</span><span class="">(</span><span class="">self</span><span class="">,</span><span class=""> event</span><span class="">):</span><span class="">
</span><span class="">def</span><span class=""> findSDS </span><span class="">(</span><span class="">path</span><span class="">,</span><span class=""> filter</span><span class="">):</span><span class="">
</span><span class="">for</span><span class=""> root</span><span class="">,</span><span class=""> dirs</span><span class="">,</span><span class=""> files </span><span class="">in</span><span class=""> os</span><span class="">.</span><span class="">walk</span><span class="">(</span><span class="">path</span><span class="">):</span><span class="">
</span><span class="">for</span><span class=""> file </span><span class="">in</span><span class=""> fnmatch</span><span class="">.</span><span class="">filter</span><span class="">(</span><span class="">files</span><span class="">,</span><span class=""> filter</span><span class="">):</span><span class="">
</span><span class="">yield</span><span class=""> file
</span><span class="">for</span><span class=""> sds </span><span class="">in</span><span class=""> findSDS</span><span class="">(</span><span class="">'D:/folder/hdf/files'</span><span class="">,</span><span class=""> </span><span class="">'*.hdf'</span><span class="">):</span><span class="">
inSDS </span><span class="">=</span><span class=""> </span><span class="">'HDF4_SDS:'</span><span class=""> </span><span class="">+</span><span class=""> </span><span class="">'D:/folder/hdf/files'</span><span class=""> </span><span class="">+</span><span class=""> </span><span class="">'/'</span><span class=""> </span><span class="">+</span><span class=""> sds </span><span class="">+</span><span class=""> </span><span class="">':01'</span><span class="">
path </span><span class="">=</span><span class=""> </span><span class="">'D:/save/newprojected'</span><span class="">
outTIFF </span><span class="">=</span><span class=""> path </span><span class="">+</span><span class=""> sds </span><span class="">+</span><span class=""> </span><span class="">'.tif'</span><span class="">
cmd </span><span class="">=</span><span class=""> </span><span class="">'gdalwarp -geoloc -t_srs "proj=longlat +datum=WGS84" -te 111.157 1.075 129.225 15.205 %s %s'</span><span class=""> </span><span class="">%</span><span class=""> </span><span class="">(</span><span class="">inSDS</span><span class="">,</span><span class=""> outTIFF</span><span class="">)</span><span class="">
os</span><span class="">.</span><span class="">system</span><span class="">(</span><span class="">cmd</span><span class="">)</span><span class="">
os</span><span class="">.</span><span class="">mkdir</span><span class="">(</span><span class="">path</span><span class="">)</span></code></pre></td></tr></tbody></table></div></div>