可用于单元测试的样本图像芯片和向量

dgsamples的Python项目详细描述


简介

DGSamples是一个样本图像芯片和矢量文件包,可以 用于单元测试,而不必在每个单元中维护测试数据 需要测试的代码基。

快速启动

importdgsamples# The code automatically discovers the data available and puts it on a# bunch object called samples which can be accessed directly:dgsamples.allsamples# This will pretty print the contents of the bunch# Finer grained access to the samples can be achieved by:dgsamples.wv2_longmont_1k.files# The above will produce a path similar to:# /path/to/dgsampledata/wv2_longmont_1k/...M2AS-053792616010_01_P001.TIL'# /path/to/dgsampledata/wv2_longmont_1k/...P2AS-053792616010_01_P001.TIL'# If the samples have a filename_map.PVL file provided, there will also be# sensor specific shotcuts available in an OrderedBunch object:dgsamples.wv2_longmont_1k.ms# The above will produce a path to the sensor .TIL file:# /path/to/dgsampledata/wv2_longmont_1k/...M2AS-053792616010_01_P001.TIL'# The .TIL file can be ingested with geoio as:importgeoioimg=geoio.DGImage(dgsamples.wv2_longmont_1k.ms)# However, these links are to real files on disk and can be read with# an appropriate application.fromosgeoimportgdalobj=gdal.Open(dgsamples.bayou_chip.extract_test)# orimportfionas=fiona.open(dgsamples.bayou_vectors.poly)# The sample data can also be retrieved through the "file" bunch key:dgsamples.bayou_vectors.files# The above will produce something similar to:# ['/path/to/dgsampledata/.../extract_test_point.shp',#  '/path/to/dgsampledata/.../extract_test_poly.shp']

添加数据集

新数据可以直接添加到“DGSamples”包中,并将 在导入时动态发现。动态发现代码使用 在确定目录中存在什么类型的数据时遵循以下逻辑:

if".TIL found":"return all .TILs and stop"elif".TIF found":"return all .TIFs and stop"elif".shp or .json found":"return all .shp and .json then stop"

如果将名为“filename_map.pvl”的文件添加到示例目录中,则键/ 文件中的值对将用于将文件映射到 返回OrderedBunch对象。

如果示例目录中存在名为“notes.txt”的文件,则 将添加到OrderedBunch对象的“notes”项中。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java Webstart“javaws open”标志不适用于多个参数   java ArrayList声明和处理   获取数组中值的百分比(Java)   java将ArrayList转换为字符串以存储在共享首选项中   Java8Lambdas与泛型的结合使用   Scala数组到Java   如何使用java知道webcontainer的路径?   java使用“收集”和“合并”的组背后的算法是什么   java OSGi:在两个不同的包中具有相同的包路径   java混淆了swt画布。重画   java正则表达式,用于5位数逗号分隔的值,例如047000480004900   使用HttpClient显示非ASCI字符的java   水塔计算程序Java中球体体积的计算   java根据给定值调整框架中所有组件的大小   java Builder类中的其他方法(lombok注释)