官网:pyModis Library — pyModis 2.1.0 documentation
pyModis 的 module 包括:
downmodis
Classes
downModis
从 NASA的 FTP/HTTP repositories 下载 MODIS 数据。
class pymodis.downmodis.
downModis
(destinationFolder, password=None, user=None, url='https://e4ftl01.cr.usgs.gov', tiles=None, path='MOLT', product='MOD11A1.006', today=None, enddate=None, delta=10, jpg=False, debug=False, timeout=30, checkgdal=True)
创建对象所使用的参数:
-
destinationFolder (str) – 用于存放输出数据的文件夹
-
password (str) – NASA authentication system 的密码
-
user (str) – NASA authentication system 的用户名
-
url (strstr) – 用于下载 MODIS 数据 的 FTP/HTTP repository 的 url。可以是 FTP 或 HTTP,但必须以 ‘ftp://’ 或 ‘http://’ 或 ‘https://’ 开头。
-
path (str) – 所用 repository 中,需要下载的数据所存放的目录,比如默认 url 中的‘MOLT’。若是 HTTP requests,该目录是 url 中参数 ‘url’ 和 ‘product’ 之间的那个参数。
-
product (str) – 待下载产品的 code,例如 ‘MOD09A1.061’。
-
tiles (str) – a set of tiles to be downloaded, None == all tiles. This can be passed as a string of tileIDs separated by commas, or as a list of individual tileIDs
-
today (str) – the day to start downloading; in order to pass a date different from today use the format YYYY-MM-DD
-
enddate (str) – the day to end downloading; in order to pass a date use the format YYYY-MM-DD. This day must be before the ‘today’ parameter. Downloading happens in reverse order (currently)
-
delta (int) – timelag i.e. the number of days starting from today backwards. Will be overwritten if ‘enddate’ is specifed during instantiation
-
jpeg (bool) – set to True if you want to download the JPG overview file in addition to the HDF
-
debug (bool) – set to True if you want to obtain debug information
-
timeout (int) – Timeout value for HTTP server (seconds)
-
checkgdal (bool) – variable to set the GDAL check
方法:
checkDataExist
(listNewFile, move=False)
checkFile
(filHdf)
closeFTP
()
closeFilelist
()
connect
(ncon=20)
dayDownload
(day, listFilesDown)
debugDays
()
debugLog
()
debugMaps
()
downloadFile
(filDown, filHdf, day)
downloadsAllDay
(clean=False, allDays=False)
getAllDays
()
getFilesList
(day=None)
getListDays
()
removeEmptyFiles
()
setDirectoryIn
(day)
setDirectoryOver
()
modisHtmlParser
Functions
urljoin()
getNewerVersion()
srt2date()
parsemodis
该 module 主要用于解析 MODIS 元数据文件,也可以用于镶嵌操作中源数据文件的解析。
Class parseModis
用于解析 MODIS 元数据文件的一个类,也可以创建参数配置文件,以便使用 MRT 软件或convertmodis module 对 MODIS 数据进行重采样。
Class parseModisMulti
用于获取多个 MODIS tile 中的变量信息的一个类,也可以创建 xml 文件。
convertmodis
该 module 使用 Modis 重投影工具,将 MODIS HDF 文件转换为 GeoTiff 文件,或为多个 tile 创建一个 HDF 镶嵌文件。
convertmodis_gdal
使用 GDAL Pyhton bindings 对 MODIS HDF 进行转换。该 module 可以创建 GeoTiff 文件(或其他 GDAL 支持的文件格式),或 为多个 tile 创建 HDF 镶嵌文件。
Python bingdings:可以实现python与其他语言结合的各种模块。
Classes
convertModisGDAL
使用 GDAL 将 modis 数据 从 hdf 格式转换为 GDAL 支持的格式(比如GeoTiff)。
class pymodis.convertmodis_gdal.
convertModisGDAL
(hdfname, prefix, subset, res, outformat='GTiff', epsg=None, wkt=None, resampl='NEAREST_NEIGHBOR', vrt=False)
创建对象所使用的参数:
-
hdfname (str) – 输入文件名
-
prefix (str) – 输出数据的前缀(prefix)
-
subset(str) – 子数据集
-
res (int) – 输出分辨率
-
outformat (str) – 输出数据的格式(受支持的 GDAL 格式)
-
epsg (int) – 输出文件的投影的 EPSG 代码
-
wkt (str) – 输出文件的投影的 WKT 字符串
-
resampl (str) – 所需使用的重采样方法
-
vrt (bool) – 如果改参数为 True,读取与 createMosaicGDAL module 一起创建的 GDAL VRT 文件。
方法:
run
(quiet=False)
对所选图层的所有子数据集进行重投影
run_vrt_separated
()
对 createMosaicGDAL module 的 write_vrt 函数(separated=True) 创建的 VRT 进行重投影。
createMosaicGDAL
使用 GDAL 将镶嵌的 MODIS 数据从 hdf 格式 转换为 GDAL 格式。
class pymodis.convertmodis_gdal.
createMosaicGDAL
(hdfnames, subset, outformat='HDF4Image')
对象创建的参数:
-
hdfnames (list) – 包含待拼接 tile 的文件名的一个列表
-
subset (str) – 需要考虑的图层子集
-
outformat (str) – 输出数据的格式,支持的格式包括 HDF4Image、GTiff、HFA 等。输出为 VRT 时该参数不使用。
方法:
run
(output, quiet=False):创建镶嵌数据。
参数:output (str) - 输出数据的文件名称
write_mosaic_xml
(prefix):为所拼接的 MODIS 数据书写 XML 元数据。
参数:prefix (str) – 包含元数据的 XML 文件的前缀
write_vrt
(output, separate=True, quiet=False):书写 VRT 文件
参数:output (str) – 输出数据的前缀
separate (bool) – True:为每个波段都写一个 VRT 文件;False:只写一个文件。
file_info
从 gdal_merge.py 复制过来的一个类,用于保存有关某个特定 GDAL 文件的信息。
Functions
getResampling()
pymodis.convertmodis_gdal.
getResampling
(res):该函数会返回一个 GDAL 重采样方法。
参数: res (str) – 重采样方法的字符串
raster_copy()
pymodis.convertmodis_gdal.
raster_copy
(s_fh, s_xoff, s_yoff, s_xsize, s_ysize, s_band_n, t_fh, t_xoff, t_yoff, t_xsize, t_ysize, t_band_n, nodata=None)
从 gdal_merge.py 复制的一个函数,用于将某个栅格的一个波段复制到输出文件。
raster_copy_with_nodata()
pymodis.convertmodis_gdal.
raster_copy_with_nodata
(s_fh, s_xoff, s_yoff, s_xsize, s_ysize, s_band_n, t_fh, t_xoff, t_yoff, t_xsize, t_ysize, t_band_n, nodata)
从 gdal_merge.py 复制的一个函数,用于将栅格的某波段复制到带有 nodata 值的输出文件。