當前位置: 首頁>>代碼示例>>Python>>正文


Python geometry.MultiLineString方法代碼示例

本文整理匯總了Python中shapely.geometry.MultiLineString方法的典型用法代碼示例。如果您正苦於以下問題:Python geometry.MultiLineString方法的具體用法?Python geometry.MultiLineString怎麽用?Python geometry.MultiLineString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在shapely.geometry的用法示例。


在下文中一共展示了geometry.MultiLineString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _line_iterator

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def _line_iterator(obj):
    if isinstance(obj, (sg.LineString)):
        yield obj
    elif isinstance(obj, (sg.MultiLineString)):
        for obj2 in obj.geoms:
            yield obj2
    elif isinstance(obj, (sg.Polygon)):
        yield sg.LineString(obj.exterior)
        for obj2 in obj.interiors:
            yield sg.LineString(obj2)
    elif isinstance(obj, (sg.MultiPolygon)):
        for obj2 in obj.geoms:
            yield sg.LineString(obj2.exterior)
            for obj3 in obj2.interiors:
                yield sg.LineString(obj3)
    else:
        try:
            tup = tuple(obj)
        except TypeError:
            raise TypeError('Could not use type %s' % type(obj))
        else:
            for obj2 in tup:
                for line in _line_iterator(obj2):
                    yield line 
開發者ID:airware,項目名稱:buzzard,代碼行數:26,代碼來源:_footprint.py

示例2: test_cover_geometry_empty_geoms

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def test_cover_geometry_empty_geoms(tiler):
    """Empty geometries should return empty iterators."""
    assert not cover_geometry(tiler, geometry.Point(), 0) == True
    assert not cover_geometry(tiler, geometry.Point(), [0, 1]) == True
    assert not cover_geometry(tiler, geometry.MultiPoint(), 0) == True
    assert not cover_geometry(tiler, geometry.MultiPoint(), [0, 1]) == True
    assert not cover_geometry(tiler, geometry.LineString(), 0) == True
    assert not cover_geometry(tiler, geometry.LineString(), [0, 1]) == True
    assert not cover_geometry(tiler, geometry.MultiLineString(), 0) == True
    assert not cover_geometry(tiler, geometry.MultiLineString(), [0, 1]) == True
    assert not cover_geometry(tiler, geometry.Polygon(), 0) == True
    assert not cover_geometry(tiler, geometry.Polygon(), [0, 1]) == True
    assert not cover_geometry(tiler, geometry.MultiPolygon(), 0) == True
    assert not cover_geometry(tiler, geometry.MultiPolygon(), [0, 1]) == True
    assert not cover_geometry(tiler, geometry.GeometryCollection(), 0) == True
    assert not cover_geometry(tiler, geometry.GeometryCollection(), [0, 1]) == True 
開發者ID:DigitalGlobe,項目名稱:tiletanic,代碼行數:18,代碼來源:test_tilecover.py

示例3: test_cover_geometry_multilinestring2

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def test_cover_geometry_multilinestring2(tiler, mls):
    """A MultiLineString geometry."""
    tiles = [tile for tile in cover_geometry(tiler, mls, 12)]
    assert len(tiles) == 47
    assert set(tiles) == {(2036, 1420, 12), (2036, 1421, 12), (2036, 1422, 12), (2036, 1423, 12),
                          (2036, 1424, 12), (2037, 1421, 12), (2037, 1422, 12), (2038, 1420, 12),
                          (2038, 1421, 12), (2038, 1422, 12), (2038, 1423, 12), (2038, 1424, 12),
                          (2039, 1420, 12), (2039, 1421, 12), (2039, 1422, 12), (2039, 1423, 12),
                          (2039, 1424, 12), (2040, 1420, 12), (2040, 1422, 12), (2040, 1424, 12),
                          (2041, 1420, 12), (2041, 1422, 12), (2041, 1424, 12), (2042, 1420, 12),
                          (2042, 1421, 12), (2042, 1422, 12), (2042, 1423, 12), (2042, 1424, 12),
                          (2043, 1420, 12), (2044, 1420, 12), (2044, 1421, 12), (2044, 1422, 12),
                          (2044, 1423, 12), (2044, 1424, 12), (2045, 1420, 12), (2046, 1420, 12),
                          (2046, 1421, 12), (2046, 1422, 12), (2046, 1423, 12), (2047, 1420, 12),
                          (2047, 1423, 12), (2047, 1424, 12), (2048, 1420, 12), (2048, 1421, 12),
                          (2048, 1422, 12), (2048, 1423, 12), (2048, 1424, 12)} 
開發者ID:DigitalGlobe,項目名稱:tiletanic,代碼行數:18,代碼來源:test_tilecover.py

示例4: _round_multilinestring_coords

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def _round_multilinestring_coords(mls, precision):
    """
    Round the coordinates of a shapely MultiLineString to some decimal precision.

    Parameters
    ----------
    mls : shapely.geometry.MultiLineString
        the MultiLineString to round the coordinates of
    precision : int
        decimal precision to round coordinates to

    Returns
    -------
    shapely.geometry.MultiLineString
    """
    return MultiLineString([_round_linestring_coords(ls, precision) for ls in mls]) 
開發者ID:gboeing,項目名稱:osmnx,代碼行數:18,代碼來源:utils_geo.py

示例5: shapely_to_paths

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def shapely_to_paths(g):
    if isinstance(g, geometry.Point):
        return []
    elif isinstance(g, geometry.LineString):
        return [list(g.coords)]
    elif isinstance(g, (geometry.MultiPoint, geometry.MultiLineString, geometry.MultiPolygon, geometry.collection.GeometryCollection)):
        paths = []
        for x in g:
            paths.extend(shapely_to_paths(x))
        return paths
    elif isinstance(g, geometry.Polygon):
        paths = []
        paths.append(list(g.exterior.coords))
        for interior in g.interiors:
            paths.extend(shapely_to_paths(interior))
        return paths
    else:
        raise Exception('unhandled shapely geometry: %s' % type(g)) 
開發者ID:fogleman,項目名稱:axi,代碼行數:20,代碼來源:osm.py

示例6: _explode_lines

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def _explode_lines(shape):
    """
    Return a list of LineStrings which make up the shape.
    """

    if shape.geom_type == 'LineString':
        return [shape]

    elif shape.geom_type == 'MultiLineString':
        return shape.geoms

    elif shape.geom_type == 'GeometryCollection':
        lines = []
        for geom in shape.geoms:
            lines.extend(_explode_lines(geom))
        return lines

    return [] 
開發者ID:tilezen,項目名稱:tilequeue,代碼行數:20,代碼來源:rawr.py

示例7: to_shapely

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def to_shapely(self):
        return geometry.MultiLineString(self.paths) 
開發者ID:fogleman,項目名稱:xy,代碼行數:4,代碼來源:drawing.py

示例8: _get_flat_poly_iter

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def _get_flat_poly_iter(cls, poly):
        if (isinstance(poly, shgeo.MultiPolygon) or
                isinstance(poly, shgeo.MultiLineString) or
                isinstance(poly, shgeo.GeometryCollection)):
            yield from poly
        else:
            yield poly 
開發者ID:ucb-art,項目名稱:BAG_framework,代碼行數:9,代碼來源:template.py

示例9: multilinestring

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def multilinestring():
    return geometry.MultiLineString([((0, 0), (1, 1)), ((-1, 0), (1, 0))]) 
開發者ID:fitodic,項目名稱:centerline,代碼行數:4,代碼來源:conftest.py

示例10: test_creating_centerline_from_polygon_returns_centerline

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def test_creating_centerline_from_polygon_returns_centerline(simple_polygon):
    centerline = Centerline(simple_polygon)
    assert isinstance(centerline, Centerline)
    assert isinstance(centerline, geometry.MultiLineString) 
開發者ID:fitodic,項目名稱:centerline,代碼行數:6,代碼來源:test_geometry.py

示例11: test_creating_centerline_from_complex_polygon_returns_centerline

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def test_creating_centerline_from_complex_polygon_returns_centerline(
    complex_polygon,
):
    centerline = Centerline(complex_polygon)

    assert isinstance(centerline, Centerline)
    assert isinstance(centerline, geometry.MultiLineString) 
開發者ID:fitodic,項目名稱:centerline,代碼行數:9,代碼來源:test_geometry.py

示例12: test_creating_centerline_from_multipolygon_returns_centerline

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def test_creating_centerline_from_multipolygon_returns_centerline(
    multipolygon,
):
    centerline = Centerline(multipolygon)
    assert isinstance(centerline, Centerline)
    assert isinstance(centerline, geometry.MultiLineString) 
開發者ID:fitodic,項目名稱:centerline,代碼行數:8,代碼來源:test_geometry.py

示例13: test_creating_centerline_using_too_large_interp_dist_raises_runtimeerror

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def test_creating_centerline_using_too_large_interp_dist_raises_runtimeerror(
    create_polygon,
):
    polygon = create_polygon(exterior=[[0, 0], [10, 0], [10, 10], [0, 10]])
    with pytest.raises(TooFewRidgesError):
        Centerline(polygon, 10)

    centerline = Centerline(polygon, 5)
    assert isinstance(centerline, Centerline)
    assert isinstance(centerline, geometry.MultiLineString) 
開發者ID:fitodic,項目名稱:centerline,代碼行數:12,代碼來源:test_geometry.py

示例14: mls

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def mls():
    return geometry.shape({'type': 'MultiLineString', 'coordinates': (((-0.9709167480468749, 35.18840002173177), (-0.9832763671875, 34.83296838321102), (-0.954437255859375, 35.02774729487063), (-0.850067138671875, 35.02662273458687), (-0.833587646484375, 34.838604318635014), (-0.8074951171874999, 35.185032937998294)), ((-0.0823974609375, 35.191766965947394), (-0.111236572265625, 34.83071390101431), (0.048065185546875, 34.829586636768205), (0.067291259765625, 35.192889249680945), (-0.06591796875, 35.191766965947394)), ((-0.28564453125, 35.19064466671118), (-0.34606933593749994, 34.84085858477277), (-0.18402099609375, 34.831841149828676)), ((-0.48614501953124994, 35.183910545750834), (-0.517730712890625, 34.854382885097905), (-0.391387939453125, 34.84874803007872)), ((-0.553436279296875, 35.183910545750834), (-0.7347106933593749, 35.185032937998294), (-0.751190185546875, 35.05922870088872), (-0.591888427734375, 35.0502352513963), (-0.758056640625, 35.03336986422378), (-0.767669677734375, 34.86227103378598), (-0.597381591796875, 34.85550980979319)))}) 
開發者ID:DigitalGlobe,項目名稱:tiletanic,代碼行數:4,代碼來源:test_tilecover.py

示例15: test_cover_geometry_multilinestring1

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiLineString [as 別名]
def test_cover_geometry_multilinestring1(tiler, mls):
    """A MultiLineString geometry."""
    tiles = [tile for tile in cover_geometry(tiler, mls, 8)]
    assert len(tiles) == 4
    assert set(tiles) == {(127, 88, 8), (127, 89, 8), (128, 88, 8), (128, 89, 8)} 
開發者ID:DigitalGlobe,項目名稱:tiletanic,代碼行數:7,代碼來源:test_tilecover.py


注:本文中的shapely.geometry.MultiLineString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。