I tried to access the FTP site of MODIS data using Python ftplib module but always fail to connect. I am connecting using: ftp = ftplib.FTP("e4ftl01.cr.usgs.gov")
here is the error: A connection attempt failed because the connected party did not properly respond after a period of time, or establishment connection failed because connected host has failed to respond.
However, if I access the ftp site thru my web browser, I was able to connect and download files.
2 Answers 2
That is because you are accessing the HTTP archive at http://e4ftl01.cr.usgs.gov/. ftplib
is expected to fail when you try to connect to HTTP instead of FTP.
(削除) The FTP archive is located at ftp://ladsweb.nascom.nasa.gov/allData/. (削除ここまで)
However, both archives do not contain the exact same data. Depending on the MODIS product you are looking for you might find it on the FTP or you might not. The obvious Python choice for accessing the HTTP archive would be urllib
or requests
, or you could just use one of the existing Python MODIS modules like pymodis
.
edit:
As mentioned by Devdatta in the comments, disregard the FTP information post 2018 as this source has been retired.
-
Hi @Kersten, why I cannot access the ftp server ladsweb.nascom.nasa.gov/allData tried ftp = FTP(host). host = 'ladsweb.nascom.nasa.gov/allData'. The error is gaierror: [Errno 11001] getaddrinfo failed. But I can open the ftp site in my browser.user32145– user321452016年10月10日 07:45:10 +00:00Commented Oct 10, 2016 at 7:45
-
@user32145 stackoverflow.com/a/34282077/4169585Kersten– Kersten2016年10月10日 08:08:53 +00:00Commented Oct 10, 2016 at 8:08
-
1For those who are looking at this answer post 2018, do note that the FTP server has been retired, and the recommended way is to get the data from
https://ladsweb.modaps.eosdis.nasa.gov/
Devdatta Tengshe– Devdatta Tengshe2018年08月17日 09:36:32 +00:00Commented Aug 17, 2018 at 9:36
You may want to check http://www.pymodis.org which is a Free and Open Source Python based library to work with MODIS data.
It offers bulk-download for user selected time ranges, mosaicking of MODIS tiles, and the reprojection from Sinusoidal to other projections, convert HDF format to other formats and the extraction of data quality information.
In the last days a series of updates where applied, also to the related GRASS GIS 7 Addon r.modis which is a toolset to import MODIS satellite data into GRASS GIS.