[GIS] Cannot access MODIS Download from FTP using Python

ftpmodispymodispython

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.

Best Answer

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.