从时空资产目录(stac)开始构建进气目录的进气适配器
intake-stac的Python项目详细描述
进气Stac
时空资源目录(stac)规范提供了描述一系列地理空间信息的通用语言,因此可以更容易地对其进行索引和发现。“时空资产”是指任何代表在特定空间和时间捕获的地球信息的文件。
这些目录的两个示例是:
radient earth跟踪更完整的stac实现列表here。
这个项目为用户提供了一种自以为是的方法,可以将这些目录中的数据集加载到科学python生态系统中。 目前,它使用了IntakeXarray插件并支持数据类型,包括geotiff、netcdf、grib和opendap。未来的格式可能包括简单的shapefile数据等。
要求
intake >= 0.5.1
intake-xarray >= 0.3.0
sat-stac >= 0.1.3
安装
intake-stac
最终将在pypi上发布。现在,你可以指向扎雷
您可以在终端中运行以下命令来安装它:
pip install git+https://github.com/pangeo-data/intake-stac
您可以通过打开examples/
目录中的示例笔记本来测试功能:
用法
可以使用
fromintake_stacimportStacCatalog,StacCollection,StacItem
加载目录
您可以通过提供有效的stac目录条目的url从stac目录加载数据:
catalog=StacCatalog('https://storage.googleapis.com/pdd-stac/disasters/catalog.json','planet-disaster-data')list(catalog)
您还可以指向stac集合或项。每个构造函数返回一个与用于初始化的stac对象相对应的顶级进气目录。
stac_cat=StacCatalog('https://landsat-stac.s3.amazonaws.com/catalog.json','landsat-stac')collection_cat=StacCollection('https://landsat-stac.s3.amazonaws.com/landsat-8-l1/catalog.json','landsat-8')items_cat=StacItem('https://landsat-stac.s3.amazonaws.com/landsat-8-l1/111/111/2018-11-30/LC81111112018334LGN00.json','LC81111112018334LGN00')
进气stac使用sat-stac来解析stac对象。您还可以将satstac
对象(例如satstac.Collection
)直接传递给进气stac构造函数:
importsatstaccol=satstac.Collection.open('https://landsat-stac.s3.amazonaws.com/landsat-8-l1/catalog.json')collection_cat=StacCollection(col,'landsat-8')
使用目录
一旦有了目录,就可以通过遍历目录的内容来显示其条目:
forentry_id,entryincatalog.items():display(entry)
如果目录中的条目太多,无法同时轻松打印所有条目, 您可以通过搜索术语(例如“缩略图”)缩小范围:
forentry_id,entryincatalog.search('thumbnail').items():display(entry)
加载数据集
一旦确定了数据集,就可以使用to_dask()
:
xarray.DataArray
中。
da=entry.to_dask()
路线图
这个项目刚刚起步。我们从this设计文档开始,一直在那里工作。