我有一个名为geodf
. 该数据框中每一行的几何图形是一个多面体。例如,如果我们通过地理数据框考虑几何列中的第一行:
bound = geodf['geometry'].iloc[0]
print(bound)
它看起来像这样:
MULTIPOLYGON (((-86.46228799973933 34.31021100007911, -86.46447100007661 34.31018399970606, -86.46447800010341 34.31197299998977, -86.4623920000716 34.31198799958079
多面体本身很大,所以我尝试为它创建一个盒子
box = shapely.geometry.box(*geodf.bounds)
然后我box
通过我们的 Crate DB 服务器通过了以下查询:
query = """
SELECT geohash, grid,shape
FROM geo
WHERE layer = 'pop'
AND MATCH(shape, '{}') USING within;
""".format(box)
geoCursor.execute(query)
results = geoCursor.fetchall()
District = gpd.GeoDataFrame(results, columns = ['geohash', 'grid','shape'])
box
我在上面的查询中通过多边形传递.format(box)
我想做的是通过bound
而不是box
在上面的查询中(请注意,上面的查询适用于box
)。但是,当我尝试通过时,bound
出现以下错误:
ProgrammingError: SQLActionException[UnhandledServerException: java.lang.IllegalArgumentException: Cannot convert Map "{type=MultiPolygon, coordinates=[[[[D@2b59d486}" to shape]
我无法诊断出上述错误。我想知道为什么bounds
不起作用以及如何使它起作用?我们不想使用边界框,因为在我们的多面体边界中没有包含很多多余的区域