地理图像读写工具。

geoio的Python项目详细描述


https://badge.fury.io/py/geoio.svg

简介

Geoio提供方便与地理空间交互的设施 数据。支持的交互包括数据检索、光谱 处理、元数据处理、shapefile交集/提取和检索 统计信息。特别注意访问 DigitalGlobe数据和元数据,但此模块中的相同功能可以是 用于访问非DigitalGlobe数据或构建自定义处理和 其他卫星平台的元数据处理。

安装

pipinstallgeoio

如果可能的话,依赖项将在安装时处理。格达尔不干净 可通过pip安装,因此应单独处理(conda、yum、apt-get等)。 运行依赖项是:gdal, xmltodict, pytz, tzwhere, ephem, numpy, tinytools。 另外,dgsamples是测试所必需的,matplotlib必须是 可供绘图功能使用。

mac用户注意:如果ephem的pip失败,请尝试在conda中直接安装它 conda虚拟环境,即:

conda install ephem

进口

importgeoio

将主类GeoImageDGImage导入模块根目录。

GeoImage类是一个相对较薄的gdal包装器,它提供了 用于访问任意地理空间图像格式的pythonic接口 (通常由gdal和digitalglobe.til格式支持)。 支持的操作包括读、写、削、重投影和meta 数据访问。类方法使用合理的默认值填充,并且 对象接口,减少图像操作的痛苦,以便您可以继续 带着重要的东西!

DGImage类继承了GeoImage的所有功能,并添加 DigitalGlobe元数据处理、频谱处理和频带别名数据 检索。因此,它要求输入图像是有效的数字地球仪 形象。这当前是一个带有相关元数据文件的.til文件 (.imd和/或.xml)存在于图像目录或带有 同名的.imd或.xml文件。元数据被读入 OrderedBunch对象(继承自tinytools包)附加到 实例化的对象。

快速启动

geoio类最好在ipython中交互使用,其中 可以触发相关的漂亮打印方法。元数据信息将是 不考虑解释器,但可读性目前是 在伊普顿好多了。

下面使用DGSamples repo。但是,下面的所有操作都可以 在本地数据上运行,方法是用图像的字符串替换dgsamples调用 地点。从exmaples,而不是键入`dgsamples.wv2_longmont_1k.ms`, 可以使用位于`/path/to/imgfile.TIF`的本地文件。

使用geoimage对象:

importdgsamples# Instantiate an image objectimg=geoio.GeoImage(dgsamples.bayou_chip.extract_test)# a TIF file# Print useful information about the objectimg.filesimg.meta# Get numpy arraydata=img.get_data()# Process data and write to new imagenewdata=data*2img.write_img_like_this('/path/to/newfile.TIF',newdata)

使用DGIMAGE对象:

importdgsamples# Instantiate an image objectimg=geoio.DGImage(dgsamples.wv2_longmont_1k.ms)# a TIL file# Can also be used directly with a DigitalGlobe TIF file if an XML and/or IMD# is available with same name as the TIF file.# Print useful information about the objectimg.filesimg.meta# Print the full IMD OrderedBunch objectimg.meta_dg.IMD# tab completeable through the OrderedBunch# Return an ImgArr (a numpy array with band meta data handling)data=img.get_data()# Convert an ImgArr to a pure numpy arraynpdata=np.asarray(data)# Return a pure numpy arraydata=img.get_data(meta=False)# Get specific bands using aliases - see geoio.constants.DG_BAND_ALIASES for# additional aliases.data=img.get_data(bands='VIS')# Get specific bands using band aliasesdata=img.get_data(bands=['C','Y'])# Get image data and convert to TOA reflectancedata=img.get_data(stype='toa')

绘图

使用geoio.plotting函数绘制:

importdgsamples# Instantiate an image objectimg=geoio.DGImage(dgsamples.wv2_longmont_1k.ms)# a TIF file# Plot the RGB imagegeoio.plotting.imshow(img.get_data(bands='RGB'))# Plot the near-infrared false color imagegeoio.plotting.imshow(img.get_data(bands=['N1','G','B']))# Plotting a histogram of the image bandsgeoio.plotting.hist(img.get_data())# Plotting a histogram of specific bandsgeoio.plotting.hist(img.get_data(bands='VIS'))

空间重采样

geoio模块有上采样和下映射代码,允许用户 轻松地将两个图像重采样到同一个网格,以便于进行多图像处理。

importdgsamples# Import wv3 imagesms=geoio.DGImage(dgsamples.wv3_longmont_1k.ms)swir=geoio.DGImage(dgsamples.wv3_longmont_1k.swir)# Upsample the swir imageswir.upsample_like_that(ms,method='nearest')# default method is bilinear# Downsample the ms imagems.downsample_like_that(swir)# default method is aggregation# Or let geoio figure it outms.resample_like_that(swir)swir.resample_like_that(ms)

迭代器

geoio模块还提供了几个迭代器,以方便访问 光栅文件中基于产量的部分。

importdgsamplesms=geoio.DGImage(dgsamples.wv2_longmont_1k.ms)# iterate through vector geometriesv=dgsamples.wv2_longmont_1k_vectors.poly_geojson_latlon[xforxinms.iter_vector(vector=v,bands='RGB',mask=True)]# random windows from the image[x.shapeforxinms.iter_window_random(win_size=[10,10],no_chips=20)]# iterate through image with evenly spaced windows based on requested stride[x.shapeforxinms.iter_window(win_size=[10,10],stride=[100,100])

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

推荐PyPI第三方库


热门话题
javajaxb在嵌套节点中生成xmlns:xsi声明   java重定向到youtube以上传jsp上可用的视频   java提高了JVM和ANT的性能   java如何将返回的JSON数据放在HTML表单中   java如何发送XWWWFORMURLENCODE在重新授权   java为什么jvm XX:+EliminateAllocations失败   堆移除和重建方法?(爪哇)   Stanford NPL in Spark(Scala)应用程序运行到Java堆空间(Java.lang.OutOfMemoryError)   调试java中打开/关闭println的任何方式(详细模式)   java IntelliJ在鼠标悬停时显示JavaDocs工具提示   Olingo Odata Java中的自动扩展选项   json将postgres文本arry转换为java列表?   oop需要帮助推断Java代码   复选框的java添加操作侦听器AbstractTableModel   java如何从公共静态void main(String[]args)传递值   java从数据库中获取大值   java Processing 2.0电影从jar运行时无法打开电影文件   java如何在不使用应用程序的情况下刷新活动?   尝试将JSON解析为ListView时的Android:JSON parse:null对象引用