Skip to main content
deleted 11 characters in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

I have downloaded numerous hdf files from an ftp site. Half of them were level 1 and the rest were level 2. Lvl1 format is Afile.A1_AC.sample.hdf and the lvl 2 format is: Afile.A1_AC.sample.hdf. 

How will I do a batch process in projecting all the level2 files only? 

How will I filter these files and create a new directory?

Any help will be appreciated.

 

UPDATE:(tried calling .bat from the python script and run the script. And it just created an empty/new directory(out_path). Tried calling the .bat from the cmd line and here's the output:

UPDATE 2:

 

UPDATE 3:

 

I have downloaded numerous hdf files from an ftp site. Half of them were level 1 and the rest were level 2. Lvl1 format is Afile.A1_AC.sample.hdf and the lvl 2 format is: Afile.A1_AC.sample.hdf. How will I do a batch process in projecting all the level2 files only? How will I filter these files and create a new directory?

Any help will be appreciated.

UPDATE:(tried calling .bat from the python script and run the script. And it just created an empty/new directory(out_path). Tried calling the .bat from the cmd line and here's the output:

UPDATE 2:

UPDATE 3:

I have downloaded numerous hdf files from an ftp site. Half of them were level 1 and the rest were level 2. Lvl1 format is Afile.A1_AC.sample.hdf and the lvl 2 format is: Afile.A1_AC.sample.hdf. 

How will I do a batch process in projecting all the level2 files only? 

How will I filter these files and create a new directory?

 

(tried calling .bat from the python script and run the script. And it just created an empty/new directory(out_path). Tried calling the .bat from the cmd line and here's the output:

 
 
revised
Source Link
lovelyvm
  • 517
  • 1
  • 7
  • 16

GDAL/PYTHON: Batch Process Project All Level 2 HDF Files Only(Filter) and save to new directory gdalwarp batch process

I have downloaded numerous hdf files from an ftp site. Let's say I already have 500 hdf files, 250Half of them were level 1 hdf files and the rest were level 2. The level 1Lvl1 format is: A2001031505000 Afile.L1A_LACA1_AC.sample.hdf and the levellvl 2 format is: A2001017054000Afile.L2_LACA1_AC.sample.hdf As what you will observe they differ in this part L1A_LAC, L2_LAC. Now, howHow will I do a batch process in projecting all the level 2 hdflevel2 files only? How will I filter these files and create a new directory for the filtered files?

Any help will be appreciated. Thanks!

C:\User\Desktop\sample>projected\sample>project.bat
C:\User\Desktop\sample>set\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md\sample>md D:\newfolder
A subdirectory or file D:\newfolder already exists.
C:\User\Desktop\sample>cd\sample>cd D:\path\to\file
C:\User\Desktop\sample>FORFILES\sample>FORFILES /m *L2_LAC**A1_AC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 @path D:\[email protected]"
ERROR: Invalid argument/option - '+datum=WGS84 -te 113.205 1.120 157.105 2.005 @path D:\[email protected]'.
Type "FORFILES /?" for usage.
C:\User\Desktop\sample>projected\sample>project.bat
C:\User\Desktop\sample>set\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md\sample>md D:\newfolder
C:\User\Desktop\sample>cd\sample>cd D:\path\to\file
C:\User\Desktop\sample>FORFILES\sample>FORFILES /m *L2_LAC**A1_AC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 @path D:\[email protected]"
ERROR: Files of type "*L2_LAC*"*A1_AC*.hdf" not found.
C:\User\Desktop\sample>projected\sample>projected.bat
C:\User\Desktop\sample>set\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md\sample>md D:\newfolder
C:\User\Desktop\sample>cd\sample>cd /d D:\path\to\file
C:\User\Desktop\sample>FORFILES\sample>FORFILES /m *L2_LAC**A1_AC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 @path D:\newfolder/@fname.tif"
ERROR 1: Translating source or target SRS failed:
'+proj=longlat
C:\User\Desktop\sample>gdalwarp\sample>gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 HDF4_SDS:hdf:"A2001017054000"Afile.L2_LACA1_AC.sample.hdf":01 sample.tif
Creating output file that is 1941P x 1670L.
Processing input file HDF4_SDS:hdf:"A2001017054000"Afile.L2_LACA1_AC.sample.hdf":01.
0...10...20...30...40...50...60...70...80...90...100 - done.

GDAL/PYTHON: Batch Process Project All Level 2 HDF Files Only(Filter) and save to new directory

I have downloaded numerous hdf files from an ftp site. Let's say I already have 500 hdf files, 250 of them were level 1 hdf files and the rest were level 2. The level 1 format is: A2001031505000.L1A_LAC.sample.hdf and the level 2 format is: A2001017054000.L2_LAC.sample.hdf As what you will observe they differ in this part L1A_LAC, L2_LAC. Now, how will I do a batch process in projecting all the level 2 hdf files only? How will I filter these files and create a new directory for the filtered files?

Any help will be appreciated. Thanks!

C:\User\Desktop\sample>projected.bat
C:\User\Desktop\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md D:\newfolder
A subdirectory or file D:\newfolder already exists.
C:\User\Desktop\sample>cd D:\path\to\file
C:\User\Desktop\sample>FORFILES /m *L2_LAC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 @path D:\[email protected]"
ERROR: Invalid argument/option - '+datum=WGS84 -te 113.205 1.120 157.105 2.005 @path D:\[email protected]'.
Type "FORFILES /?" for usage.
C:\User\Desktop\sample>projected.bat
C:\User\Desktop\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md D:\newfolder
C:\User\Desktop\sample>cd D:\path\to\file
C:\User\Desktop\sample>FORFILES /m *L2_LAC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 @path D:\[email protected]"
ERROR: Files of type "*L2_LAC*.hdf" not found.
C:\User\Desktop\sample>projected.bat
C:\User\Desktop\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md D:\newfolder
C:\User\Desktop\sample>cd /d D:\path\to\file
C:\User\Desktop\sample>FORFILES /m *L2_LAC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 @path D:\newfolder/@fname.tif"
ERROR 1: Translating source or target SRS failed:
'+proj=longlat
C:\User\Desktop\sample>gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 HDF4_SDS:hdf:"A2001017054000.L2_LAC.sample.hdf":01 sample.tif
Creating output file that is 1941P x 1670L.
Processing input file HDF4_SDS:hdf:"A2001017054000.L2_LAC.sample.hdf":01.
0...10...20...30...40...50...60...70...80...90...100 - done.

gdalwarp batch process

I have downloaded numerous hdf files from an ftp site. Half of them were level 1 and the rest were level 2. Lvl1 format is Afile.A1_AC.sample.hdf and the lvl 2 format is: Afile.A1_AC.sample.hdf. How will I do a batch process in projecting all the level2 files only? How will I filter these files and create a new directory?

Any help will be appreciated.

C:\sample>project.bat
C:\sample>set in_path=D:\path\to\file
C:\sample>set out_path=D:\newfolder
C:\sample>md D:\newfolder
A subdirectory or file D:\newfolder already exists.
C:\sample>cd D:\path\to\file
C:\sample>FORFILES /m *A1_AC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 @path D:\[email protected]"
ERROR: Invalid argument/option - '+datum=WGS84 -te 113.205 1.120 157.105 2.005 @path D:\[email protected]'.
Type "FORFILES /?" for usage.
C:\sample>project.bat
C:\sample>set in_path=D:\path\to\file
C:\sample>set out_path=D:\newfolder
C:\sample>md D:\newfolder
C:\sample>cd D:\path\to\file
C:\sample>FORFILES /m *A1_AC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 @path D:\[email protected]"
ERROR: Files of type "*A1_AC*.hdf" not found.
C:\sample>projected.bat
C:\sample>set in_path=D:\path\to\file
C:\sample>set out_path=D:\newfolder
C:\sample>md D:\newfolder
C:\sample>cd /d D:\path\to\file
C:\sample>FORFILES /m *A1_AC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 @path D:\newfolder/@fname.tif"
ERROR 1: Translating source or target SRS failed:
'+proj=longlat
C:\sample>gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 HDF4_SDS:hdf:"Afile.A1_AC.sample.hdf":01 sample.tif
Creating output file that is 1941P x 1670L.
Processing input file HDF4_SDS:hdf:"Afile.A1_AC.sample.hdf":01.
0...10...20...30...40...50...60...70...80...90...100 - done.
added an update
Source Link
lovelyvm
  • 517
  • 1
  • 7
  • 16
C:\User\Desktop\sample>projected.bat
C:\User\Desktop\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md D:\newfolder
A subdirectory or file D:\newfolder already exists.
C:\User\Desktop\sample>cd D:\path\to\file
C:\User\Desktop\sample>FORFILES /m *L2_LAC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 109113.975205 31.475120 135157.025105 252.025005 @path D:\[email protected]"
ERROR: Invalid argument/option - '+datum=WGS84 -te 113.205 1.120 157.105 2.005 @path D:\[email protected]'.
Type "FORFILES /?" for usage.
C:\User\Desktop\sample>projected.bat
C:\User\Desktop\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md D:\newfolder
C:\User\Desktop\sample>cd D:\path\to\file
C:\User\Desktop\sample>FORFILES /m *L2_LAC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 109113.975205 31.475120 135157.025105 252.025005 @path D:\[email protected]"
ERROR: Files of type "*L2_LAC*.hdf" not found.

UPDATE 3:

C:\User\Desktop\sample>projected.bat
C:\User\Desktop\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md D:\newfolder
C:\User\Desktop\sample>cd /d D:\path\to\file
C:\User\Desktop\sample>FORFILES /m *L2_LAC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 @path D:\newfolder/@fname.tif"
ERROR 1: Translating source or target SRS failed:
'+proj=longlat

Tried running the gdalwarp in the cmd line and it was successful:

C:\User\Desktop\sample>gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 HDF4_SDS:hdf:"A2001017054000.L2_LAC.sample.hdf":01 sample.tif
Creating output file that is 1941P x 1670L.
Processing input file HDF4_SDS:hdf:"A2001017054000.L2_LAC.sample.hdf":01.
0...10...20...30...40...50...60...70...80...90...100 - done.
C:\User\Desktop\sample>projected.bat
C:\User\Desktop\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md D:\newfolder
A subdirectory or file D:\newfolder already exists.
C:\User\Desktop\sample>cd D:\path\to\file
C:\User\Desktop\sample>FORFILES /m *L2_LAC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 109.975 3.475 135.025 25.025 @path D:\[email protected]"
ERROR: Invalid argument/option - '+datum=WGS84 -te 113.205 1.120 157.105 2.005 @path D:\[email protected]'.
Type "FORFILES /?" for usage.
C:\User\Desktop\sample>projected.bat
C:\User\Desktop\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md D:\newfolder
C:\User\Desktop\sample>cd D:\path\to\file
C:\User\Desktop\sample>FORFILES /m *L2_LAC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 109.975 3.475 135.025 25.025 @path D:\[email protected]"
ERROR: Files of type "*L2_LAC*.hdf" not found.
C:\User\Desktop\sample>projected.bat
C:\User\Desktop\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md D:\newfolder
A subdirectory or file D:\newfolder already exists.
C:\User\Desktop\sample>cd D:\path\to\file
C:\User\Desktop\sample>FORFILES /m *L2_LAC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 @path D:\[email protected]"
ERROR: Invalid argument/option - '+datum=WGS84 -te 113.205 1.120 157.105 2.005 @path D:\[email protected]'.
Type "FORFILES /?" for usage.
C:\User\Desktop\sample>projected.bat
C:\User\Desktop\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md D:\newfolder
C:\User\Desktop\sample>cd D:\path\to\file
C:\User\Desktop\sample>FORFILES /m *L2_LAC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 @path D:\[email protected]"
ERROR: Files of type "*L2_LAC*.hdf" not found.

UPDATE 3:

C:\User\Desktop\sample>projected.bat
C:\User\Desktop\sample>set in_path=D:\path\to\file
C:\User\Desktop\sample>set out_path=D:\newfolder
C:\User\Desktop\sample>md D:\newfolder
C:\User\Desktop\sample>cd /d D:\path\to\file
C:\User\Desktop\sample>FORFILES /m *L2_LAC*.hdf /C "cmd /c gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 @path D:\newfolder/@fname.tif"
ERROR 1: Translating source or target SRS failed:
'+proj=longlat

Tried running the gdalwarp in the cmd line and it was successful:

C:\User\Desktop\sample>gdalwarp -geoloc -t_srs "+proj=longlat +datum=WGS84" -te 113.205 1.120 157.105 2.005 HDF4_SDS:hdf:"A2001017054000.L2_LAC.sample.hdf":01 sample.tif
Creating output file that is 1941P x 1670L.
Processing input file HDF4_SDS:hdf:"A2001017054000.L2_LAC.sample.hdf":01.
0...10...20...30...40...50...60...70...80...90...100 - done.
added an update
Source Link
lovelyvm
  • 517
  • 1
  • 7
  • 16
Loading
added a symbol
Source Link
lovelyvm
  • 517
  • 1
  • 7
  • 16
Loading
added an update
Source Link
lovelyvm
  • 517
  • 1
  • 7
  • 16
Loading
edited the content
Source Link
lovelyvm
  • 517
  • 1
  • 7
  • 16
Loading
improved formatting
Source Link
lovelyvm
  • 517
  • 1
  • 7
  • 16
Loading
made an update
Source Link
lovelyvm
  • 517
  • 1
  • 7
  • 16
Loading
edited the question
Link
lovelyvm
  • 517
  • 1
  • 7
  • 16
Loading
revised the question as well as the content
Source Link
lovelyvm
  • 517
  • 1
  • 7
  • 16
Loading
edited title
Link
lovelyvm
  • 517
  • 1
  • 7
  • 16
Loading
added some questions
Source Link
lovelyvm
  • 517
  • 1
  • 7
  • 16
Loading
Source Link
lovelyvm
  • 517
  • 1
  • 7
  • 16
Loading