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.
3 Answers 3
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:
-
I'm try used pyModis library too, but it seem very hard. so I find this script and hope understand it.LL2– LL22014年01月15日 01:48:00 +00:00Commented Jan 15, 2014 at 1:48
-
Did you check the examples? pymodis.fem-environment.eu/scripts/modis_download.html#examplesmarkusN– markusN2014年01月15日 19:22:18 +00:00Commented 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?LL2– LL22014年01月17日 02:03:03 +00:00Commented 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_terramarkusN– markusN2014年01月19日 18:57:08 +00:00Commented 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
LL2– LL22014年01月20日 04:09:40 +00:00Commented Jan 20, 2014 at 4:09
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– LL22014年01月15日 02:30:46 +00:00Commented 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.toms– toms2014年01月15日 05:57:29 +00:00Commented 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.toms– toms2014年01月15日 05:58:52 +00:00Commented Jan 15, 2014 at 5:58
-
Thanks for your recomment. It's very useful for me. I'll do like that :)LL2– LL22014年01月15日 09:35:22 +00:00Commented Jan 15, 2014 at 9:35
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
open(r"
that r shouldn't be there.