本文整理汇总了Python中osgeo.ogr.wkbMultiLineString方法的典型用法代码示例。如果您正苦于以下问题:Python ogr.wkbMultiLineString方法的具体用法?Python ogr.wkbMultiLineString怎么用?Python ogr.wkbMultiLineString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osgeo.ogr
的用法示例。
在下文中一共展示了ogr.wkbMultiLineString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_layer
# 需要导入模块: from osgeo import ogr [as 别名]
# 或者: from osgeo.ogr import wkbMultiLineString [as 别名]
def plot_layer(filename, symbol, layer_index=0, **kwargs):
"""Plots an OGR layer using the given symbol."""
ds = ogr.Open(filename)
for row in ds.GetLayer(layer_index):
geom = row.geometry()
geom_type = geom.GetGeometryType()
# Polygons
if geom_type == ogr.wkbPolygon:
plot_polygon(geom, symbol, **kwargs)
# Multipolygons
elif geom_type == ogr.wkbMultiPolygon:
for i in range(geom.GetGeometryCount()):
subgeom = geom.GetGeometryRef(i)
plot_polygon(subgeom, symbol, **kwargs)
# Lines
elif geom_type == ogr.wkbLineString:
plot_line(geom, symbol, **kwargs)
# Multilines
elif geom_type == ogr.wkbMultiLineString:
for i in range(geom.GetGeometryCount()):
subgeom = geom.GetGeometryRef(i)
plot_line(subgeom, symbol, **kwargs)
# Points
elif geom_type == ogr.wkbPoint:
plot_point(geom, symbol, **kwargs)
# Multipoints
elif geom_type == ogr.wkbMultiPoint:
for i in range(geom.GetGeometryCount()):
subgeom = geom.GetGeometryRef(i)
plot_point(subgeom, symbol, **kwargs)
# Now plot countries, rivers, and cities.
示例2: auto_fix_geom_type
# 需要导入模块: from osgeo import ogr [as 别名]
# 或者: from osgeo.ogr import wkbMultiLineString [as 别名]
def auto_fix_geom_type(self, geom, source_geom_type, destination_geom_type):
"""
Converts single geometry type to multi type if the destination is multi type.
:param geom: The OGR geometry
:type geom: OGRGeometry
:param source_geom_type: Source geometry type
:type source_geom_type: String
:param destination_geom_type: Destination geometry type
:type destination_geom_type: String
:return: WkB geometry and the output layer geometry type.
:rtype: Tuple
"""
# Convert polygon to multipolygon if the destination table is multi-polygon.
if source_geom_type.lower() == 'polygon' and \
destination_geom_type.lower() == 'multipolygon':
geom_wkb, geom_type = self.to_ogr_multi_type(geom,
ogr.wkbMultiPolygon)
elif source_geom_type.lower() == 'linestring' and \
destination_geom_type.lower() == 'multilinestring':
geom_wkb, geom_type = self.to_ogr_multi_type(geom,
ogr.wkbMultiLineString)
elif source_geom_type.lower() == 'point' and \
destination_geom_type.lower() == 'multipoint':
geom_wkb, geom_type = self.to_ogr_multi_type(geom, ogr.wkbMultiPoint)
else:
geom_wkb = geom.ExportToWkt()
geom_type = geom.GetGeometryName()
return geom_wkb, geom_type