本文整理匯總了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