3

I need download Modis imagery automatically from the website: https://earthdata.nasa.gov/.

I found this link: http://gis-techniques.blogspot.com/2010/06/getting-modis-image-automatically-from.html

but I can't run it. In that code there's the line:

logFileread=open(r"D:\MODIS\MOD09\lpdaac.txt",'r')

I don't know the structure of this file.I don't know how to create it. If anyone knows the answer, please tell me.

  • It may be a typo, but you have an extra "r" in your line of code. open(r" that r shouldn't be there. – GIS-Jonathan Jan 14 '14 at 11:08
  • 1
    In Python, if you write your path with \\ or / the 'r' in front is not required. As it now stands (with single backslash), it is necessary for correct path interpretation. – Martin Jan 14 '14 at 11:12
  • @Martin you are right. I run this script on windows7 – LL2 Jan 15 '14 at 1:22
4

You may also take a look at "pyModis", a Free and Open Source Python library to work with MODIS data. It can bulk-download, mosaik and reproject:

http://www.pymodis.org

  • I'm try used pyModis library too, but it seem very hard. so I find this script and hope understand it. – LL2 Jan 15 '14 at 1:48
  • Did you check the examples? pymodis.fem-environment.eu/scripts/modis_download.html#examples – markusN Jan 15 '14 at 19:22
  • yes, I did. but It don't work. Did you do it? Can you show me image when you check the examples? – LL2 Jan 17 '14 at 2:03
  • Here an example: mkdir modis_lst_terra ; modis_download.py -t h18v03,h18v04 -p MOD11A1.005 -D10 -r modis_lst_terra – markusN Jan 19 '14 at 18:57
  • It look like the same example on the link that you gave me. I understand what this command do because there is an list Options. But when I run just a command like that on IDLE, there's always have error: Syntaxerror: invalid syntax of each agument: >>> modis_download.py -t h18v03,h18v04 -p MOD11A1.005 -D10 -r modis_lst_terra SyntaxError: invalid syntax – LL2 Jan 20 '14 at 4:09
2

The comment above the line in question says:

# Read the log file to retrive the information of latest downloaded data

It looks like this file keeps track of which directories (dates) have already been downloaded. Further down the same file is referenced again (here to write, not read):

# Write download information in the log file
logFwrite=open(r"H:\MODIS_LST_NDVI\MOD11A2\lpdaac.txt",'w')

Running the script the first time, you haven't downloaded anything yet, so I wouldn't expect anything in that file. What happens if you just create an empty file, and change the script to point to that (both places)?

  • thanks for your comment. I try to write but it don't write anything, still empty. In this script have this: #parsing the directory name only[2002.12.03] mainDirname= mainDir[37:47] dd=mainDirname[8:10] mm=mainDirname[5:7] yyyy=mainDirname[0:4] how to parsing like that? what mean of day 2002.12.03? I'm sorry because my lazy question, but I'm a newer in python, I just learn it a few day and I need this script. – LL2 Jan 15 '14 at 2:30
  • mainDirname is a string, mainDirname[8:10] returns characters 8 to 10 (starting from 0, non-inclusive). This must be the "day" of the data collection (dd), or the last two characters of the string "2002.12.03". This seems to be how the ftp directories are structured, you need this to navigate to the right folder and get the right imagery. – toms Jan 15 '14 at 5:57
  • the script you found will be a little hard to work with because it is so customized (notice they only retrieve data for the three tiles covering the NGP/Upper Midwest, for example). Also the formatting is not preserved in the example (indentation). I suggest using a command line python interpreter and pasting in line by line to help understand what each line is doing, exploring the ftp directories, and the objects being created. Then use only the parts of the script you need. – toms Jan 15 '14 at 5:58
  • Thanks for your recomment. It's very useful for me. I'll do like that :) – LL2 Jan 15 '14 at 9:35
1

You can also use this script. It's quite easy to use to get MOD09/MYD09: The following example downloads daily surface reflectance from the TERRA platform for tile h17v04 for 2004, between DoY 153 and 243, and putting it in folder /tmp/

bash $ ./get_modis.py --username YOUR_USERNAME --password YOUR_PASSWORD \ -v -p MOD09GA.006 -s MOLT -y 2004 -t h17v04 -o /tmp/ -b 153 -e 243

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.