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.

mgri
16.4k6 gold badges48 silver badges80 bronze badges
asked Jan 14, 2014 at 10:33
3
  • It may be a typo, but you have an extra "r" in your line of code. open(r" that r shouldn't be there. Commented Jan 14, 2014 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. Commented Jan 14, 2014 at 11:12
  • @Martin you are right. I run this script on windows7 Commented Jan 15, 2014 at 1:22

3 Answers 3

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

answered Jan 14, 2014 at 17:16
7
  • I'm try used pyModis library too, but it seem very hard. so I find this script and hope understand it. Commented Jan 15, 2014 at 1:48
  • Did you check the examples? pymodis.fem-environment.eu/scripts/modis_download.html#examples Commented Jan 15, 2014 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? Commented Jan 17, 2014 at 2:03
  • Here an example: mkdir modis_lst_terra ; modis_download.py -t h18v03,h18v04 -p MOD11A1.005 -D10 -r modis_lst_terra Commented Jan 19, 2014 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 Commented Jan 20, 2014 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)?

answered Jan 14, 2014 at 16:56
4
  • 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. Commented Jan 15, 2014 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. Commented Jan 15, 2014 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. Commented Jan 15, 2014 at 5:58
  • Thanks for your recomment. It's very useful for me. I'll do like that :) Commented Jan 15, 2014 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

answered Nov 27, 2017 at 12:50

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.