
    h                        d dl Z d dlZd dlZd dlZd dlmZ d dlZd dlZ	d dl
mZmZmZ d dlZd dlZd dlZd dlZd dlZd dlmZ ddlmZmZmZmZmZmZ ddlmZ erd dlmZ  eej@                        Z!ddd	d
ddddddd
Z"ddhZ#h dZ$d	dhZ%ejL                  D  ci c]  } | jN                  e"| jP                      c} Z) e*e)jW                               Z, ejZ                   e*e)j]                               e/      Z0 G d de      Z1 ee1       d%dZ2d&dZ3d Z4d Z5d'dZ6d Z7d(dZ8d%dZ9d(dZ:d Z;d)d Z< G d! d"e      Z=d# Z>d$ Z?yc c} w )*    N)	lru_cache)ExtensionArrayExtensionDtyperegister_extension_dtype)BaseGeometry   )GEOS_GE_312
HAS_PYPROJPANDAS_GE_21PANDAS_GE_22SHAPELY_GE_21requires_pyproj)SpatialIndex)TransformerPoint
LineString
LinearRingPolygon
MultiPointMultiLineStringMultiPolygonGeometryCollection)
MISSINGNAGPOINT
LINESTRING
LINEARRINGPOLYGON
MULTIPOINTMULTILINESTRINGMULTIPOLYGONGEOMETRYCOLLECTION>   r   r   r   dtypec                   8    e Zd ZeZdZdZed        Zed        Z	y)GeometryDtypegeometryNc                     t        |t              st        dt        |             || j                  k(  r |        S t        d| j
                   d| d      )Nz.'construct_from_string' expects a string, got zCannot construct a 'z' from '')
isinstancestr	TypeErrortypename__name__)clsstrings     B/var/www/html/immo/lib/python3.12/site-packages/geopandas/array.pyconstruct_from_stringz#GeometryDtype.construct_from_string@   s\    &#&@fO  sxx5L23<<.PQRSS    c                     t         S N)GeometryArray)r0   s    r2   construct_array_typez"GeometryDtype.construct_array_typeK   s    r4   )
r/   
__module____qualname__r   r-   r.   na_valueclassmethodr3   r8    r4   r2   r&   r&   ;   s9    DDHT T  r4   r&   c                 n    |r| j                   r|j                   sy| j                   |j                   k(  syy)z{
    Check if the projection of both arrays is the same.

    If allow_none is True, empty CRS is treated as the same.
    TFcrs)leftright
allow_nones      r2   
_check_crsrD   S   s-     xxuyy88uyy r4   c                    | j                   rA| j                   j                         }t        |      dk  r|ndj                  |dd dg      }nd}|j                   rA|j                   j                         }t        |      dk  r|ndj                  |dd dg      }nd}t	        j
                  d| d| dt        |       y)	zFRaise a CRS mismatch warning with the information on the assigned CRS.2    Nz...zCRS mismatch between the CRS of left geometries and the CRS of right geometries.
Use `to_crs()` to reproject one of the input geometries to match the CRS of the other.

Left CRS: z
Right CRS: 

stacklevel)r@   	to_stringlenjoinwarningswarnUserWarning)rA   rB   rJ   left_srs	right_srss        r2   _crs_mismatch_warnrS   a   s    xx88%%'"8}28(3B-QVAW8XyyII'')	Y2-I388Ys^U<S3T 	 	MM	 J [	$ 		r4   c                 |    | yt        | t              rt        j                  |       ry| t        j
                  u ryy)z
    Check if scalar value is NA-like (None, np.nan or pd.NA).

    Custom version that only works for scalars (returning True or False),
    as `pd.isna` also works for array-like input returning a boolean array.
    TF)r*   floatnpisnanpdNA)values    r2   isnar[   }   s4     }	E5	!bhhuo	"%%r4   c                 "    t        | t              S r6   )r*   r   )geoms    r2   _is_scalar_geometryr^      s    dL))r4   c                    t        | t        j                        s*t        j                  t	        |       t
              }| |dd n5t	        |       dk(  r%| j                  dk(  r| j                  t
              }n| }t        j                  |      j                         sg }| D ]  }t        |t              r|j                  |       %t        |d      r1t        j                  j                  |      }|j                  |       bt!        |      r|j                  d       t#        d|        t        j$                  |t
              }t'        ||      S )a  
    Convert a list or array of shapely objects to a GeometryArray.

    Validates the elements.

    Parameters
    ----------
    data : array-like
        list or array of shapely objects
    crs : value, optional
        Coordinate Reference System of the geometry objects. Can be anything accepted by
        :meth:`pyproj.CRS.from_user_input() <pyproj.crs.CRS.from_user_input>`,
        such as an authority string (eg "EPSG:4326") or a WKT string.

    r#   Nr   float64__geo_interface__z&Input must be valid geometry objects: r?   )r*   rV   ndarrayemptyrL   objectr$   astypeshapelyis_valid_inputallr   appendhasattrr'   shaper[   r,   arrayr7   )datar@   arroutr]   s        r2   from_shapelyrp      s     dBJJ'hhs4y/A	TaDJJ)3kk&!!!#&**, 		QD$-

4 23''--d3

4 d

4 "H OPP		Q hhs&)#&&r4   c                 P    t        | t              st        d      | j                  S )z?Convert GeometryArray to numpy object array of shapely objects.'geoms' must be a GeometryArray)r*   r7   
ValueError_data)geomss    r2   
to_shapelyrv      s"    e]+:;;;;r4   c                 F    t        t        j                  | |      |      S )a  
    Convert a list or array of WKB objects to a GeometryArray.

    Parameters
    ----------
    data : array-like
        list or array of WKB objects
    crs : value, optional
        Coordinate Reference System of the geometry objects. Can be anything accepted by
        :meth:`pyproj.CRS.from_user_input() <pyproj.crs.CRS.from_user_input>`,
        such as an authority string (eg "EPSG:4326") or a WKT string.
    on_invalid: {"raise", "warn", "ignore"}, default "raise"
        - raise: an exception will be raised if a WKB input geometry is invalid.
        - warn: a warning will be raised and invalid WKB geometries will be returned as
          None.
        - ignore: invalid WKB geometries will be returned as None without a warning.
        - fix: an effort is made to fix invalid input geometries (e.g. close
          unclosed rings). If this is not possible, they are returned as ``None``
          without a warning. Requires GEOS >= 3.11 and shapely >= 2.1.

    
on_invalidr?   )r7   rf   from_wkbrm   r@   ry   s      r2   rz   rz          , ))$:FCPPr4   c                 h    t        | t              st        d      t        j                  | fd|i|S )z=Convert GeometryArray to a numpy object array of WKB objects.rr   hex)r*   r7   rs   rf   to_wkb)ru   r~   kwargss      r2   r   r      s1    e]+:;;>>%3S3F33r4   c                 F    t        t        j                  | |      |      S )a  
    Convert a list or array of WKT objects to a GeometryArray.

    Parameters
    ----------
    data : array-like
        list or array of WKT objects
    crs : value, optional
        Coordinate Reference System of the geometry objects. Can be anything accepted by
        :meth:`pyproj.CRS.from_user_input() <pyproj.crs.CRS.from_user_input>`,
        such as an authority string (eg "EPSG:4326") or a WKT string.
    on_invalid : {"raise", "warn", "ignore"}, default "raise"
        - raise: an exception will be raised if a WKT input geometry is invalid.
        - warn: a warning will be raised and invalid WKT geometries will be
          returned as ``None``.
        - ignore: invalid WKT geometries will be returned as ``None`` without a warning.
        - fix: an effort is made to fix invalid input geometries (e.g. close
          unclosed rings). If this is not possible, they are returned as ``None``
          without a warning. Requires GEOS >= 3.11 and shapely >= 2.1.

    rx   r?   )r7   rf   from_wktr{   s      r2   r   r      r|   r4   c                 d    t        | t              st        d      t        j                  | fi |S )z=Convert GeometryArray to a numpy object array of WKT objects.rr   )r*   r7   rs   rf   to_wkt)ru   r   s     r2   r   r     s,    e]+:;;>>%*6**r4   c                     t        j                  | d      } t        j                  |d      }|t        j                  |d      }t        t        j                  | ||      |      S )aN  
    Generate GeometryArray of shapely Point geometries from x, y(, z) coordinates.

    In case of geographic coordinates, it is assumed that longitude is captured by
    ``x`` coordinates and latitude by ``y``.

    Parameters
    ----------
    x, y, z : iterable
    crs : value, optional
        Coordinate Reference System of the geometry objects. Can be anything accepted by
        :meth:`pyproj.CRS.from_user_input() <pyproj.crs.CRS.from_user_input>`,
        such as an authority string (eg "EPSG:4326") or a WKT string.

    Examples
    --------
    >>> import pandas as pd
    >>> df = pd.DataFrame({'x': [0, 1, 2], 'y': [0, 1, 2], 'z': [0, 1, 2]})
    >>> df
       x  y  z
    0  0  0  0
    1  1  1  1
    2  2  2  2
    >>> geometry = geopandas.points_from_xy(x=[1, 0], y=[0, 1])
    >>> geometry = geopandas.points_from_xy(df['x'], df['y'], df['z'])
    >>> gdf = geopandas.GeoDataFrame(
    ...     df, geometry=geopandas.points_from_xy(df['x'], df['y']))

    Having geographic coordinates:

    >>> df = pd.DataFrame({'longitude': [-140, 0, 123], 'latitude': [-65, 1, 48]})
    >>> df
       longitude  latitude
    0       -140       -65
    1          0         1
    2        123        48
    >>> geometry = geopandas.points_from_xy(df.longitude, df.latitude, crs="EPSG:4326")

    Returns
    -------
    output : GeometryArray
    r`   r#   r?   )rV   asarrayr7   rf   points)xyzr@   s       r2   points_from_xyr     sT    V 	

1I&A


1I&A}JJq	*1a0c::r4   c                   t    e Zd ZdZ e       ZddZed        Zed        Z	ed        Z
e
j                  d        Z
d Zed	        Zd
 Zd Zd Zd Zd Zed        Zd ZddZddZed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Zed        Z d Z!d Z"d Z#d  Z$d! Z%ed"        Z&ed#        Z'd$ Z(d% Z)ed&        Z*ed'        Z+d( Z,ed)        Z-d* Z.dd+Z/ed,        Z0dd-Z1d. Z2d/ Z3d0 Z4d1 Z5d2 Z6d3 Z7d4 Z8dd6Z9dd7Z:d8 Z;d9 Z<d: Z=dd;Z>dd<Z?dd=Z@dd>ZAeBd?        ZCd@ ZDdA ZEdB ZFdC ZGdD ZHdE ZIdF ZJdG ZKdH ZLdI ZMdJ ZNdK ZOdL ZPdM ZQdN ZRdO ZSdP ZTdQ ZUdR ZVdS ZWdT ZXdU ZYdV ZZdW Z[dX Z\ddYZ]ddZZ^dd[Z_dd\Z`dd]Zad^ Zbd_ Zcd` ZdddaZedb ZfeBdc        Zgdd ZhddeZiddfZjddgZkddhZlemddi       Znemddj       Zoedk        Zpedl        Zqedm        Zredn        Zsedo        Ztedp        Zuedq        Zvedr        Zweds        Zxdt ZydduZz	 d fdv	Z{ddwZ|ddxZ}dy Z~	 ddzefd{Zd| Zed}        Zd fd~	Zedd       Zedd5dd       Zd Zed        Zd ZddedefdZddedefdZddZed        ZddZddZd Zd Zd Zd Z xZS )r7   ziClass wrapping a numpy array of Shapely objects.

    It also holds the array-based implementations.
    Nc                    t        || j                        r|s|j                  }|j                  }n?t        |t        j
                        st        d      |j                  dk(  st        d      || _        d | _	        || _        d | _
        y )Nzx'data' should be array of geometry objects. Use from_shapely, from_wkb, from_wkt functions to construct a GeometryArray.r   z;'data' should be a 1-dimensional array of geometry objects.)r*   	__class__r@   rt   rV   rb   r,   ndimrs   _crs_sindex)selfrm   r@   s      r2   __init__zGeometryArray.__init__C  s    dDNN+hh::DD"**-M  aM  
	r4   c                 f    | j                   t        | j                        | _         | j                   S )z/Spatial index for the geometries in this array.)r   r   rt   r   s    r2   sindexzGeometryArray.sindexW  s(     <<'

3DL||r4   c                     | j                   duS )a^  Check the existence of the spatial index without generating it.

        Use the `.sindex` attribute on a GeoDataFrame or GeoSeries
        to generate a spatial index if it does not yet exist,
        which may take considerable time based on the underlying index
        implementation.

        Note that the underlying spatial index may not be fully
        initialized until the first use.

        See Also
        --------
        GeoDataFrame.has_sindex

        Returns
        -------
        bool
            `True` if the spatial index has been generated or
            `False` if not.
        N)r   r   s    r2   
has_sindexzGeometryArray.has_sindex^  s    , ||4''r4   c                     | j                   S )a  The Coordinate Reference System (CRS) represented as a ``pyproj.CRS`` object.

        Returns None if the CRS is not set, and to set the value it
        :getter: Returns a ``pyproj.CRS`` or None. When setting, the value
        Coordinate Reference System of the geometry objects. Can be anything accepted by
        :meth:`pyproj.CRS.from_user_input() <pyproj.crs.CRS.from_user_input>`,
        such as an authority string (eg "EPSG:4326") or a WKT string.
        )r   r   s    r2   r@   zGeometryArray.crsv  s     yyr4   c                     t         r'ddlm} |sd| _        y|j                  |      | _        y|t        j                  dt        d       d| _        y)zSet the value of the crs.r   CRSNzCannot set the CRS, falling back to None. The CRS support requires the 'pyproj' package, but it is not installed or does not import correctly. The functions depending on CRS will raise an error or may produce unexpected results.   rI   )r
   pyprojr   from_user_inputr   rN   rO   rP   )r   rZ   r   s      r2   r@   zGeometryArray.crs  sL     "$)DIs/B/B5/IDI 7    DIr4   c                     | j                   rW| j                   j                  r@t        j                  dt	        j
                         d   j                   dt        |       yyy)zGCheck CRS and warn if the planar operation is done in a geographic CRS.z/Geometry is in a geographic CRS. Results from 'r   zt' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.
rI   N)r@   is_geographicrN   rO   inspectstackfunctionrP   )r   rJ   s     r2   check_geographic_crsz"GeometryArray.check_geographic_crs  sV    88..MMMMOA&//0 199 % /8r4   c                     | j                   S r6   )_dtyper   s    r2   r$   zGeometryArray.dtype  s    {{r4   c                      | j                   d   S )Nr   )rk   r   s    r2   __len__zGeometryArray.__len__  s    zz!}r4   c                     t        |t        j                        r| j                  |   S t        j
                  j                  j                  | |      }t        | j                  |   | j                        S Nr?   )
r*   numbersIntegralrt   rX   apiindexerscheck_array_indexerr7   r@   )r   idxs     r2   __getitem__zGeometryArray.__getitem__  sU    c7++,::c?" ffoo11$<TZZ_$((;;r4   c                    t         j                  j                  j                  | |      }t	        |t         j
                        r|j                  }t	        |t         j                        r|j                  j                         }t	        |t        t        j                  z        rt        |      }t	        |t              rFt	        |t        j                        rt!        d      |j"                  | j"                  |<   d | _        y t	        |t$              st'        |      rt'        |      rd }n5t	        |t$              rt        |g      j"                  d   }nt)        d      t	        |t*        t        z  t        j                  z        r8t        j,                  dt.              }|g|d d  || j"                  |<   d | _        y || j"                  |<   d | _        y t)        d|      )Nz)cannot set a single element with an arrayr   zshould be valid geometryr   r#   z3Value should be either a BaseGeometry or None, got )rX   r   r   r   r*   Seriesvalues	DataFrameflattenlistrV   rb   rp   r7   r   r   rs   rt   r   r[   r,   slicerc   rd   r   )r   keyrZ   value_arrays       r2   __setitem__zGeometryArray.__setitem__  sx    ffoo11$<eRYY'LLEeR\\*LL((*EeTBJJ./ 'Ee]+#w//0 !LMM#kkDJJsO, + |,UE{ E<0$eW-33A6 :;;#ut|bjj89 hhq7"'A"-

3  #(

3  EeYO r4   c                 X    t        j                  | j                        | j                  fS r6   )rf   r   rt   r   r   s    r2   __getstate__zGeometryArray.__getstate__  s    tzz*DII66r4   c                    t        |t              s8t        j                  |d         }|d   | _        d | _        || _        d | _        y d|v r|j                  d      |d<   d|vrd |d<   | j                  j                  |       y )Nr   r   rm   rt   r   )r*   dictrf   rz   r   r   rt   basepop__dict__update)r   stateru   s      r2   __setstate__zGeometryArray.__setstate__  s|    %&$$U1X.EaDIDLDJDI!&6!2gU" $fMM  'r4   c                 @    t        j                  | j                        S r6   )rf   is_validrt   r   s    r2   r   zGeometryArray.is_valid      

++r4   c                 @    t        j                  | j                        S r6   )rf   is_valid_reasonrt   r   s    r2   r   zGeometryArray.is_valid_reason  s    &&tzz22r4   c                     t         rt        st        d      t        t	        j
                  | j                  |            S )Nz@Method 'is_valid_coverage' requires shapely>=2.1 and GEOS>=3.12.	gap_width)r   r	   ImportErrorboolrf   coverage_is_validrt   r   r   s     r2   is_valid_coveragezGeometryArray.is_valid_coverage  s5    +R  G--djjINOOr4   c                 r    t         rt        st        d      t        j                  | j
                  |      S )NzEMethod 'invalid_coverage_edges' requires shapely>=2.1 and GEOS>=3.12.r   )r   r	   r   rf   coverage_invalid_edgesrt   r   s     r2   invalid_coverage_edgesz$GeometryArray.invalid_coverage_edges  s0    +W  --djjINNr4   c                 @    t        j                  | j                        S r6   )rf   is_emptyrt   r   s    r2   r   zGeometryArray.is_empty	  r   r4   c                 @    t        j                  | j                        S r6   )rf   	is_simplert   r   s    r2   r   zGeometryArray.is_simple        ,,r4   c                 @    t        j                  | j                        S r6   )rf   is_ringrt   r   s    r2   r   zGeometryArray.is_ring  s    tzz**r4   c                 @    t        j                  | j                        S r6   )rf   	is_closedrt   r   s    r2   r   zGeometryArray.is_closed  r   r4   c                 @    t        j                  | j                        S r6   )rf   is_ccwrt   r   s    r2   r   zGeometryArray.is_ccw      ~~djj))r4   c                 @    t        j                  | j                        S r6   )rf   has_zrt   r   s    r2   r   zGeometryArray.has_z  s    }}TZZ((r4   c                 b    t         st        d      t        j                  | j                        S )Nz'has_m' requires shapely>=2.1.)r   r   rf   has_mrt   r   s    r2   r   zGeometryArray.has_m!  s$    >??}}TZZ((r4   c                     t        j                  | j                        }t        t	        j
                  t        |         S r6   )rf   get_type_idrt   geometry_type_valuesrV   searchsortedgeometry_type_ids)r   ress     r2   	geom_typezGeometryArray.geom_type(  s-    !!$**-#BOO4Es$KLLr4   c                 d    | j                  d       t        j                  | j                        S )aS  Return the area of the geometries in this array.

        Raises a UserWarning if the CRS is geographic, as the area
        calculation is not accurate in that case.

        Note that the area is calculated in the units of the CRS.

        Returns
        -------
        np.ndarray of float
            Area of the geometries.
           rI   )r   rf   areart   r   s    r2   r   zGeometryArray.area-  s(     	!!Q!/||DJJ''r4   c                 d    | j                  d       t        j                  | j                        S )Nr   rI   )r   rf   lengthrt   r   s    r2   r   zGeometryArray.length>  s&    !!Q!/~~djj))r4   c                 @    t        j                  | j                        S r6   )rf   get_num_coordinatesrt   r   s    r2   count_coordinateszGeometryArray.count_coordinatesC  s    **4::66r4   c                 @    t        j                  | j                        S r6   )rf   get_num_geometriesrt   r   s    r2   count_geometrieszGeometryArray.count_geometriesF  s    ))$**55r4   c                 @    t        j                  | j                        S r6   )rf   get_num_interior_ringsrt   r   s    r2   count_interior_ringsz"GeometryArray.count_interior_ringsI  s    --djj99r4   c                 @    t        j                  | j                        S r6   )rf   get_precisionrt   r   s    r2   r   zGeometryArray.get_precisionL  s    $$TZZ00r4   c                 D    t        j                  | j                  |      S )N)index)rf   get_geometryrt   )r   r   s     r2   r   zGeometryArray.get_geometryO  s    ##DJJe<<r4   c                 j    t        t        j                  | j                        | j                        S r   )r7   rf   boundaryrt   r@   r   s    r2   r  zGeometryArray.boundaryV  s"    W--djj9txxHHr4   c                     | j                  d       t        t        j                  | j                        | j
                        S )Nr   rI   r?   )r   r7   rf   centroidrt   r@   r   s    r2   r  zGeometryArray.centroidZ  s3    !!Q!/W--djj9txxHHr4   c                 F    t        j                  | j                  ||      S )N)ratioallow_holes)rf   concave_hullrt   )r   r  r  s      r2   r  zGeometryArray.concave_hull_  s    ##DJJeUUr4   c                     t         st        d      t        t        j                  | j
                        | j                        S )Nz7'constrained_delaunay_triangles' requires shapely>=2.1.r?   )r   r   r7   rf   constrained_delaunay_trianglesrt   r@   r   s    r2   r
  z,GeometryArray.constrained_delaunay_trianglesb  s6    WXX224::>DHH
 	
r4   c                 j    t        t        j                  | j                        | j                        S )z7Return the convex hull of the geometries in this array.r?   )r7   rf   convex_hullrt   r@   r   s    r2   r  zGeometryArray.convex_hullj  s$     W00<$((KKr4   c                 j    t        t        j                  | j                        | j                        S )z4Return the envelope of the geometries in this array.r?   )r7   rf   envelopert   r@   r   s    r2   r  zGeometryArray.envelopeo  s$     W--djj9txxHHr4   c                 j    t        t        j                  | j                        | j                        S )zEReturn the minimum rotated rectangle of the geometries in this array.r?   )r7   rf   oriented_envelopert   r@   r   s    r2   minimum_rotated_rectanglez'GeometryArray.minimum_rotated_rectanglet  "    W66tzzBQQr4   c                 j    t        t        j                  | j                        | j                        S r   )r7   rf   get_exterior_ringrt   r@   r   s    r2   exteriorzGeometryArray.exteriorx  r  r4   c                 j    t        t        j                  | j                        | j                        S r   )r7   rf   extract_unique_pointsrt   r@   r   s    r2   r  z#GeometryArray.extract_unique_points|  s"    W::4::FDHHUUr4   c           	      t    t        t        j                  | j                  ||||      | j                        S )N)	quad_segs
join_stylemitre_limitr?   )r7   rf   offset_curvert   r@   )r   distancer  r  r  s        r2   r  zGeometryArray.offset_curve  s9      

#%' 	
 		
r4   c                 .   d}g }| j                   D ]?  }t        |dd       }||j                  t        |             -d}|j                  d        A |rt	        j
                  dd       t        j                  t        |      t              }||d d  |S )NF	interiorsTzUOnly Polygon objects have interior rings. For other geometry types, None is returned.r   rI   r#   )
rt   getattrri   r   rN   rO   rV   rc   rL   rd   )r   has_non_polyinner_ringsr]   interior_ring_seqrm   s         r2   r  zGeometryArray.interiors  s     JJ 	)D 'k4 @ ,""4(9#:;  $""4(	) MM4 xxK(7Qr4   c                 n    t        t        j                  | j                  |      | j                        S )N	tolerancer?   )r7   rf   remove_repeated_pointsrt   r@   r   r&  s     r2   r'  z$GeometryArray.remove_repeated_points  s*    **4::K
 	
r4   c                 j    t        t        j                  | j                        | j                        S r   )r7   rf   point_on_surfacert   r@   r   s    r2   representative_pointz"GeometryArray.representative_point  s"    W55djjAtxxPPr4   c                 j    t        t        j                  | j                        | j                        S r   )r7   rf   minimum_bounding_circlert   r@   r   s    r2   r-  z%GeometryArray.minimum_bounding_circle  s"    W<<TZZHdhhWWr4   c                     t         st        d      t        t        j                  | j
                  |      | j                        S )Nz1'maximum_inscribed_circle' requires shapely>=2.1.r%  r?   )r   r   r7   rf   maximum_inscribed_circlert   r@   r(  s     r2   r/  z&GeometryArray.maximum_inscribed_circle  s9    QRR,,TZZ9M
 	
r4   c                 @    t        j                  | j                        S r6   )rf   minimum_bounding_radiusrt   r   s    r2   r1  z%GeometryArray.minimum_bounding_radius  s    ..tzz::r4   c                 @    t        j                  | j                        S r6   )rf   minimum_clearancert   r   s    r2   r3  zGeometryArray.minimum_clearance  s    ((44r4   c                     t         st        d      t        t        j                  | j
                        | j                        S )Nz/'minimum_clearance_line' requires shapely>=2.1.r?   )r   r   r7   rf   minimum_clearance_linert   r@   r   s    r2   r5  z$GeometryArray.minimum_clearance_line  s1    OPPW;;DJJGTXXVVr4   c                 j    t        t        j                  | j                        | j                        S r   )r7   rf   	normalizert   r@   r   s    r2   r7  zGeometryArray.normalize  s"    W..tzz:IIr4   Fc                     t         st        d      t        t        j                  | j
                  |      | j                        S )Nz('orient_polygons' requires shapely>=2.1.)exterior_cwr?   )r   r   r7   rf   orient_polygonsrt   r@   )r   r9  s     r2   r:  zGeometryArray.orient_polygons  s8    HII##DJJKHdhh
 	
r4   c                     i }t         r||d<   ||d<   n|dk7  rt        d      t        t        j                  | j
                  fi || j                        S )Nmethodkeep_collapsedlineworkz:Only the 'linework' method is supported for shapely < 2.1.r?   )r   rs   r7   rf   
make_validrt   r@   )r   r<  r=  r   s       r2   r?  zGeometryArray.make_valid  s^    %F8'5F#$# P  W//

EfE488TTr4   c                 j    t        t        j                  | j                        | j                        S r   )r7   rf   reversert   r@   r   s    r2   rA  zGeometryArray.reverse  s     W__TZZ8dhhGGr4   c                 l    t        t        j                  | j                  |      | j                        S r   )r7   rf   
segmentizert   r@   )r   max_segment_lengths     r2   rC  zGeometryArray.segmentize  s+    tzz+=>
 	
r4   c                 j    t        t        j                  | j                        | j                        S r   )r7   rf   force_2drt   r@   r   s    r2   rF  zGeometryArray.force_2d  s"    W--djj9txxHHr4   c                 n    t        t        j                  | j                  |      | j                        S )N)r   r?   )r7   rf   force_3drt   r@   )r   r   s     r2   rH  zGeometryArray.force_3d  s$    W--djjA>DHHMMr4   c                 p    t        t        j                  | j                  ||      | j                        S )N	include_zr?   )r7   rf   	transformrt   r@   )r   transformationrK  s      r2   rL  zGeometryArray.transform  s,    djj.IN
 	
r4   c                 n    t        t        j                  | j                  |      | j                        S )N)directedr?   )r7   rf   
line_mergert   r@   )r   rO  s     r2   rP  zGeometryArray.line_merge  s)    tzzH=488
 	
r4   c                 p    t        t        j                  | j                  ||      | j                        S )N)	grid_sizemoder?   )r7   rf   set_precisionrt   r@   )r   rR  rS  s      r2   rT  zGeometryArray.set_precision  s,    !!$**	M
 	
r4   c                 *   t        |t              rbt        |      t        |      k7  r%dt        |       dt        |       }t        |      t	        ||      st        ||d       |j                  } t        t        |       |j                  |fi |S )Nz&Lengths of inputs do not match. Left: z	, Right:    rI   )	r*   r7   rL   rs   rD   rS   rt   r   rf   )oprA   rB   r   msgs        r2   _binary_methodzGeometryArray._binary_method  s    e]+4yCJ& YKyU>  !o%dE*"41=KKE#ww#DJJ@@@r4   c                 (    | j                  d| |      S )NcoversrY  r   others     r2   r[  zGeometryArray.covers      ""8T599r4   c                 (    | j                  d| |      S )N
covered_byr\  r]  s     r2   ra  zGeometryArray.covered_by      ""<u==r4   c                 (    | j                  d| |      S )Ncontainsr\  r]  s     r2   rd  zGeometryArray.contains      "":tU;;r4   c                 (    | j                  d| |      S )Ncontains_properlyr\  r]  s     r2   rg  zGeometryArray.contains_properly  s    ""#6eDDr4   c                 (    | j                  d| |      S )Ncrossesr\  r]  s     r2   ri  zGeometryArray.crosses      ""9dE::r4   c                 (    | j                  d| |      S )Ndisjointr\  r]  s     r2   rl  zGeometryArray.disjoint  re  r4   c                 (    | j                  d| |      S )Nequalsr\  r]  s     r2   geom_equalszGeometryArray.geom_equals   r_  r4   c                 (    | j                  d| |      S )N
intersectsr\  r]  s     r2   rq  zGeometryArray.intersects#  rb  r4   c                 (    | j                  d| |      S )Noverlapsr\  r]  s     r2   rs  zGeometryArray.overlaps&  re  r4   c                 (    | j                  d| |      S )Ntouchesr\  r]  s     r2   ru  zGeometryArray.touches)  rj  r4   c                 (    | j                  d| |      S )Nwithinr\  r]  s     r2   rw  zGeometryArray.within,  r_  r4   c                 P    | j                  d       | j                  d| ||      S )N   rI   dwithin)r  r   rY  )r   r^  r  s      r2   rz  zGeometryArray.dwithin/  s-    !!Q!/""9dEH"MMr4   c                 ,    | j                  d| ||      S )Nequals_exactr%  r\  r   r^  r&  s      r2   geom_equals_exactzGeometryArray.geom_equals_exact3  s    "">4)"TTr4   c                 J    t         st        d      | j                  d| |      S )Nz.'geom_equals_identical' requires shapely>=2.1.equals_identical)r   r   rY  r]  s     r2   geom_equals_identicalz#GeometryArray.geom_equals_identical6  s'    NOO""#5tUCCr4   c           	      r    t        t        j                  | j                  ||||      | j                        S r   )r7   rf   clip_by_rectrt   r@   )r   xminyminxmaxymaxs        r2   r  zGeometryArray.clip_by_rect?  s/      T4tD$((
 	
r4   c                 R    t        | j                  d| |      | j                        S )N
differencer?   r7   rY  r@   r]  s     r2   r  zGeometryArray.differenceD  s'    dE:
 	
r4   c                 R    t        | j                  d| |      | j                        S )Nintersectionr?   r  r]  s     r2   r  zGeometryArray.intersectionI  '    e<$((
 	
r4   c                 R    t        | j                  d| |      | j                        S )Nsymmetric_differencer?   r  r]  s     r2   r  z"GeometryArray.symmetric_differenceN  s(     6eD$((
 	
r4   c                 R    t        | j                  d| |      | j                        S )Nunionr?   r  r]  s     r2   r  zGeometryArray.unionS  s"    T00$FDHHUUr4   c                 R    t        | j                  d| |      | j                        S )Nshortest_liner?   r  r]  s     r2   r  zGeometryArray.shortest_lineV  s'    u=488
 	
r4   c                 V    t        | j                  d| ||      | j                        S )Nsnapr%  r?   r  r~  s      r2   r  zGeometryArray.snap[  s,    eyItxx
 	
r4   c                 R    t        | j                  d| |      | j                        S )Nshared_pathsr?   r  r]  s     r2   r  zGeometryArray.shared_paths`  r  r4   c                 L    | j                  d       | j                  d| |      S )Nry  rI   r  r{  r]  s     r2   r  zGeometryArray.distancei  s(    !!Q!/"":tU;;r4   c                 P    | j                  d        | j                  d| |fi |S )Nry  rI   hausdorff_distancer{  r   r^  r   s      r2   r  z GeometryArray.hausdorff_distancem  s0    !!Q!/"t""#7uOOOr4   c                 P    | j                  d        | j                  d| |fi |S )Nry  rI   frechet_distancer{  r  s      r2   r  zGeometryArray.frechet_distanceq  s0    !!Q!/"t""#5tUMfMMr4   c                     t        |t        t        z        r|dk(  s| j                  d       t	        t        j                  | j                  |fd|i|| j                        S )Nr   r   rI   r  r?   )	r*   intrU   r   r7   rf   bufferrt   r@   )r   r  
resolutionr   s       r2   r  zGeometryArray.bufferu  sW    8S5[1h!m%%%3NN4::xP:PP
 	
r4   c                     | j                  d       t        t        j                  | j                  ||      | j
                        S )Nr   rI   
normalizedr?   )r   r7   rf   line_interpolate_pointrt   r@   )r   r  r  s      r2   interpolatezGeometryArray.interpolate}  s=    !!Q!/**4::xJW
 	
r4   c                 p    t        t        j                  | j                  ||      | j                        S )N)preserve_topologyr?   )r7   rf   simplifyrt   r@   )r   r&  r  s      r2   r  zGeometryArray.simplify  s2    

I9J 	
 	
r4   c                     t         rt        st        d      t        t	        j
                  | j                  ||      | j                        S )Nz9'simplify_coverage' requires shapely>=2.1 and GEOS>=3.12.)simplify_boundaryr?   )r   r	   r   r7   rf   coverage_simplifyrt   r@   )r   r&  r  s      r2   simplify_coveragezGeometryArray.simplify_coverage  sI    +K  %%

I9J 	
 	
r4   c                 ~    t        |t              r|j                  }t        j                  | j                  ||      S )Nr  )r*   r7   rt   rf   line_locate_point)r   r^  r  s      r2   projectzGeometryArray.project  s.    e]+KKE((UzRRr4   c                 z    t        |t              r|j                  }t        j                  | j                  |      S r6   )r*   r7   rt   rf   relater]  s     r2   r  zGeometryArray.relate  s*    e]+KKE~~djj%00r4   c                 |    t        |t              r|j                  }t        j                  | j                  ||      S r6   )r*   r7   rt   rf   relate_pattern)r   r^  patterns      r2   r  zGeometryArray.relate_pattern  s.    e]+KKE%%djj%AAr4   c                 Z    t        j                  dt        d       | j                         S )NzNThe 'unary_union' attribute is deprecated, use the 'union_all' method instead.r   rI   )rN   rO   DeprecationWarning	union_allr   s    r2   unary_unionzGeometryArray.unary_union  s(    2		
 ~~r4   c                 V   |dk7  r|t        d| d      |dk(  rt        j                  | j                        S |dk(  r!t        j                  | j                  |      S |dk(  r6t
        rt        st        d      t        j                  | j                        S t        d| d	      )
Nunaryz'grid_size is not supported for method 'z'.coverage)rR  disjoint_subsetz=Method 'disjoin_subset' requires shapely>=2.1 and GEOS>=3.12.zMethod 'z?' not recognized. Use 'coverage', 'unary' or 'disjoint_subset'.)	rs   rf   coverage_union_allrt   r  r   r	   r   disjoint_subset_union_all)r   r<  rR  s      r2   r  zGeometryArray.union_all  s    W!6FvhbQRRZ--djj99w$$TZZ9EE((!k!S  44TZZ@@6( #% % r4   c                 @    t        j                  | j                        S r6   )rf   intersection_allrt   r   s    r2   r  zGeometryArray.intersection_all  s    ''

33r4   c                     g }|D ]H  }||j                   r|}n$ t        t        j                  |       |g|i |}|j	                  |       J t        j                  t        |      t              }||d d  |S )Nr#   )	r   r   rf   affinityri   rV   rc   rL   rd   )rW  rA   argsr   ro   r]   r   rm   s           r2   _affinity_methodzGeometryArray._affinity_method  sz      	D|t}}3gg..3DJ4J6JJJsO	 xxD	0Qr4   c                 f    t        | j                  d| j                  |      | j                        S )Naffine_transformr?   r7   r  rt   r@   )r   matrixs     r2   r  zGeometryArray.affine_transform  s-    !!"4djj&I
 	
r4   c           	      j    t        | j                  d| j                  |||      | j                        S )N	translater?   r  )r   xoffyoffzoffs       r2   r  zGeometryArray.translate  s0    !!+tzz4tL
 	
r4   c           	      l    t        | j                  d| j                  |||      | j                        S )Nrotateoriginuse_radiansr?   r  )r   angler  r  s       r2   r  zGeometryArray.rotate  s:    !!$**eF "  	
 	
r4   c           
      n    t        | j                  d| j                  ||||      | j                        S )Nscale)r  r?   r  )r   xfactyfactzfactr  s        r2   r  zGeometryArray.scale  s<    !!UE5 "  	
 	
r4   c           
      n    t        | j                  d| j                  ||||      | j                        S )Nskewr  r?   r  )r   xsysr  r  s        r2   r  zGeometryArray.skew  s<    !!

B6{ "  	
 	
r4   c                 f   ddl m} | j                  t        d      ||j	                  |      }n||j                  |      }nt        d      | j                  j                  |      r| S t        | j                  |d      }t        | j                  |j                        }t        ||      S )u[
  Transform all geometries to a different coordinate reference system.

        Transform all geometries in a GeometryArray to a different coordinate
        reference system.  The ``crs`` attribute on the current GeometryArray must
        be set.  Either ``crs`` or ``epsg`` may be specified for output.

        This method will transform all points in all objects.  It has no notion
        of projecting entire geometries.  All segments joining points are
        assumed to be lines in the current projection, not geodesics.  Objects
        crossing the dateline (or other projection boundary) will have
        undesirable behavior.

        Parameters
        ----------
        crs : pyproj.CRS, optional if `epsg` is specified
            The value can be anything accepted
            by :meth:`pyproj.CRS.from_user_input() <pyproj.crs.CRS.from_user_input>`,
            such as an authority string (eg "EPSG:4326") or a WKT string.
        epsg : int, optional if `crs` is specified
            EPSG code specifying output projection.

        Returns
        -------
        GeometryArray

        Examples
        --------
        >>> from shapely.geometry import Point
        >>> from geopandas.array import from_shapely, to_wkt
        >>> a = from_shapely([Point(1, 1), Point(2, 2), Point(3, 3)], crs=4326)
        >>> to_wkt(a)
        array(['POINT (1 1)', 'POINT (2 2)', 'POINT (3 3)'], dtype=object)
        >>> a.crs  # doctest: +SKIP
        <Geographic 2D CRS: EPSG:4326>
        Name: WGS 84
        Axis Info [ellipsoidal]:
        - Lat[north]: Geodetic latitude (degree)
        - Lon[east]: Geodetic longitude (degree)
        Area of Use:
        - name: World
        - bounds: (-180.0, -90.0, 180.0, 90.0)
        Datum: World Geodetic System 1984
        - Ellipsoid: WGS 84
        - Prime Meridian: Greenwich

        >>> a = a.to_crs(3857)
        >>> to_wkt(a)
        array(['POINT (111319.490793 111325.142866)',
               'POINT (222638.981587 222684.208506)',
               'POINT (333958.47238 334111.171402)'], dtype=object)
        >>> a.crs  # doctest: +SKIP
        <Projected CRS: EPSG:3857>
        Name: WGS 84 / Pseudo-Mercator
        Axis Info [cartesian]:
        - X[east]: Easting (metre)
        - Y[north]: Northing (metre)
        Area of Use:
        - name: World - 85°S to 85°N
        - bounds: (-180.0, -85.06, 180.0, 85.06)
        Coordinate Operation:
        - name: Popular Visualisation Pseudo-Mercator
        - method: Popular Visualisation Pseudo Mercator
        Datum: World Geodetic System 1984
        - Ellipsoid: WGS 84
        - Prime Meridian: Greenwich

        r   r   zICannot transform naive geometries.  Please set a crs on the object first.zMust pass either crs or epsg.T	always_xyr?   )r   r   r@   rs   r   	from_epsgis_exact_sameTransformerFromCRSrL  rt   r7   )r   r@   epsgr   transformernew_datas         r2   to_crszGeometryArray.to_crs  s    J 	888  ?%%c*C--%C<== 88!!#&K(3$GTZZ)>)>?X3//r4   c           	         ddl m} ddlm} ddlm} | j                  st        d      | j                  \  }}}}| j                  j                  r/t        j                  ||g      }	t        j                  ||g      }
nt        | j                  dd      }|j                  ||||      \  }}}}t        j                  ||g      }
||kD  r(|d	z  }t        j                  ||g      }	|	d
z   d	z  d
z
  }	nt        j                  ||g      }	 || ||	|
|	|
            }	 |j                  |d   j                        S # t         $ r t        d      w xY w)uu  Return the estimated UTM CRS based on the bounds of the dataset.

        .. versionadded:: 0.9

        .. note:: Requires pyproj 3+

        Parameters
        ----------
        datum_name : str, optional
            The name of the datum to use in the query. Default is WGS 84.

        Returns
        -------
        pyproj.CRS

        Examples
        --------
        >>> import geodatasets
        >>> df = geopandas.read_file(
        ...     geodatasets.get_path("geoda.chicago_commpop")
        ... )
        >>> df.geometry.values.estimate_utm_crs()  # doctest: +SKIP
        <Derived Projected CRS: EPSG:32616>
        Name: WGS 84 / UTM zone 16N
        Axis Info [cartesian]:
        - E[east]: Easting (metre)
        - N[north]: Northing (metre)
        Area of Use:
        - name: Between 90°W and 84°W, northern hemisphere between equator and 84°N,...
        - bounds: (-90.0, 0.0, -84.0, 84.0)
        Coordinate Operation:
        - name: UTM zone 16N
        - method: Transverse Mercator
        Datum: World Geodetic System 1984 ensemble
        - Ellipsoid: WGS 84
        - Prime Meridian: Greenwich
        r   r   )AreaOfInterest)query_utm_crs_infoz$crs must be set to estimate UTM CRS.z	EPSG:4326Tr  ih     )west_lon_degreesouth_lat_degreeeast_lon_degreenorth_lat_degree)
datum_namearea_of_interestzUnable to determine UTM CRS)r   r   
pyproj.aoir  pyproj.databaser  r@   RuntimeErrortotal_boundsr   rV   meanr  transform_boundsr  code
IndexError)r   r  r   r  r  minxminymaxxmaxyx_centery_centerr  utm_crs_lists                r2   estimate_utm_crszGeometryArray.estimate_utm_crs_  sS   N 	-6xxEFF!%!2!2dD$88!!wwd|,Hwwd|,H -TXX{dSK%0%A%AdD$&"D$d wwd|,Hd{ 77D$<0%^s2c977D$<0)!+ (!) (!)	
	>==a!5!566 	><==	>s   !D? ?Ec                    | j                   | j                             dk(  j                         r| j                  }|j	                         rT| }t        j                  |t        t
        j                        }t        j                  | j                  |         ||<   |S t        j                  | j                        S d}t        |      )z9Return the x location of point geometries in a GeoSeries.r   r$   
fill_valuez5x attribute access only provided for Point geometries)r   r[   rh   r   anyrV   	full_likerU   nanrf   get_xrt   rs   r   rc   nonemptycoordsmessages        r2   r   zGeometryArray.x       NNDIIK<(G388:MMEyy{!6heO#*==H1E#Fx }}TZZ00MGW%%r4   c                    | j                   | j                             dk(  j                         r| j                  }|j	                         rT| }t        j                  |t        t
        j                        }t        j                  | j                  |         ||<   |S t        j                  | j                        S d}t        |      )z9Return the y location of point geometries in a GeoSeries.r   r  z5y attribute access only provided for Point geometries)r   r[   rh   r   r  rV   r  rU   r  rf   get_yrt   rs   r
  s        r2   r   zGeometryArray.y  r  r4   c                    | j                   | j                             dk(  j                         r| j                  }|j	                         rT| }t        j                  |t        t
        j                        }t        j                  | j                  |         ||<   |S t        j                  | j                        S d}t        |      )z9Return the z location of point geometries in a GeoSeries.r   r  z5z attribute access only provided for Point geometries)r   r[   rh   r   r  rV   r  rU   r  rf   get_zrt   rs   r
  s        r2   r   zGeometryArray.z  r  r4   c                    t         st        d      | j                  | j                             dk(  j	                         r| j
                  }|j                         rT| }t        j                  |t        t        j                        }t        j                  | j                  |         ||<   |S t        j                  | j                        S d}t        |      )z;Return the m coordinate of point geometries in a GeoSeries.z'm' requires shapely>=2.1.r   r  z5m attribute access only provided for Point geometries)r   r   r   r[   rh   r   r  rV   r  rU   r  rf   get_mrt   rs   r
  s        r2   mzGeometryArray.m  s     :;;NNDIIK<(G388:MMEyy{!6heO#*==H1E#Fx }}TZZ00MGW%%r4   c                 @    t        j                  | j                        S r6   )rf   boundsrt   r   s    r2   r  zGeometryArray.bounds  r   r4   c                 d   t        |       dk(  rQt        j                  t        j                  t        j                  t        j                  t        j                  g      S | j                  }t        j                         5  t        j                  ddt               t        j                  t        j                  |d d df         t        j                  |d d df         t        j                  |d d df         t        j                  |d d df         f      cd d d        S # 1 sw Y   y xY w)Nr   ignorezAll-NaN slice encounteredr   r      )rL   rV   rl   r  r  rN   catch_warningsfilterwarningsRuntimeWarningnanminnanmax)r   bs     r2   r  zGeometryArray.total_bounds  s    t9> 88RVVRVVRVVRVV<==KK$$& 	##6 88IIa1g&IIa1g&IIa1g&IIa1g&		 	 	s    BD&&D/c                 .    | j                   j                  S r6   )rt   sizer   s    r2   r"  zGeometryArray.size  s    zzr4   c                     | j                   fS r6   )r"  r   s    r2   rk   zGeometryArray.shape  s    		|r4   c                 ,    t        | j                        S r6   )rL   rk   r   s    r2   r   zGeometryArray.ndim  s    4::r4   c                 `    t        | j                  j                         | j                        S r   )r7   rt   copyr   )r   r  r   s      r2   r&  zGeometryArray.copy"  s    TZZ__.DII>>r4   c                    ddl m} |r0|t        j                  |      rd }nt	        |      st        d       || j                  |||      }|r|d |t        j                  |       <   t        || j                        S )Nr   )takez&provide geometry or None as fill value)
allow_fillr  r?   )pandas.api.extensionsr(  rX   r[   r^   r,   rt   rf   rg   r7   r@   )r   indicesr)  r  r(  results         r2   r(  zGeometryArray.take&  sw    .!RWWZ%8!
(4 HIIdjj'jZX*,6:FG**6223V22r4   c                 \    t         rt        s|||d<   n||d<   t        |   d|||d|S )N
limit_area)r<  limitr&  r=   )r   r   super_pad_or_backfill)r   r<  r/  r.  r&  r   r   s         r2   r1  zGeometryArray._pad_or_backfill5  sC     % (2|$#-F< w'XvUXQWXXr4   c                    |t        d      | j                         }|r| j                         }n| }|j                         s|S |6|t	        |       k  r(|j                         |kD  }|j                         rd||<   t        |      rdg}nFt        |      r|g}n7t        |t              r||   }n!t        dt        |      j                        t        j                  |t              }||j                  |<   |S )a)  
        Fill NA values with geometry (or geometries) or using the specified method.

        Parameters
        ----------
        value : shapely geometry object or GeometryArray
            If a geometry value is passed it is used to fill all missing values.
            Alternatively, an GeometryArray 'value' can be given. It's expected
            that the GeometryArray has the same length as 'self'.

        method : {'backfill', 'bfill', 'pad', 'ffill', None}, default None
            Method to use for filling holes in reindexed Series
            pad / ffill: propagate last valid observation forward to next valid
            backfill / bfill: use NEXT valid observation to fill gap

        limit : int, default None
            The maximum number of entries where NA values will be filled.

        copy : bool, default True
            Whether to make a copy of the data before filling. If False, then
            the original should be modified and no new memory should be allocated.

        Returns
        -------
        GeometryArray
        Nz)fillna with a method is not yet supportedFzT'value' parameter must be None, a scalar geometry, or a GeoSeries, but you passed a r#   )NotImplementedErrorr[   r&  r  rL   cumsumr^   r*   r7   r,   r-   r/   rV   r   rd   rt   )	r   rZ   r<  r/  r&  mask
new_valuesmodify	value_arrs	            r2   fillnazGeometryArray.fillnaA  s    6 %&QRRyy{JJxxzT!2[[]U*Fzz|$V;FE 'GE}-$KE$$(K$8$8#;=  JJuF3	!*
r4   c                 @   t        |t              r|r| j                         S | S t        j                  j
                  j                  |      rt        j                  j
                  j                  |      sxt        |       }t        j                  j
                  j                  |      }t        |t        j                        rt        j                  ||      S |j                  |d      S |st        j                  | |      S t        j                  | ||      S )a  
        Cast to a NumPy array with 'dtype'.

        Parameters
        ----------
        dtype : str or dtype
            Typecode or data-type to which the array is cast.
        copy : bool, default True
            Whether to copy the data, even if not necessary. If False,
            a copy is made only if the old dtype does not match the
            new dtype.

        Returns
        -------
        array : ndarray
            NumPy ndarray with 'dtype' for its dtype.
        r#   F)r&  r$   r&  )r*   r&   r&  rX   r   typesis_string_dtypeis_object_dtyper   pandas_dtypeStringDtyperl   re   rV   r   )r   r$   r&  string_valuespd_dtypes        r2   re   zGeometryArray.astype}  s    $ e]+yy{"VV\\))%09U9U:
 #4LMvv||007H(BNN3xxX>> ''E'::
 zz$e44xxE==r4   c                 @    t        j                  | j                        S )z8Boolean NumPy array indicating if each value is missing.)rf   
is_missingrt   r   s    r2   r[   zGeometryArray.isna  s    !!$**--r4   dropnac           	          t        |       }ddlm}m}  ||      j	                  |      } |t        t        j                  |j                  j                         d|j                                    |_        |S )z
        Compute a histogram of the counts of non-null values.

        Parameters
        ----------
        dropna : bool, default True
            Don't include counts of NaN

        Returns
        -------
        pd.Series
        r   )Indexr   )rE  N)
r   pandasrG  r   value_countsrz   rV   wherer   r[   )r   rE  r   rG  r   r,  s         r2   rI  zGeometryArray.value_counts  sb    $ (,,F,;
 RXXfll//14FG
 r4   c                 (    ddl m}  ||       \  }}|S )zwCompute the ExtensionArray of unique values.

        Returns
        -------
        uniques : ExtensionArray
        r   )	factorize)rH  rL  )r   rL  _uniquess       r2   uniquezGeometryArray.unique  s     	%t_
7r4   c                 .    | j                   j                  S r6   )rt   nbytesr   s    r2   rQ  zGeometryArray.nbytes  s    zz   r4   c                 J    t         |   ||      }| j                  |_        |S )aL  
        Shift values by desired number.

        Newly introduced missing values are filled with
        ``self.dtype.na_value``.

        Parameters
        ----------
        periods : int, default 1
            The number of periods to shift. Negative values are allowed
            for shifting backwards.

        fill_value : object, optional (default None)
            The scalar value to use for newly introduced missing values.
            The default is ``self.dtype.na_value``.

        Returns
        -------
        GeometryArray
            Shifted.

        Notes
        -----
        If ``self`` is empty or ``periods`` is 0, a copy of ``self`` is
        returned.

        If ``periods > len(self)``, then an array of size
        len(self) is returned, with all values filled with
        ``self.dtype.na_value``.
        )r0  shiftr@   )r   periodsr  shiftedr   s       r2   rS  zGeometryArray.shift  s%    > '-4hhr4   c                 >    t        |t              r|g}t        |      S )a#  
        Construct a new ExtensionArray from a sequence of scalars.

        Parameters
        ----------
        scalars : Sequence
            Each element will be an instance of the scalar type for this
            array, ``cls.dtype.type``.
        dtype : dtype, optional
            Construct for this particular dtype. This should be a Dtype
            compatible with the ExtensionArray.
        copy : boolean, default False
            If True, copy the underlying data.

        Returns
        -------
        ExtensionArray
        )r*   r   rp   )r0   scalarsr$   r&  s       r2   _from_sequencezGeometryArray._from_sequence   s     * g|,iGG$$r4   r;  c                    t        |      S )a   
        Construct a new ExtensionArray from a sequence of strings.

        Parameters
        ----------
        strings : Sequence
            Each element will be an instance of the scalar type for this
            array, ``cls.dtype.type``.
        dtype : dtype, optional
            Construct for this particular dtype. This should be a Dtype
            compatible with the ExtensionArray.
        copy : bool, default False
            If True, copy the underlying data.

        Returns
        -------
        ExtensionArray
        )r   )r0   stringsr$   r&  s       r2   _from_sequence_of_stringsz'GeometryArray._from_sequence_of_strings  s    *   r4   c                      t        |       }|dfS )as  Return an array and missing value suitable for factorization.

        Returns
        -------
        values : ndarray
            An array suitable for factorization. This should maintain order
            and be a supported dtype (Float64, Int64, UInt64, String, Object).
            By default, the extension array is cast to object dtype.
        na_value : object
            The value in `values` to consider missing. This will be treated
            as NA in the factorization routines, so it will be coded as
            `na_sentinal` and not included in `uniques`. By default,
            ``np.nan`` is used.
        N)r   )r   valss     r2   _values_for_factorizez#GeometryArray._values_for_factorize0  s      d|Tzr4   c                 0    t        ||j                        S )a  
        Reconstruct an ExtensionArray after factorization.

        Parameters
        ----------
        values : ndarray
            An integer ndarray with the factorized values.
        original : ExtensionArray
            The original ExtensionArray that factorize was called on.

        See Also
        --------
        pandas.factorize
        ExtensionArray.factorize
        r?   )rz   r@   )r0   r   originals      r2   _from_factorizedzGeometryArray._from_factorizedC  s    " HLL11r4   c                 `   ddl m} | j                  dk(  rt        j                  g d      S | j
                  }|j                         }| j                         |z  }|j                         rd| j                         }t        j                  |       d   }|j                  r	| |d      }n t        j                  j                  dd      }|||<   n| }|rG|j                  }|d   |d   z
  dz  }	|d   |d   z
  dz  }
|t        j                  |	 |
 |	|
g      z  }nd	} |||
      }|rd||<   |S )a  Return values for sorting.

        Returns
        -------
        ndarray
            The transformed values should maintain the ordering between values
            within the array.

        See Also
        --------
        ExtensionArray.argsort
        r   )_hilbert_distanceuint32r#   r   g{Gz?r  r   N)r  )geopandas.tools.hilbert_curverc  r"  rV   rl   r   r  r[   r&  nonzerorf   r'   r   r  )r   rc  
mask_empty	has_emptyr5  ru   r+  r]   r  r  r  	distancess               r2   _values_for_argsortz!GeometryArray._values_for_argsortV  s5    	D99>88Bh//]]
NN$	yy{Z'88: IIKEjj$'*G||GAJ' ''--a3E$KE !--L Ol1o5=D Ol1o5=DBHHtedUD$%?@@LL%e,G	 %&Ij!r4   skipnareturnc                     t        d      Nz%geometries have no minimum or maximumr,   r   rk  s     r2   argminzGeometryArray.argmin      ?@@r4   c                     t        d      rn  ro  rp  s     r2   argmaxzGeometryArray.argmax  rr  r4   c                    |rddl }|j                  j                  | j                  r| j                  j                  rdndnt        j                         5  t        j                  dt               | | j                             dd j                  \  }}}}ddd       dcxk  rd	k  r0n n-dcxk  rd	k  r"n nd
cxk  rdk  rn nd
cxk  rdk  rn ndndfdS t        S # 1 sw Y   QxY w)aX  Return a formatting function for scalar values.

        This is used in the default '__repr__'. The returned formatting
        function receives instances of your scalar type.

        Parameters
        ----------
        boxed: bool, default False
            An indicated for whether or not your array is being printed
            within a Series, DataFrame, or Index (True), or just by
            itself (False). This may be useful if you want scalar values
            to appear differently within a Series versus on its own (e.g.
            quoted or not).

        Returns
        -------
        Callable[[Any], str]
            A callable that gets instances of the scalar type and
            returns a string. By default, :func:`repr` is used
            when ``boxed=False`` and :func:`str` is used when
            ``boxed=True``.
        r   Nr  r   r  )category
   iLr  iZ   c                 2    t        j                  |       S )N)rounding_precision)rf   r   )r]   	precisions    r2   <lambda>z*GeometryArray._formatter.<locals>.<lambda>  s    t	 R r4   )	geopandasoptionsdisplay_precisionr@   is_projectedrN   r  simplefilterr  r[   r  repr)r   boxedr}  r  r  r  r  r{  s          @r2   
_formatterzGeometryArray._formatter  s    . !));;I 88xx,,$%	$%	
 "002 V --hP15tyy{l1CCR1H1U1U.dD$V ,,!T0S0 D.B. D.B. %&	 %&	RR!V Vs   AC..C7c                     t        j                  |D cg c]  }|j                   c}      }t        |t	        |            S c c}w )zConcatenate multiple array.

        Parameters
        ----------
        to_concat : sequence of this type

        Returns
        -------
        ExtensionArray
        r?   )rV   concatenatert   r7   _get_common_crs)r0   	to_concatgarm   s       r2   _concat_same_typezGeometryArray._concat_same_type  s8     ~~)<Brxx<=Ty'ABB =s   Ac           	          |dv r t        | j                  |      |      S t        dt        |       j                   d| j
                   d| d      )N)r  rh   )keepdimsr)   z' with dtype z does not support reduction ')r   rt   r,   r-   r/   r$   )r   r.   rk  r  r   s        r2   _reducezGeometryArray._reduce  s^     >!,74::t,h??T
##$M$** >++/&3
 	
r4   c                     |r4||t        j                  d      k(  r| j                  j                         S | j                  S )zReturn the data as a numpy array.

        This is the numpy array interface.

        Returns
        -------
        values : numpy array
        rd   )rV   r$   rt   r&  )r   r$   r&  s      r2   	__array__zGeometryArray.__array__  s6     U]erxx/A&A::??$$zzr4   c                 z     fd}t        |t        j                  t        j                  z  t        j                  z        rt
        S  } ||      }t        |      t        |      k7  rt        d      t        ||      D cg c]  \  }} |||       }}}t        j                  |t              }|S c c}}w )Nc                     t        |       s=t        | t              s)t        j                  j
                  j                  |       r| }|S | gt              z  }|S r6   )r^   r*   r   rX   r   r<  is_list_likerL   )paramovaluesr   s     r2   convert_valuesz,GeometryArray._binop.<locals>.convert_values  sM    &u-5.1RVV\\5N5Nu5U N !'CI-Nr4   zLengths must match to comparer#   )r*   rX   r   rG  r   NotImplementedrL   rs   ziprV   r   r   )	r   r^  rW  r  lvaluesrvaluesar   r   s	   `        r2   _binopzGeometryArray._binop  s    	 eRYY1BLL@A!! 'w<3w<'<== '*'7&;<FQr!Qx<<jjD)
 =s   B7c                 B    | j                  |t        j                        S r6   )r  operatoreqr]  s     r2   __eq__zGeometryArray.__eq__      {{5(++..r4   c                 B    | j                  |t        j                        S r6   )r  r  ner]  s     r2   __ne__zGeometryArray.__ne__  r  r4   c                     t        |      rY|| j                  j                  u s"t        || j                  j                        s|| j                         j                         S y| |k(  j                         S )zReturn for `item in self`.F)r[   r$   r;   r*   r-   r  )r   items     r2   __contains__zGeometryArray.__contains__  s[    :

+++dDJJOO4<yy{((!!##r4   r6   )        )   roundg      @F)r>  T)r   )valid_output)   )T)r  N)r  r  r  )centerF)      ?r  r  r  )r  r  r  FNN)zWGS 84)FN)NNT)NNNT)r   N)NF)TF)r/   r9   r:   __doc__r&   r   r   propertyr   r   r@   setterr   r$   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r
  r  r  r  r  r  r  r  r'  r+  r-  r/  r1  r3  r5  r7  r:  r?  rA  rC  rF  rH  rL  rP  rT  staticmethodrY  r[  ra  rd  rg  ri  rl  ro  rq  rs  ru  rw  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r   r   r   r  r  r  r"  rk   r   r&  r(  r1  r9  re   r[   r   rI  rO  rQ  rS  r<   rX  r[  r^  ra  rj  r  rq  rt  r  r  r  r  r  r  r  r  __classcell__)r   s   @r2   r7   r7   ;  s   
 _F(   ( (. 	 	 	ZZ $
  <#Z7(& , ,3PO , , - - + + - - * * ) ) ) ) M M ( (  * *76:1= I I I IV
 L L I IR R RV

  0
QX
;5W
J
UH
IN



 A A:><E;<:><;:NUD







V




<PN




S
1
B &4   




 Y0 Y0v P> P>l & & & & & & & &$ * *  0      ?3  9=
Y:x'>R. >
 ! !!N % %0 9=E ! !,& 2 2$9vAT AS AAT AS A5n C C
6//$r4   r7   c                 
   | D cg c]/  }|j                         j                         r|j                  .|1 } }g }| D ],  }|j                  |vs|j                  |j                         . |D cg c]  }||	 }}|D cg c]  }|j                   }}t        |      dk(  ry t        |      dk(  r1t        |      dk7  rt        j                  d|d    dd       |d   S t        d| d      c c}w c c}w c c}w )	Nr   r   zJCRS not set for some of the concatenation inputs. Setting output's CRS as z$ (the single non-null crs provided).r   rI   z:Cannot determine common CRS for concatenation inputs, got zH. Use `to_crs()` to transform geometries to the same CRS before merging.)	r[   rh   r@   ri   r.   rL   rN   rO   rs   )arr_seqr  
unique_crsrn   r@   crs_not_nonenamess          r2   r  r  #  s    $PbBGGIMMOrPGP J '77*$cgg&' $.ACCALA!-.#SXX.E.
<A
<Az?aMM++08* 566 	 A

DUG LQ 	Q / Q B.s   /C6C62C;:C;D c                 P   t        j                  |       }t        j                  |       }t        j                  | |    d      } ||d d df   |d d df         }t        j
                  | |    j                         t        j                  |      j                        || <   t        j                  | |   d      } ||d d df   |d d df   |d d df         }t        j
                  | |   j                         t        j                  |      j                        ||<   |S )NFrJ  r   r   Tr   )	rf   r   rV   
empty_likeget_coordinatesset_coordinatesr&  rl   T)rm   funcr   r,  r  new_coords_zcoords_zs          r2   rL  rL  C  s   MM$E]]4 F$$T5&\UCFq!tfQTl3L,,eVRXXl355FE6N &&tE{dCHAAAGL++UBHH\244F5M Mr4   r  )r  r6   )Nraiser  )@r   r   r  rN   	functoolsr   numpyrV   rH  rX   r*  r   r   r   rf   shapely.affinityshapely.geometryshapely.opsshapely.wktshapely.geometry.baser   _compatr	   r
   r   r   r   r   r   r   r   r   from_crsr  _namesPOLYGON_GEOM_TYPESLINE_GEOM_TYPESPOINT_GEOM_TYPESGeometryTyperZ   r.   type_mappingr   keysr   rl   r   rd   r   r&   rD   rS   r[   r^   rp   rv   rz   r   r   r   r   r7   r  rL  )ps   0r2   <module>r     sp                .  !"";#7#78 (".
  0 A\* 181E1EFA'F**,- rxx\%8%8%: ;6J N *  '8,*''TQ24Q2+0;fe$N e$P/@[8 Gs   !E	