diff --git a/bigframes/geopandas/LICENSE.txt b/bigframes/geopandas/LICENSE.txt new file mode 100644 index 0000000000..028603be20 --- /dev/null +++ b/bigframes/geopandas/LICENSE.txt @@ -0,0 +1,25 @@ +Copyright (c) 2013-2022, GeoPandas developers. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of GeoPandas nor the names of its contributors may + be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/bigframes/geopandas/__init__.py b/bigframes/geopandas/__init__.py new file mode 100644 index 0000000000..96102b5dca --- /dev/null +++ b/bigframes/geopandas/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import geopandas as gpd + + +class GeoSeries(gpd.GeoSeries): + def distance(self): + + return self.distance(...) diff --git a/bigframes/geopandas/geoseries.py b/bigframes/geopandas/geoseries.py new file mode 100644 index 0000000000..ef0227106b --- /dev/null +++ b/bigframes/geopandas/geoseries.py @@ -0,0 +1,68 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING + +from bigframes import constants + +if TYPE_CHECKING: + import bigframes.series + + +class GeoSeries: + """ + A Series object designed to store shapely geometry objects. + """ + + @property + def x(self) -> bigframes.series.Series: + """Return the x location of point geometries in a GeoSeries + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + >>> from shapely.geometry import Point + >>> import geopandas + + >>> series = bigframes.pandas.Series( + ... [shapely.Point(1, 1), shapely.Point(2, 2), shapely.Point(3, 3)], + ... dtype=geopandas.array.GeometryDtype() + ... ) + >>> s.x + 0 1.0 + 1 2.0 + 2 3.0 + dtype: float64 + + Returns: + bigframes.series.Series: + Return the x location (longitude) of point geometries. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + @property + def y(self) -> bigframes.series.Series: + """Return the y location of point geometries in a GeoSeries + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + >>> from shapely.geometry import Point + >>> import geopandas + + >>> series = bigframes.pandas.Series( + ... [shapely.Point(1, 1), shapely.Point(2, 2), shapely.Point(3, 3)], + ... dtype=geopandas.array.GeometryDtype() + ... ) + >>> s.y + 0 1.0 + 1 2.0 + 2 3.0 + dtype: float64 + + Returns: + bigframes.series.Series: + Return the y location (latitude) of point geometries. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) diff --git a/bigframes/series.py b/bigframes/series.py index 3986d38445..a521f4f4d6 100644 --- a/bigframes/series.py +++ b/bigframes/series.py @@ -48,6 +48,7 @@ import bigframes.dataframe import bigframes.dtypes import bigframes.formatting_helpers as formatter +import bigframes.geopandas import bigframes.operations as ops import bigframes.operations.aggregations as agg_ops import bigframes.operations.base @@ -84,6 +85,18 @@ def dtype(self): def dtypes(self): return self._dtype + @property + def geo(self) -> bigframes.geopandas.GeoSeries: + """ + Accessor object for geography properties of the Series values. + + Returns: + bigframes.geopandas.GeoSeries: + An accessor containing geography methods. + + """ + return bigframes.geopandas.GeoSeries(self) + @property def loc(self) -> bigframes.core.indexers.LocSeriesIndexer: return bigframes.core.indexers.LocSeriesIndexer(self)