本文整理汇总了Python中shapely.geometry.polygon.LinearRing方法的典型用法代码示例。如果您正苦于以下问题:Python polygon.LinearRing方法的具体用法?Python polygon.LinearRing怎么用?Python polygon.LinearRing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shapely.geometry.polygon
的用法示例。
在下文中一共展示了polygon.LinearRing方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_view_from_extent
# 需要导入模块: from shapely.geometry import polygon [as 别名]
# 或者: from shapely.geometry.polygon import LinearRing [as 别名]
def get_view_from_extent(extent):
extent = list(map(float, extent.split(",")))
view = LinearRing([
(extent[1], extent[0]),
(extent[3], extent[0]),
(extent[3], extent[2]),
(extent[1], extent[2])
])
return view
示例2: _get_view
# 需要导入模块: from shapely.geometry import polygon [as 别名]
# 或者: from shapely.geometry.polygon import LinearRing [as 别名]
def _get_view(extent):
extent = list(map(float, extent.split(",")))
view = LinearRing([
(extent[1], extent[0]),
(extent[3], extent[0]),
(extent[3], extent[2]),
(extent[1], extent[2])
])
return view
示例3: list_areas
# 需要导入模块: from shapely.geometry import polygon [as 别名]
# 或者: from shapely.geometry.polygon import LinearRing [as 别名]
def list_areas(file_id, simplify=True):
AREA_DIR = os.path.join(current_app.config['OVERLAY_KML_DIR'], 'area')
areas = []
f = os.path.join(AREA_DIR, "%s.kml" % file_id)
folder = ET.parse(f).getroot()
nsmap = folder.tag.split("}", 1)[0] + "}"
def get_coords(path):
result = []
for bound in place.iter(nsmap + path):
for c in bound.iter(nsmap + "coordinates"):
tuples = c.text.split(' ')
coords = []
for tup in tuples:
tup = tup.strip()
if not tup:
continue
lonlat = tup.split(',')
coords.append([float(lonlat[1]), float(lonlat[0])])
if simplify:
coords = list(LinearRing(coords).simplify(1.0 / 32).coords)
result.append(coords)
return result
for place in folder.iter(nsmap + "Placemark"):
outers = get_coords("outerBoundaryIs")
inners = get_coords("innerBoundaryIs")
name = None
for placename in place.iter(nsmap + "name"):
name = placename.text
centroids = [LinearRing(x).centroid for x in outers]
areas.append({
'name': name,
'polygons': outers,
'innerrings': inners,
'centroids': [(c.y, c.x) for c in centroids],
'key': file_id + "/" + name,
})
areas = sorted(areas, key=lambda k: k['name'])
return areas