我有一个用 OpenTripPlanner 生成的等时多边形:
{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[]},"properties":{"time":-47},"id":"fid--576b228b_15b66d32d71_-7cbd"}]}
使用以下指令将此多边形转换为 Shapely 对象:
isochrone = shapely.geometry.asShape(isochroneJSON['features'][0]['geometry'])
这是它在 Spyder 中的样子:
{u'type': u'FeatureCollection', u'features': [{u'geometry': {u'type': u'MultiPolygon', u'coordinates': []}, u'type': u'Feature', u'properties': {u'time': -47}, u'id': u'fid--576b228b_15b66d32d71_-7a54'}]}
对我来说,它真的看起来像一个空的多边形。我的问题是我想将它排除在我的其余治疗之外,并检查它是否有效和/或为空。以及以下说明:
if not isochrone.is_empty:
使用 .is_empty shapely 指令生成错误:
return (self._geom is None) or bool(self.impl['is_empty'](self))
self.__geom__, n = self.factory(self.context)
我完全迷失了,因为唯一类似的问题似乎没有我自己的问题。