当前位置: 首页>>代码示例>>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;未经允许,请勿转载。