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


Python geometry.MultiPoint方法代碼示例

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


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

示例1: nearest_neighbor_within

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiPoint [as 別名]
def nearest_neighbor_within(others, point, max_distance):
    """Find nearest point among others up to a maximum distance.

    Args:
        others: a list of Points or a MultiPoint
        point: a Point
        max_distance: maximum distance to search for the nearest neighbor

    Returns:
        A shapely Point if one is within max_distance, None otherwise
    """
    search_region = point.buffer(max_distance)
    interesting_points = search_region.intersection(MultiPoint(others))

    if not interesting_points:
        closest_point = None
    elif isinstance(interesting_points, Point):
        closest_point = interesting_points
    else:
        distances = [point.distance(ip) for ip in interesting_points
                     if point.distance(ip) > 0]
        closest_point = interesting_points[distances.index(min(distances))]

    return closest_point 
開發者ID:architecture-building-systems,項目名稱:CityEnergyAnalyst,代碼行數:26,代碼來源:connectivity_potential.py

示例2: test_cover_geometry_empty_geoms

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiPoint [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: _round_multipoint_coords

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

    Parameters
    ----------
    mpt : shapely.geometry.MultiPoint
        the MultiPoint to round the coordinates of
    precision : int
        decimal precision to round coordinates to

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

示例4: polygon_iou

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiPoint [as 別名]
def polygon_iou(list1, list2):
    """
    Intersection over union between two shapely polygons.
    """
    polygon_points1 = np.array(list1).reshape(4, 2)
    poly1 = Polygon(polygon_points1).convex_hull
    polygon_points2 = np.array(list2).reshape(4, 2)
    poly2 = Polygon(polygon_points2).convex_hull
    union_poly = np.concatenate((polygon_points1, polygon_points2))
    if not poly1.intersects(poly2):  # this test is fast and can accelerate calculation
        iou = 0
    else:
        try:
            inter_area = poly1.intersection(poly2).area
            # union_area = poly1.area + poly2.area - inter_area
            union_area = MultiPoint(union_poly).convex_hull.area
            if union_area == 0:
                return 0
            iou = float(inter_area) / union_area
        except shapely.geos.TopologicalError:
            print('shapely.geos.TopologicalError occured, iou set to 0')
            iou = 0
    return iou 
開發者ID:jessemelpolio,項目名稱:Faster_RCNN_for_DOTA,代碼行數:25,代碼來源:test_rcnn.py

示例5: polygon_iou

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiPoint [as 別名]
def polygon_iou(list1, list2):
    """
    Intersection over union between two shapely polygons.
    """
    polygon_points1 = np.array(list1).reshape(4, 2)
    poly1 = Polygon(polygon_points1).convex_hull
    polygon_points2 = np.array(list2).reshape(4, 2)
    poly2 = Polygon(polygon_points2).convex_hull
    union_poly = np.concatenate((polygon_points1, polygon_points2))
    if not poly1.intersects(poly2):  # this test is fast and can accelerate calculation
        iou = 0
    else:
        try:
            inter_area = poly1.intersection(poly2).area
            # union_area = poly1.area + poly2.area - inter_area
            union_area = MultiPoint(union_poly).convex_hull.area
            if union_area == 0:
                return 1
            iou = float(inter_area) / union_area
        except shapely.geos.TopologicalError:
            print('shapely.geos.TopologicalError occured, iou set to 0')
            iou = 0
    return iou 
開發者ID:jessemelpolio,項目名稱:Faster_RCNN_for_DOTA,代碼行數:25,代碼來源:polygon_nms.py

示例6: get_geom_type

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiPoint [as 別名]
def get_geom_type(geom):
    """Returns the HoloViews geometry type.

    Args:
        geom: A shapely geometry

    Returns:
        A string representing type of the geometry.
    """
    from shapely.geometry import (
        Point, LineString, Polygon, Ring, MultiPoint, MultiPolygon, MultiLineString
    )
    if isinstance(geom, (Point, MultiPoint)):
        return 'Point'
    elif isinstance(geom, (LineString, MultiLineString)):
        return 'Line'
    elif isinstance(geom, Ring):
        return 'Ring'
    elif isinstance(geom, (Polygon, MultiPolygon)):
        return 'Polygon' 
開發者ID:holoviz,項目名稱:geoviews,代碼行數:22,代碼來源:geopandas.py

示例7: _poly_area_approximation

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiPoint [as 別名]
def _poly_area_approximation(way, nodes):
    """ Compute the approximated area of an irregular OSM polygon.
        see: https://arachnoid.com/area_irregular_polygon/
             https://gist.github.com/robinkraft/c6de2f988c9d3f01af3c
    """
    points = []
    for node in way['nd']:
        points.append([float(nodes[node['ref']]['lat']), float(nodes[node['ref']]['lon'])])

    approx = MultiPoint(points).convex_hull
    # http://openstreetmapdata.com/info/projections
    proj = partial(pyproj.transform, pyproj.Proj(init='epsg:4326'),
                   pyproj.Proj(init='epsg:3857'))

    converted_approximation = transform(proj, approx)

    return converted_approximation.area 
開發者ID:lcodeca,項目名稱:MoSTScenario,代碼行數:19,代碼來源:compute.area.poly.py

示例8: shapely_to_paths

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiPoint [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

示例9: create_ordered_line

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiPoint [as 別名]
def create_ordered_line(feature_collection):
    ordered_collection = np.array(order_lines(feature_collection))
    return LineString(MultiPoint(ordered_collection)) 
開發者ID:metro-ontime,項目名稱:performance_tracker,代碼行數:5,代碼來源:track.py

示例10: test_CheckTessellationInput

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiPoint [as 別名]
def test_CheckTessellationInput(self):
        df = self.df_buildings
        df.loc[144, "geometry"] = Polygon([(0, 0), (0, 1), (1, 0)])
        df.loc[145, "geometry"] = MultiPoint([(0, 0), (1, 0)]).buffer(0.55)
        df.loc[146, "geometry"] = affinity.rotate(df.geometry.iloc[0], 12)
        check = mm.CheckTessellationInput(self.df_buildings)
        assert len(check.collapse) == 1
        assert len(check.split) == 1
        assert len(check.overlap) == 2

        check = mm.CheckTessellationInput(self.df_buildings, collapse=False)
        assert len(check.split) == 1
        assert len(check.overlap) == 2

        check = mm.CheckTessellationInput(self.df_buildings, split=False)
        assert len(check.collapse) == 1
        assert len(check.overlap) == 2

        check = mm.CheckTessellationInput(self.df_buildings, overlap=False)
        assert len(check.collapse) == 1
        assert len(check.split) == 1

        check = mm.CheckTessellationInput(self.df_buildings, shrink=0)
        assert len(check.collapse) == 0
        assert len(check.split) == 0
        assert len(check.overlap) == 4 
開發者ID:martinfleis,項目名稱:momepy,代碼行數:28,代碼來源:test_utils.py

示例11: multipoint

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

示例12: compute_intersections

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiPoint [as 別名]
def compute_intersections(lines, crs):
    import itertools
    inters = []
    for line1, line2 in itertools.combinations(lines, 2):
        if line1.intersects(line2):
            inter = line1.intersection(line2)
            if "Point" == inter.type:
                inters.append(inter)
            elif "MultiPoint" == inter.type:
                inters.extend([pt for pt in inter])
            elif "MultiLineString" == inter.type:
                multiLine = [line for line in inter]
                first_coords = multiLine[0].coords[0]
                last_coords = multiLine[len(multiLine) - 1].coords[1]
                inters.append(Point(first_coords[0], first_coords[1]))
                inters.append(Point(last_coords[0], last_coords[1]))
            elif "GeometryCollection" == inter.type:
                for geom in inter:
                    if "Point" == geom.type:
                        inters.append(geom)
                    elif "MultiPoint" == geom.type:
                        inters.extend([pt for pt in geom])
                    elif "MultiLineString" == geom.type:
                        multiLine = [line for line in geom]
                        first_coords = multiLine[0].coords[0]
                        last_coords = multiLine[len(multiLine) - 1].coords[1]
                        inters.append(Point(first_coords[0], first_coords[1]))
                        inters.append(Point(last_coords[0], last_coords[1]))

    geometry = inters
    df = gdf(geometry=geometry, crs=crs)
    return df 
開發者ID:architecture-building-systems,項目名稱:CityEnergyAnalyst,代碼行數:34,代碼來源:connectivity_potential.py

示例13: mpt

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiPoint [as 別名]
def mpt():
    return geometry.MultiPoint([(-94.39453125, 15.908203125),
                                (-94.306640625, 15.908203125),
                                (-94.306640625, 15.8203125),
                                (-94.39453125, 15.8203125)]) 
開發者ID:DigitalGlobe,項目名稱:tiletanic,代碼行數:7,代碼來源:test_tilecover.py

示例14: test_cover_geometry_multipoint1

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiPoint [as 別名]
def test_cover_geometry_multipoint1(tiler, mpt):
    """A MultiPoint geometry."""
    tiles = [tile for tile in cover_geometry(tiler, mpt, 4)]
    assert len(tiles) == 1 
開發者ID:DigitalGlobe,項目名稱:tiletanic,代碼行數:6,代碼來源:test_tilecover.py

示例15: test_cover_geometry_multipoint2

# 需要導入模塊: from shapely import geometry [as 別名]
# 或者: from shapely.geometry import MultiPoint [as 別名]
def test_cover_geometry_multipoint2(tiler, mpt):
    """A MultiPoint geometry."""
    tiles = [tile for tile in cover_geometry(tiler, mpt, 12)]
    assert len(tiles) == 9
    assert set(tiles) == {(973, 1203, 12), (974, 1203, 12), (975, 1203, 12),
                          (973, 1204, 12), (973, 1205, 12), (974, 1204, 12),
                          (975, 1204, 12), (974, 1205, 12), (975, 1205, 12)} 
開發者ID:DigitalGlobe,項目名稱:tiletanic,代碼行數:9,代碼來源:test_tilecover.py


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