当前位置: 首页>>代码示例>>Python>>正文


Python geopandas.GeoSeries方法代码示例

本文整理汇总了Python中geopandas.GeoSeries方法的典型用法代码示例。如果您正苦于以下问题:Python geopandas.GeoSeries方法的具体用法?Python geopandas.GeoSeries怎么用?Python geopandas.GeoSeries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在geopandas的用法示例。


在下文中一共展示了geopandas.GeoSeries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_network_false_nodes

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def test_network_false_nodes(self):
        test_file_path2 = mm.datasets.get_path("tests")
        self.false_network = gpd.read_file(test_file_path2, layer="network")
        fixed = mm.network_false_nodes(self.false_network)
        assert len(fixed) == 55
        assert isinstance(fixed, gpd.GeoDataFrame)
        assert self.false_network.crs.equals(fixed.crs)
        fixed_series = mm.network_false_nodes(self.false_network.geometry)
        assert len(fixed_series) == 55
        assert isinstance(fixed_series, gpd.GeoSeries)
        assert self.false_network.crs.equals(fixed_series.crs)
        with pytest.raises(TypeError):
            mm.network_false_nodes(list())
        multiindex = self.false_network.explode()
        fixed_multiindex = mm.network_false_nodes(multiindex)
        assert len(fixed_multiindex) == 55
        assert isinstance(fixed, gpd.GeoDataFrame) 
开发者ID:martinfleis,项目名称:momepy,代码行数:19,代码来源:test_utils.py

示例2: _get_centerline_lonlat

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def _get_centerline_lonlat(gdir):
    """Quick n dirty solution to write the centerlines as a shapefile"""

    cls = gdir.read_pickle('centerlines')
    olist = []
    for j, cl in enumerate(cls[::-1]):
        mm = 1 if j == 0 else 0
        gs = gpd.GeoSeries()
        gs['RGIID'] = gdir.rgi_id
        gs['LE_SEGMENT'] = np.rint(np.max(cl.dis_on_line) * gdir.grid.dx)
        gs['MAIN'] = mm
        tra_func = partial(gdir.grid.ij_to_crs, crs=wgs84)
        gs['geometry'] = shp_trafo(tra_func, cl.line)
        olist.append(gs)

    return olist 
开发者ID:OGGM,项目名称:oggm,代码行数:18,代码来源:_downloads.py

示例3: gaussian_polygons

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def gaussian_polygons(points, n=10):
    """
    Returns an array of approximately `n` `shapely.geometry.Polygon` objects for an array of
    `shapely.geometry.Point` objects.
    """
    gdf = gpd.GeoDataFrame(
        data={'cluster_number': classify_clusters(points, n=n)}, geometry=points
    )
    polygons = []
    for i in range(n):
        sel_points = gdf[gdf['cluster_number'] == i].dropna().geometry
        polygons.append(shapely.geometry.MultiPoint([(p.x, p.y) for p in sel_points]).convex_hull)
    polygons = [
        p for p in polygons if (
            (not isinstance(p, shapely.geometry.Point)) and
            (not isinstance(p, shapely.geometry.LineString)))
    ]
    return gpd.GeoSeries(polygons) 
开发者ID:ResidentMario,项目名称:geoplot,代码行数:20,代码来源:utils.py

示例4: paint_clip

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def paint_clip(self):
        clip = self.kwargs.pop('clip')
        clip = _to_geom_geoseries(self.df, clip, "clip")
        if clip is not None:
            if self.projection is not None:
                xmin, xmax, ymin, ymax = self.ax.get_extent(crs=ccrs.PlateCarree())
                extent = (xmin, ymin, xmax, ymax)
                clip_geom = self._get_clip(extent, clip)
                feature = ShapelyFeature([clip_geom], ccrs.PlateCarree())
                self.ax.add_feature(feature, facecolor=(1,1,1), linewidth=0, zorder=2)
            else:
                xmin, xmax = self.ax.get_xlim()
                ymin, ymax = self.ax.get_ylim()
                extent = (xmin, ymin, xmax, ymax)
                clip_geom = self._get_clip(extent, clip)
                xmin, xmax = self.ax.get_xlim()
                ymin, ymax = self.ax.get_ylim()
                polyplot(
                    gpd.GeoSeries(clip_geom), facecolor='white', linewidth=0, zorder=2,
                    extent=extent, ax=self.ax
                ) 
开发者ID:ResidentMario,项目名称:geoplot,代码行数:23,代码来源:geoplot.py

示例5: test_cluster_is_within_envelope

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def test_cluster_is_within_envelope(get_dataframe):
    """
    Test that all the clusters are within the enveloped formed by all the towers in the cluster.
    """
    cd = CallDays(
        SubscriberLocations(
            "2016-01-01", "2016-01-04", spatial_unit=make_spatial_unit("versioned-site")
        )
    )

    hartigan = HartiganCluster(calldays=cd, radius=50)
    har_df = hartigan.to_geopandas()
    sites = Sites().to_geopandas().set_index(["site_id", "version"])
    towers = GeoSeries(har_df.apply(lambda x: get_geom_point(x, sites), 1))
    s = har_df.intersects(towers)
    assert all(s) 
开发者ID:Flowminder,项目名称:FlowKit,代码行数:18,代码来源:test_subscriber_location_cluster.py

示例6: test_multiple_holes_of_union

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def test_multiple_holes_of_union(self):
        # 00000
        # 0 0 0
        # 00000
        geometries = geopandas.GeoSeries(
            [
                square_at(point)
                for point in product([0, 1, 2, 3, 4], [0, 1, 2])
                if point not in [(1, 1), (3, 1)]
            ]
        )
        result = holes_of_union(geometries)
        assert len(result) == 2
        squares = [square_at((1, 1)), square_at((3, 1))]
        assert (result[0].equals(squares[0]) and result[1].equals(squares[1])) or (
            result[1].equals(squares[0]) and result[0].equals(squares[1])
        ) 
开发者ID:mggg,项目名称:maup,代码行数:19,代码来源:test_holes.py

示例7: test_multipolygon

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def test_multipolygon(self):
        # 000 000
        # 0 0 0 0
        # 000 000

        geometries = geopandas.GeoSeries(
            [
                square_at(point)
                for point in product([0, 1, 2], [0, 1, 2])
                if point != (1, 1)
            ]
            + [
                square_at(point)
                for point in product([4, 5, 6], [0, 1, 2])
                if point != (5, 1)
            ]
        )
        result = holes_of_union(geometries)
        assert len(result) == 2
        squares = [square_at((1, 1)), square_at((5, 1))]
        assert (result[0].equals(squares[0]) and result[1].equals(squares[1])) or (
            result[1].equals(squares[0]) and result[0].equals(squares[1])
        ) 
开发者ID:mggg,项目名称:maup,代码行数:25,代码来源:test_holes.py

示例8: test_can_impose_relative_area_threshold

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def test_can_impose_relative_area_threshold(self):
        # 001
        # 0 1
        # 001
        pacman = Polygon(
            [(0, 0), (0, 3), (2, 3), (2, 2), (1, 2), (1, 1), (2, 1), (2, 0)]
        )

        bar = Polygon([(2, 0), (2, 3), (3, 3), (3, 0)])

        geometries = geopandas.GeoSeries([pacman, bar])
        fixed = close_gaps(geometries, relative_threshold=0.01)
        # Since the gap is more than 1% of the area, the gap is not closed
        assert fixed[1].equals(bar)
        assert fixed[0].equals(pacman)

        geometries = geopandas.GeoSeries([pacman, bar])
        fixed = close_gaps(geometries, relative_threshold=0.5)
        # Since the gap is less than 50% of the area, the gap is closed
        assert fixed[1].equals(bar)
        assert fixed[0].equals(Polygon([(0, 0), (0, 3), (2, 3), (2, 0)])) 
开发者ID:mggg,项目名称:maup,代码行数:23,代码来源:test_holes.py

示例9: test_assigns_overlap_by_max_shared_perimeter

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def test_assigns_overlap_by_max_shared_perimeter(self):
        """The overlapping area should be assigned to the polygon that shares
        the most perimeter with the overlap.
        """
        # 000
        # 00x1
        # 00x1
        square1 = square_at((0, 0), side_length=3)
        square2 = square_at((2, 0), side_length=2)
        geometries = geopandas.GeoSeries([square1, square2])
        result = resolve_overlaps(geometries, relative_threshold=None)

        # Expected:
        # 000
        # 0001
        # 0001
        assert result[0].equals(square1)
        assert result[1].equals(Polygon([(3, 0), (3, 2), (4, 2), (4, 0)])) 
开发者ID:mggg,项目名称:maup,代码行数:20,代码来源:test_holes.py

示例10: test_threshold

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def test_threshold(self):
        # 000
        # 00x1
        # 00x1
        square1 = square_at((0, 0), side_length=3)
        square2 = square_at((2, 0), side_length=2)
        geometries = geopandas.GeoSeries([square1, square2])
        # This threshold is low enough that nothing should happen:
        result = resolve_overlaps(geometries, relative_threshold=0.0001)

        # Expected:
        # 000
        # 00x1
        # 00x1
        print(result)
        assert result[0].equals(square1)
        assert result[1].equals(square2) 
开发者ID:mggg,项目名称:maup,代码行数:19,代码来源:test_holes.py

示例11: test_threshold_rules_out_one_but_not_both

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def test_threshold_rules_out_one_but_not_both(self):
        # 000
        # 00x1
        # 00x1
        square1 = square_at((0, 0), side_length=3)
        square2 = square_at((2, 0), side_length=2)
        geometries = geopandas.GeoSeries([square1, square2])

        # It's under threshold w.r.t square1 but not square 2
        result = resolve_overlaps(geometries, relative_threshold=0.4)

        # Expected:
        # 000
        # 00x1
        # 00x1
        assert result[0].equals(square1)
        assert result[1].equals(square2) 
开发者ID:mggg,项目名称:maup,代码行数:19,代码来源:test_holes.py

示例12: test_fat_ops

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def test_fat_ops(self):
        features = read_test_features()
        gdf = GeoDataFrame.from_features(features)
        self.assertIsNotNone(gdf.crs)

        from cate.ops.data_frame import data_frame_min, data_frame_max
        df_min = data_frame_min(gdf, 'C')
        self.assertIsInstance(df_min, gpd.GeoDataFrame)
        self.assertEqual(len(df_min), 1)
        # assertCountEqual ignores the order of the list
        self.assertCountEqual(list(df_min.columns), ['A', 'B', 'C', 'geometry'])
        self.assertIsInstance(df_min.geometry, gpd.GeoSeries)
        self.assertIsNotNone(df_min.crs)

        df_max = data_frame_max(gdf, 'C')
        self.assertIsInstance(df_max, gpd.GeoDataFrame)
        self.assertEqual(len(df_max), 1)
        # assertCountEqual ignores the order of the list
        self.assertCountEqual(list(df_max.columns), ['A', 'B', 'C', 'geometry'])
        self.assertIsInstance(df_max.geometry, gpd.GeoSeries)
        self.assertIsNotNone(df_max.crs) 
开发者ID:CCI-Tools,项目名称:cate,代码行数:23,代码来源:test_types.py

示例13: _prepare_gdf_for_mask

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def _prepare_gdf_for_mask(geodataframe, method, numbers):

    from geopandas import GeoDataFrame, GeoSeries

    if not isinstance(geodataframe, (GeoDataFrame, GeoSeries)):
        raise TypeError("input must be a geopandas 'GeoDataFrame' or 'GeoSeries'")

    if method == "legacy":
        raise ValueError("method 'legacy' not supported in 'mask_geopandas'")

    lon_min = geodataframe.bounds["minx"].min()
    lon_max = geodataframe.bounds["maxx"].max()
    is_180 = _is_180(lon_min, lon_max)

    polygons = geodataframe.geometry.tolist()

    if numbers is not None:
        numbers = geodataframe[numbers]
        _check_missing(numbers, "numbers")
        _check_duplicates(numbers, "numbers")
    else:
        numbers = geodataframe.index.values

    return polygons, is_180, numbers 
开发者ID:mathause,项目名称:regionmask,代码行数:26,代码来源:_geopandas.py

示例14: test_vector_feature_types

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def test_vector_feature_types(self):
        eop = EOPatch()

        invalid_entries = [
            {}, [], 0, None
        ]

        for feature_type in FeatureTypeSet.VECTOR_TYPES:
            for entry in invalid_entries:
                with self.assertRaises(ValueError,
                                       msg='Invalid entry {} for {} should raise an error'.format(entry, feature_type)):
                    eop[feature_type]['TEST'] = entry

        crs_test = CRS.WGS84.pyproj_crs()
        geo_test = GeoSeries([BBox((1, 2, 3, 4), crs=CRS.WGS84).geometry], crs=crs_test)

        eop.vector_timeless['TEST'] = geo_test
        self.assertTrue(isinstance(eop.vector_timeless['TEST'], GeoDataFrame),
                        'GeoSeries should be parsed into GeoDataFrame')
        self.assertTrue(hasattr(eop.vector_timeless['TEST'], 'geometry'), 'Feature should have geometry attribute')
        self.assertEqual(eop.vector_timeless['TEST'].crs, crs_test, 'GeoDataFrame should still contain the crs')

        with self.assertRaises(ValueError, msg='Should fail because there is no TIMESTAMP column'):
            eop.vector['TEST'] = geo_test 
开发者ID:sentinel-hub,项目名称:eo-learn,代码行数:26,代码来源:test_eodata.py

示例15: makeLineMap

# 需要导入模块: import geopandas [as 别名]
# 或者: from geopandas import GeoSeries [as 别名]
def makeLineMap(line):
    line_plot = gpd.GeoSeries(line)
    line_plot = line_plot.plot(figsize=(24, 24), color="white")
    line_plot.set_facecolor("#111111")
    line_plot.spines["bottom"].set_color("white")
    line_plot.spines["left"].set_color("white")
    line_plot.xaxis.label.set_color("white")
    line_plot.tick_params(axis="x", colors="white")
    line_plot.yaxis.label.set_color("white")
    line_plot.tick_params(axis="y", colors="white")
    line_plot.set_xlabel("Longitude")
    line_plot.set_ylabel("Latitude")
    return line_plot 
开发者ID:metro-ontime,项目名称:performance_tracker,代码行数:15,代码来源:visualizer.py


注:本文中的geopandas.GeoSeries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。