首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >(Python) Rtree交集和fiona问题

(Python) Rtree交集和fiona问题
EN

Stack Overflow用户
提问于 2017-11-15 12:07:58
回答 1查看 277关注 0票数 0

我正在尝试为一个交叉点创建一个函数,其中输入文件是某个城市区域,而查询框用于创建一个输出文件,该输出文件的交叉点只包含在该查询框中找到的建筑物。

代码语言:javascript
复制
import matplotlib.pyplot as plt
import matplotlib as mpl
from mpl_toolkits.basemap import Basemap
import fiona
import fiona.crs
import rtree


input_file = 'se_england_clean.shp'
out_file = 'se_england_out'
file_index = 'Rtree_index_east.idx'

query_box = [-0.0957870483,51.5134165224,-0.08664608,51.5192383994]



def write_clipped_file(name_file_in, out_file, file_index):
 idx = rtree.index.Index(file_index)
 idx.insert(0, (input_file))
 list(idx.intersection((query_box)))[0]
 count = 0
 with fiona.open(input_file, 'w') as out_file :  #?
    for building in out_file: #?

到目前为止,我不知道我的代码是否正确,但我有两个直接的问题:首先,我不知道如何用Fiona打开输入的shapefile和我想要在输出中生成的新的(裁剪的) shapefile。我想循环索引列表,选择所需的建筑物,并将它们写入新文件'out_ file‘中。第二,我得到一个错误:

代码语言:javascript
复制
 RTreeError: Coordinates must be in the form (minx, miny, maxx, maxy)
EN

回答 1

Stack Overflow用户

发布于 2017-11-15 15:13:57

代码语言:javascript
复制
idx.insert(0, (input_file))

您需要在树中插入坐标,而不是文件名。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47299216

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档