
    Ch                      S SK Jr  S SKrS SKrS SKrS SKJrJr  S SKrS SK	r
S SK	JrJr  S SKrS SKJrJr  S SKJr  S SKrS SKJrJrJrJrJr  S SKJrJr  S S	KJr  S S
K J!r!  SSK"J#r#J$r$  SSK%J&r&  \$(       a  S SK'J(r(  OS SK'J)r(  \RT                  (       a   S SK+r+S SK,J-r-  S SK.r.S SK/r0S SK1J2r2  S SK3J4r4J5r5  SSS jjr6Sr7 " S S\\5      r8   S       SS jjr9\9\l:        g)    )annotationsN)AnyLiteral)	DataFrameSeries)mappingshape)BaseGeometry)GeometryArrayGeometryDtypefrom_shapelyto_wkbto_wkt)GeoPandasBaseis_geometry_type_explore)	GeoSeries   )
HAS_PYPROJPANDAS_GE_30)doc)Accessor)CachedAccessor)IterableCRS)PARQUET_GEOMETRY_ENCODINGSSUPPORTED_VERSIONS_LITERALc                   [        U 5      (       ao  [        U [        5      (       a  [        U 5      n U R                  c@  Ub=  U R                  5       n [        U [        5      (       a  Xl        U $ XR                  l        U $ [        U [        5      (       a<  [        [        R                  " U 5      US9n[        X R                  U R                  S9$ [        XS9nU$ )z
Ensure the data is of geometry dtype or converted to it.

If input is a (Geo)Series, output is a GeoSeries, otherwise output
is GeometryArray.

If the input is a GeometryDtype with a set CRS, `crs` is ignored.
crs)indexname)r   
isinstancer   r   r"   copyr   arrayr   npasarrayr#   r$   )datar"   outs      iC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geopandas/geodataframe.py_ensure_geometryr-   .   s     dF##T?D8899;D$..  "%

dF##rzz$/S9CS

CCt-CJ    zCRS mismatch between CRS of the passed geometries and 'crs'. Use 'GeoDataFrame.set_crs(crs, allow_override=True)' to overwrite CRS or 'GeoDataFrame.to_crs(crs)' to reproject geometries. c                  .  ^  \ rS rSrSrS/r\R                  S/-   r\" \5      r	Sr
 SESSS.   SFU 4S jjjjrU 4S jrSGS	 jrS
 r\" \\SS9r\R$                     SH       SIS jj5       r\R$                     SH       SJS jj5       r   SK       SLS jjr\R$                   SM     SNS jj5       r\R$                   SM     SOS jj5       rSPSQS jjr\SRS j5       r\SSS j5       r\R.                  STS j5       rSTU 4S jjr\  SU     SVS jj5       r\SWS j5       r\ SU     SXS jj5       r\       SY                 SZS jj5       r\ SU   S[S jj5       r    S\         S]S jjr\S^S j5       r  S_       S`S jjr! S_       SaS  jjr"SPSbS! jjr#ScS" jr$SS#SSS$.       SdS% jjr%     Se             SfS& jjr&   Sg       ShS' jjr'   Sg       SiS( jjr(\R$                      Sj         SkS) jj5       r)\R$                      Sj         SlS* jj5       r)    Sm         SnS+ jjr)\R$                     SH       SoS, jj5       r*\R$                     SH       SpS- jj5       r*   Sq       SrS. jjr*SsStS/ jjr+U 4S0 jr,STS1 jr-U 4S2 jr.\/" \0R                  5      SuSvU 4S3 jjj5       r1\/" \0R                  5          Sw SxU 4S4 jjj5       r2\  SyS5 j5       r3\SzS6 j5       r4SzS7 jr5\S{S8 j5       r6S{S9 jr7 SE   S|U 4S: jjjr8         S}               S~S; jjr9   S       SU 4S< jjjr:      S             SS= jjr;\<" S>\=R|                  R~                  5      r@\/" \A5      SS? j5       rB    S           SS@ jjrC      S               SSA jjrD S     SSB jjrE   S       SSC jjrFSDrGU =rH$ )GeoDataFrameS   a  A GeoDataFrame object is a pandas.DataFrame that has one or more columns
containing geometry.

In addition to the standard DataFrame constructor arguments,
GeoDataFrame also accepts the following keyword arguments:

Parameters
----------
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.
geometry : str or array-like (optional)
    Value to use as the active geometry column.
    If str, treated as column name to use. If array-like, it will be
    added as new column named 'geometry' on the GeoDataFrame and set as the
    active geometry column.

    Note that if ``geometry`` is a (Geo)Series with a
    name, the name will not be used, a column named "geometry" will still be
    added. To preserve the name, you can use :meth:`~GeoDataFrame.rename_geometry`
    to update the geometry column name.

Examples
--------
Constructing GeoDataFrame from a dictionary.

>>> from shapely.geometry import Point
>>> d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
>>> gdf = geopandas.GeoDataFrame(d, crs="EPSG:4326")
>>> gdf
    col1     geometry
0  name1  POINT (1 2)
1  name2  POINT (2 1)

Notice that the inferred dtype of 'geometry' columns is geometry.

>>> gdf.dtypes
col1          object
geometry    geometry
dtype: object

Constructing GeoDataFrame from a pandas DataFrame with a column of WKT geometries:

>>> import pandas as pd
>>> d = {'col1': ['name1', 'name2'], 'wkt': ['POINT (1 2)', 'POINT (2 1)']}
>>> df = pd.DataFrame(d)
>>> gs = geopandas.GeoSeries.from_wkt(df['wkt'])
>>> gdf = geopandas.GeoDataFrame(df, geometry=gs, crs="EPSG:4326")
>>> gdf
    col1          wkt     geometry
0  name1  POINT (1 2)  POINT (1 2)
1  name2  POINT (2 1)  POINT (2 1)

See Also
--------
GeoSeries : Series object designed to store shapely geometry objects
_geometry_column_namegeometryNr3   r"   c                 > UR                  S5      c9  [        U[        5      (       a$  [        U[        5      (       d  UR	                  SS9  Uc  SU;  a  [
        R                  " / SS9US'   [        TU ]   " U/UQ70 UD6  UcH  [        U[        5      (       a3  UR                  U l	        Ub  UR                  U:w  a  [        [        5      eUGcM  U R                  R                  S:X  Ga2  SU R                  ;   Ga!  U R                  S:H  R                  5       S:  a  [        S	5      e[!        U S   R"                  S
5      (       aQ  U S   R"                  R                  (       a3  U(       a,  U S   R"                  R                  U:X  d  [        [        5      eU S   R$                  nUS:X  dR  US:X  dL  ['        U 5      S:X  a  US:X  d7  U R(                  (       dE  U S   R+                  5       R-                  5       (       a   [/        U S   R"                  U5      U S'   SnUb  [!        US
5      (       a7  UR                  (       a&  U(       a  UR                  U:X  d  [        [        5      e[        U[
        R2                  5      (       a!  UR4                  S;  a  UR7                  S5      nU R9                  USUS9  Uc  U(       a  [        S5      eg g ! [0         a     Nf = f)Nr&   T)r&   columnsstrdtyper   r3   zYGeoDataFrame does not support multiple columns using the geometry column name 'geometry'.r"   objectr   float)r3   N)inplacer"   zAssigning CRS to a GeoDataFrame without a geometry column is not supported. Supply geometry using the 'geometry=' keyword argument, or by providing a DataFrame with column name 'geometry')getr%   r   r0   updatepdIndexsuper__init__r2   r"   
ValueErrorcrs_mismatch_errorr6   nlevelssumhasattrvaluesr9   lenemptyisnaallr-   	TypeErrorr   r$   renameset_geometry)selfr*   r3   r"   argskwargs
geom_dtype	__class__s          r,   rB   GeoDataFrame.__init__   s    JJv&4++t\22MMtM$<IV3 !#5 9F9/// 
4 > >)-)C)CD&488s? !344 $$)dll*
 
*//1A5 A  Z(//77$++//Z(//33s: !344j)//Jj()INzW'<j)9)>)>)@)D)D)F)F*'7Z8H8O8OQT'UD$
  *H%((LL + !344(BII..8== I 4 $??:6h#>J  !$3 ! s    K 
KKc                ^   > US:X  a  [         R                  XU5        g [        TU ]  X5        g )Nr3   )r:   __setattr__rA   )rP   attrvalrT   s      r,   rW   GeoDataFrame.__setattr__   s(    :t3/G*r.   c                   U R                   U ;  an  U R                   c  SnOSU R                    S3n[        U R                  U R                  S:H     5      n[	        U5      S:  a
  USU S3-  nOUS-  n[        U5      eX R                      $ )	NzqYou are calling a geospatial method on the GeoDataFrame, but the active geometry column to use has not been set. zZYou are calling a geospatial method on the GeoDataFrame, but the active geometry column ('z') is not present. r3   r   z,
There are columns with geometry data type (z), and you can either set one as the active geometry with df.set_geometry("name") or access the column as a GeoSeries (df["name"]) and call the method directly on it.z
There are no existing columns with geometry data type. You can add a geometry column as the active geometry column with df.set_geometry. )r2   listr6   dtypesrI   AttributeError)rP   msggeo_colss      r,   _get_geometryGeoDataFrame._get_geometry  s    %%T1))1O 88<8R8R7S T'' 
 DLL
)BCDH8}q CH: NQ Q ( !%%..//r.   c                    [         R                  R                  R                  U5      (       d  [	        S5      eU R                  5         U R                  USS9  g )Nz1Must use a list-like to set the geometry propertyTr<   )r?   apitypesis_list_likerC   %_persist_old_default_geometry_colnamerO   )rP   cols     r,   _set_geometryGeoDataFrame._set_geometry"  sF    vv||((--PQQ224#t,r.   zGeometry data for GeoDataFrame)fgetfsetr   c                    g N rP   ri   dropr<   r"   s        r,   rO   GeoDataFrame.set_geometry,       r.   c                    g ro   rp   rq   s        r,   rO   rs   5       r.   c                   U(       a  U nO+[         (       a  U R                  SS9nOU R                  5       nU R                  nUc  Sn[        U[        [
        -  [        R                  -  [        -  5      (       aT  U(       a  Sn[        R                  " U[        SS9  [        U[        5      (       a  UR                  b  UR                  nUnO[        US5      (       a  UR                  S	:  a  [        S
5      e XQ   n[        U["        5      (       a  [        S5      eSn	USL a  [        R                  " U	[        SS9  U(       a  XQ	 [        R                  " U	[        SS9  OUnU(       d  [%        USS5      n['        XS9n[        U[(        5      (       a  XHR*                  l        OXHl        Xel        XU'   U(       d  U$ g! [          a    [        SU 35      ef = f)a`  
Set the GeoDataFrame geometry using either an existing column or
the specified input. By default yields a new object.

The original geometry column is replaced with the input.

Parameters
----------
col : column label or array-like
    An existing column name or values to set as the new geometry column.
    If values (array-like, (Geo)Series) are passed, then if they are named
    (Series) the new geometry column will have the corresponding name,
    otherwise the existing geometry column will be replaced. If there is
    no existing geometry column, the new geometry column will use the
    default name "geometry".
drop : boolean, default False
    When specifying a named Series or an existing column name for `col`,
    controls if the previous geometry column should be dropped from the
    result. The default of False keeps both the old and new geometry column.

    .. deprecated:: 1.0.0

inplace : boolean, default False
    Modify the GeoDataFrame in place (do not create a new object)
crs : pyproj.CRS, optional
    Coordinate system to use. 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.
    If passed, overrides both DataFrame and col's crs.
    Otherwise, tries to get crs from passed col values or DataFrame.

Examples
--------
>>> from shapely.geometry import Point
>>> d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
>>> gdf = geopandas.GeoDataFrame(d, crs="EPSG:4326")
>>> gdf
    col1     geometry
0  name1  POINT (1 2)
1  name2  POINT (2 1)

Passing an array:

>>> df1 = gdf.set_geometry([Point(0,0), Point(1,1)])
>>> df1
    col1     geometry
0  name1  POINT (0 0)
1  name2  POINT (1 1)

Using existing column:

>>> gdf["buffered"] = gdf.buffer(2)
>>> df2 = gdf.set_geometry("buffered")
>>> df2.geometry
0    POLYGON ((3 2, 2.99037 1.80397, 2.96157 1.6098...
1    POLYGON ((4 1, 3.99037 0.80397, 3.96157 0.6098...
Name: buffered, dtype: geometry

Returns
-------
GeoDataFrame

See Also
--------
GeoDataFrame.rename_geometry : rename an active geometry column
FdeepNr3   zThe `drop` keyword argument is deprecated and has no effect when `col` is an array-like value. You should stop passing `drop` to `set_geometry` when this is the case.   category
stacklevelndimr   z(Must pass array with one dimension only.zUnknown column znGeoDataFrame does not support setting the geometry column where the column name is shared by multiple columns.a  The `drop` keyword argument is deprecated and in future the only supported behaviour will match drop=False. To silence this warning and adopt the future behaviour, stop providing `drop` as a keyword to `set_geometry`. To replicate the `drop=True` behaviour you should update your code to
`geo_col_name = gdf.active_geometry_name; gdf.set_geometry(new_geo_col).drop(columns=geo_col_name).rename_geometry(geo_col_name)`.r"   r!   )r   r&   r2   r%   r   r\   r(   ndarrayr   warningswarnFutureWarningr$   rG   r~   rC   KeyErrorr   getattrr-   r   r'   r"   )
rP   ri   rr   r<   r"   framegeo_column_namer_   levelgiven_colname_drop_msgs
             r,   rO   rs   >  s   T E|		u	-		44"(Oc6D=2::5EFF< 
 cMaH#v&&388+?"%((ES&!!chhlGHH:
 %++ E H # u}** 
 J**  #&%-C !0eY''!KKOI '6#!&oL i  : ?3%!899:s   <G Gc                    g ro   rp   rP   ri   r<   s      r,   rename_geometryGeoDataFrame.rename_geometry  s    
 r.   c                    g ro   rp   r   s      r,   r   r     s    
 r.   c                    U R                   R                  nXR                  ;   a  [        SU S35      eU(       d  U R	                  X10S9R                  XS9$ U R	                  X10US9  U R                  XS9  g)a  Rename the GeoDataFrame geometry column to the specified name.

By default yields a new object.

The original geometry column is replaced with the input.

Parameters
----------
col : new geometry column label
inplace : boolean, default False
    Modify the GeoDataFrame in place (do not create a new object)

Examples
--------
>>> from shapely.geometry import Point
>>> d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
>>> df = geopandas.GeoDataFrame(d, crs="EPSG:4326")
>>> df1 = df.rename_geometry('geom1')
>>> df1.geometry.name
'geom1'
>>> df.rename_geometry('geom1', inplace=True)
>>> df.geometry.name
'geom1'


See Also
--------
GeoDataFrame.set_geometry : set the active geometry
zColumn named z already exists)r6   rd   )r6   r<   N)r3   r$   r6   rC   rN   rO   )rP   ri   r<   geometry_cols       r,   r   r     s    < }})),,}SEABB{{L+>{?LL M   KK 3WKEc3r.   c                    U R                   $ )a  Return the name of the active geometry column.

Returns a name if a GeoDataFrame has an active geometry column set,
otherwise returns None. The return type is usually a string, but may be
an integer, tuple or other hashable, depending on the contents of the
dataframe columns.

You can also access the active geometry column using the
``.geometry`` property. You can set a GeoSeries to be an active geometry
using the :meth:`~GeoDataFrame.set_geometry` method.

Returns
-------
str or other index label supported by pandas
    name of an active geometry column or None

See Also
--------
GeoDataFrame.set_geometry : set the active geometry
)r2   rP   s    r,   active_geometry_name!GeoDataFrame.active_geometry_name  s    , )))r.   c                b     U R                   R                  $ ! [         a    [        S5      ef = f)a2  
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
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
--------
>>> gdf.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

See Also
--------
GeoDataFrame.set_crs : assign CRS
GeoDataFrame.to_crs : re-project to another CRS

zThe CRS attribute of a GeoDataFrame without an active geometry column is not defined. Use GeoDataFrame.set_geometry to set the active geometry column.)r3   r"   r^   r   s    r,   r"   GeoDataFrame.crs+  s9    B	==$$$ 	 5 	s    .c                   U R                   c  [        S5      e[        U R                  R                  S5      (       aB  U R
                  b  [        R                  " SS[        S9  XR                  R                  l        g[        S5      e)zSet the value of the crs.NzAssigning CRS to a GeoDataFrame without a geometry column is not supported. Use GeoDataFrame.set_geometry to set the active geometry column.r"   zOverriding the CRS of a GeoDataFrame that already has CRS. This unsafe behavior will be deprecated in future versions. Use GeoDataFrame.set_crs method insteadrz   )r}   r|   zAssigning CRS to a GeoDataFrame without an active geometry column is not supported. Use GeoDataFrame.set_geometry to set the active geometry column.)	r2   rC   rG   r3   rH   r"   r   r   DeprecationWarning)rP   values     r,   r"   r   U  s     %%-#  4==''//xx#>  !/ (-MM  $ . r.   c                  > S n[        U[        5      (       ae  SU;   a  SU;  a  UR                  SS 5      nOUR                  SS 5      nUb  [        (       d  [	        S5      eUb  SSKJn  UR                  " U5      n[        TU ]%  U5         Ub)  U R                  R                  R                  c  X l        g g g ! [         a     g f = f)Nr"   _crszxUnpickling a GeoDataFrame with CRS requires the 'pyproj' package, but it is not installed or does not import correctly. r   r   )r%   dictpopr   ImportErrorpyprojr   from_user_inputrA   __setstate__r3   rH   r"   	Exception)rP   stater"   r   rT   s       r,   r   GeoDataFrame.__setstate__q  s    eT""~&"5iit,ii-zz!M  &))#.U#
	==''++3"H 4   		s   *B; ;
CCc                >    [         R                  " U40 UD6nU " XRUS9$ )a*  Construct GeoDataFrame from dict of array-like or dicts by
overriding DataFrame.from_dict method with geometry and crs.

Parameters
----------
data : dict
    Of the form {field : array-like} or {field : dict}.
geometry : str or array (optional)
    If str, column to use as geometry. If array, will be set as 'geometry'
    column on GeoDataFrame.
crs : str or dict (optional)
    Coordinate reference system to set on the resulting frame.
kwargs : key-word arguments
    These arguments are passed to DataFrame.from_dict

Returns
-------
GeoDataFrame

r4   )r   	from_dict)clsr*   r3   r"   rR   	dataframes         r,   r   GeoDataFrame.from_dict  s&    8 ''77	9S99r.   c                X    [         R                  R                  R                  " U40 UD6$ )a  Alternate constructor to create a ``GeoDataFrame`` from a file.

It is recommended to use :func:`geopandas.read_file` instead.

Can load a ``GeoDataFrame`` from a file in any format recognized by
`pyogrio`. See http://pyogrio.readthedocs.io/ for details.

Parameters
----------
filename : str
    File path or file handle to read from. Depending on which kwargs
    are included, the content of filename may vary. See
    :func:`pyogrio.read_dataframe` for usage details.
kwargs : key-word arguments
    These arguments are passed to :func:`pyogrio.read_dataframe`, and can be
    used to access multi-layer data, data stored within archives (zip files),
    etc.

Examples
--------
>>> import geodatasets
>>> path = geodatasets.get_path('nybb')
>>> gdf = geopandas.GeoDataFrame.from_file(path)
>>> gdf  # doctest: +SKIP
   BoroCode       BoroName     Shape_Leng    Shape_Area                                           geometry
0         5  Staten Island  330470.010332  1.623820e+09  MULTIPOLYGON (((970217.022 145643.332, 970227....
1         4         Queens  896344.047763  3.045213e+09  MULTIPOLYGON (((1029606.077 156073.814, 102957...
2         3       Brooklyn  741080.523166  1.937479e+09  MULTIPOLYGON (((1021176.479 151374.797, 102100...
3         1      Manhattan  359299.096471  6.364715e+08  MULTIPOLYGON (((981219.056 188655.316, 980940....
4         2          Bronx  464392.991824  1.186925e+09  MULTIPOLYGON (((1012821.806 229228.265, 101278...

The recommended method of reading files is :func:`geopandas.read_file`:

>>> gdf = geopandas.read_file(path)

See Also
--------
read_file : read file to GeoDataFrame
GeoDataFrame.to_file : write GeoDataFrame to file

)	geopandasiofile
_read_file)r   filenamerR   s      r,   	from_fileGeoDataFrame.from_file  s%    b ||  ++H???r.   c                   [        US5      (       a  UR                  nOUn[        U[        5      (       a  UR	                  S5      S:X  a  US   nOUn/ nU Hh  n[        US5      (       a  UR                  nSUS   (       a  [        US   5      OS0nUS   n	U	c  0 n	UR                  U	5        UR                  U5        Mj     U " XcUS9$ )	a  
Alternate constructor to create GeoDataFrame from an iterable of
features or a feature collection.

Parameters
----------
features
    - Iterable of features, where each element must be a feature
      dictionary or implement the __geo_interface__.
    - Feature collection, where the 'features' key contains an
      iterable of features.
    - Object holding a feature collection that implements the
      ``__geo_interface__``.
crs : str or dict (optional)
    Coordinate reference system to set on the resulting frame.
columns : list of column names, optional
    Optionally specify the column names to include in the output frame.
    This does not overwrite the property names of the input, but can
    ensure a consistent output format.

Returns
-------
GeoDataFrame

Notes
-----
For more information about the ``__geo_interface__``, see
https://gist.github.com/sgillies/2217756

Examples
--------
>>> feature_coll = {
...     "type": "FeatureCollection",
...     "features": [
...         {
...             "id": "0",
...             "type": "Feature",
...             "properties": {"col1": "name1"},
...             "geometry": {"type": "Point", "coordinates": (1.0, 2.0)},
...             "bbox": (1.0, 2.0, 1.0, 2.0),
...         },
...         {
...             "id": "1",
...             "type": "Feature",
...             "properties": {"col1": "name2"},
...             "geometry": {"type": "Point", "coordinates": (2.0, 1.0)},
...             "bbox": (2.0, 1.0, 2.0, 1.0),
...         },
...     ],
...     "bbox": (1.0, 1.0, 2.0, 2.0),
... }
>>> df = geopandas.GeoDataFrame.from_features(feature_coll)
>>> df
      geometry   col1
0  POINT (1 2)  name1
1  POINT (2 1)  name2

__geo_interface__typeFeatureCollectionfeaturesr3   N
properties)r6   r"   )rG   r   r%   r   r=   r	   r>   append)
r   r   r"   r6   fsfeatures_lstrowsfeaturerowr   s
             r,   from_featuresGeoDataFrame.from_features  s    ~ 8011++BBb$BFF6N6I$Ij>L#L#Gw 344!33'*:ME'*"56SWC !.J!
JJz"KK $ 4c22r.   Tc
                d    [         R                  R                  R                  UUUUUUUUU	S9	n
U
$ )ab  
Alternate constructor to create a ``GeoDataFrame`` from a sql query
containing a geometry column in WKB representation.

Parameters
----------
sql : string
con : sqlalchemy.engine.Connection or sqlalchemy.engine.Engine
geom_col : string, default 'geom'
    column name to convert to shapely geometries
crs : optional
    Coordinate reference system to use for the returned GeoDataFrame
index_col : string or list of strings, optional, default: None
    Column(s) to set as index(MultiIndex)
coerce_float : boolean, default True
    Attempt to convert values of non-string, non-numeric objects (like
    decimal.Decimal) to floating point, useful for SQL result sets
parse_dates : list or dict, default None
    - List of column names to parse as dates.
    - Dict of ``{column_name: format string}`` where format string is
      strftime compatible in case of parsing string times, or is one of
      (D, s, ns, ms, us) in case of parsing integer timestamps.
    - Dict of ``{column_name: arg dict}``, where the arg dict
      corresponds to the keyword arguments of
      :func:`pandas.to_datetime`. Especially useful with databases
      without native Datetime support, such as SQLite.
params : list, tuple or dict, optional, default None
    List of parameters to pass to execute method.
chunksize : int, default None
    If specified, return an iterator where chunksize is the number
    of rows to include in each chunk.

Examples
--------
PostGIS

>>> from sqlalchemy import create_engine  # doctest: +SKIP
>>> db_connection_url = "postgresql://myusername:mypassword@myhost:5432/mydb"
>>> con = create_engine(db_connection_url)  # doctest: +SKIP
>>> sql = "SELECT geom, highway FROM roads"
>>> df = geopandas.GeoDataFrame.from_postgis(sql, con)  # doctest: +SKIP

SpatiaLite

>>> sql = "SELECT ST_Binary(geom) AS geom, highway FROM roads"
>>> df = geopandas.GeoDataFrame.from_postgis(sql, con)  # doctest: +SKIP

The recommended method of reading from PostGIS is
:func:`geopandas.read_postgis`:

>>> df = geopandas.read_postgis(sql, con)  # doctest: +SKIP

See Also
--------
geopandas.read_postgis : read PostGIS database to GeoDataFrame
)geom_colr"   	index_colcoerce_floatparse_datesparams	chunksize)r   r   sql_read_postgis)r   r   conr   r"   r   r   r   r   r   dfs              r,   from_postgisGeoDataFrame.from_postgis:  sF    J \\++%# , 

 	r.   c                    SSK Jn  U" XUS9$ )a6  
Construct a GeoDataFrame from a Arrow table object based on GeoArrow
extension types.

See https://geoarrow.org/ for details on the GeoArrow specification.

This functions accepts any tabular Arrow object implementing
the `Arrow PyCapsule Protocol`_ (i.e. having an ``__arrow_c_array__``
or ``__arrow_c_stream__`` method).

.. _Arrow PyCapsule Protocol: https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html

.. versionadded:: 1.0

Parameters
----------
table : pyarrow.Table or Arrow-compatible table
    Any tabular object implementing the Arrow PyCapsule Protocol
    (i.e. has an ``__arrow_c_array__`` or ``__arrow_c_stream__``
    method). This table should have at least one column with a
    geoarrow geometry type.
geometry : str, default None
    The name of the geometry column to set as the active geometry
    column. If None, the first geometry column found will be used.
to_pandas_kwargs : dict, optional
    Arguments passed to the `pa.Table.to_pandas` method for non-geometry
    columns. This can be used to control the behavior of the conversion of the
    non-geometry columns to a pandas DataFrame. For example, you can use this
    to control the dtype conversion of the columns. By default, the `to_pandas`
    method is called with no additional arguments.

Returns
-------
GeoDataFrame

r   )arrow_to_geopandas)r3   to_pandas_kwargs)geopandas.io._geoarrowr   )r   tabler3   r   r   s        r,   
from_arrowGeoDataFrame.from_arrow  s    P 	>!7G
 	
r.   c                   U(       a,  U R                   (       a  U R                  SS9nO[        S5      eU nUR                  XUS9nUR                   bv  UR                   R	                  S5      (       dV  U R                   R                  5       n/ SQn	Ub	  US   U	;  a  [        R                  " SS	S
9  OUu  pSU
 SU 3nSSU0S.US'   [        R                  " U40 UD6$ )a  Return a GeoJSON representation of the ``GeoDataFrame`` as a string.

Parameters
----------
na : {'null', 'drop', 'keep'}, default 'null'
    Indicates how to output missing (NaN) values in the GeoDataFrame.
    See below.
show_bbox : bool, optional, default: False
    Include bbox (bounds) in the geojson
drop_id : bool, default: False
    Whether to retain the index of the GeoDataFrame as the id property
    in the generated GeoJSON. Default is False, but may want True
    if the index is just arbitrary row numbers.
to_wgs84: bool, optional, default: False
    If the CRS is set on the active geometry column it is exported as
    WGS84 (EPSG:4326) to meet the `2016 GeoJSON specification
    <https://tools.ietf.org/html/rfc7946>`_.
    Set to True to force re-projection and set to False to ignore CRS. False by
    default.

Notes
-----
The remaining *kwargs* are passed to json.dumps().

Missing (NaN) values in the GeoDataFrame can be represented as follows:

- ``null``: output the missing entries as JSON null.
- ``drop``: remove the property from the feature. This applies to each
  feature individually so that features may have different properties.
- ``keep``: output the missing entries as NaN.

If the GeoDataFrame has a defined CRS, its definition will be included
in the output unless it is equal to WGS84 (default GeoJSON CRS) or not
possible to represent in the URN OGC format, or unless ``to_wgs84=True``
is specified.

Examples
--------
>>> from shapely.geometry import Point
>>> d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
>>> gdf = geopandas.GeoDataFrame(d, crs="EPSG:3857")
>>> gdf
    col1     geometry
0  name1  POINT (1 2)
1  name2  POINT (2 1)

>>> gdf.to_json()
'{"type": "FeatureCollection", "features": [{"id": "0", "type": "Feature", "properties": {"col1": "name1"}, "geometry": {"type": "Point", "coordinates": [1.0, 2.0]}}, {"id": "1", "type": "Feature", "properties": {"col1": "name2"}, "geometry": {"type": "Point", "coordinates": [2.0, 1.0]}}], "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:EPSG::3857"}}}'

Alternatively, you can write GeoJSON to file:

>>> gdf.to_file(path, driver="GeoJSON")  # doctest: +SKIP

See Also
--------
GeoDataFrame.to_file : write GeoDataFrame to file

i  )epsgz7CRS is not set. Cannot re-project to WGS84 (EPSG:4326).na	show_bboxdrop_idz	epsg:4326)EDCSEPSGOGCSIUCUMr   zjGeoDataFrame's CRS is not representable in URN OGC format. Resulting JSON will contain no CRS information.rz   r}   zurn:ogc:def:crs:z::r$   )r   r   r"   )
r"   to_crsrC   to_geo_dictequalsto_authorityr   r   jsondumps)rP   r   r   r   to_wgs84rR   r   geoauth_crsdefallowed_authorities	authoritycodeogc_crss                r,   to_jsonGeoDataFrame.to_json  s    L xx[[d[+ M  BnnnI 66bffmmK&@&@((//1K"G"k!n<O&ON  #.	,YKr$@&,VW<MNE
zz#(((r.   c                $    U R                  SSSS9$ )a/  Returns a ``GeoDataFrame`` as a python feature collection.

Implements the `geo_interface`. The returned python data structure
represents the ``GeoDataFrame`` as a GeoJSON-like
``FeatureCollection``.

This differs from :meth:`to_geo_dict` only in that it is a property with
default args instead of a method.

CRS of the dataframe is not passed on to the output, unlike
:meth:`~GeoDataFrame.to_json()`.

Examples
--------
>>> from shapely.geometry import Point
>>> d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
>>> gdf = geopandas.GeoDataFrame(d, crs="EPSG:4326")
>>> gdf
    col1     geometry
0  name1  POINT (1 2)
1  name2  POINT (2 1)

>>> gdf.__geo_interface__
{'type': 'FeatureCollection', 'features': [{'id': '0', 'type': 'Feature', 'properties': {'col1': 'name1'}, 'geometry': {'type': 'Point', 'coordinates': (1.0, 2.0)}, 'bbox': (1.0, 2.0, 1.0, 2.0)}, {'id': '1', 'type': 'Feature', 'properties': {'col1': 'name2'}, 'geometry': {'type': 'Point', 'coordinates': (2.0, 1.0)}, 'bbox': (2.0, 1.0, 2.0, 1.0)}], 'bbox': (1.0, 1.0, 2.0, 2.0)}
nullTFr   )r   r   s    r,   r   GeoDataFrame.__geo_interface__  s    > 6T5IIr.   c           	   #    #    US;  a  [        SU 35      eU R                  U ;  a  [        SU R                   S35      e[        R                  " U R
                  5      n[        R                  " X R                     5      nU R                  R                  (       d  [        S5      eU R                  R                  U R                  5      n[        U5      S:  Ga  X   nUR                  [        5      n[        R                  " U5      R                  nUS:X  a  SXx'   [        UR                  5       H  u  pXY   nWS	:X  a1  X   n[!        XjU5       VVVs0 s H  u  pnU(       a  M  X_M     nnnnO[#        [!        Xj5      5      nU(       a  0 nOS
[%        XI   5      0nSUS'   UUS'   U(       a  ['        U5      OSUS'   U(       a  U(       a  UR(                  OSUS'   Uv   M     g[!        XE5       Ha  u  nnU(       a  0 nOS
[%        U5      0nSUS'   0 US'   U(       a  ['        U5      OSUS'   U(       a  U(       a  UR(                  OSUS'   Uv   Mc     gs  snnnf 7f)a  Return an iterator that yields feature dictionaries that comply with
__geo_interface__.

Parameters
----------
na : str, optional
    Options are {'null', 'drop', 'keep'}, default 'null'.
    Indicates how to output missing (NaN) values in the GeoDataFrame

    - null: output the missing entries as JSON null
    - drop: remove the property from the feature. This applies to each feature individually so that features may have different properties
    - keep: output the missing entries as NaN

show_bbox : bool, optional
    Include bbox (bounds) in the geojson. Default False.
drop_id : bool, default: False
    Whether to retain the index of the GeoDataFrame as the id property
    in the generated GeoJSON. Default is False, but may want True
    if the index is just arbitrary row numbers.

Examples
--------
>>> from shapely.geometry import Point
>>> d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
>>> gdf = geopandas.GeoDataFrame(d, crs="EPSG:4326")
>>> gdf
    col1     geometry
0  name1  POINT (1 2)
1  name2  POINT (2 1)

>>> feature = next(gdf.iterfeatures())
>>> feature
{'id': '0', 'type': 'Feature', 'properties': {'col1': 'name1'}, 'geometry': {'type': 'Point', 'coordinates': (1.0, 2.0)}}
)r   rr   keepzUnknown na method z*No geometry data set (expected in column 'z').z4GeoDataFrame cannot contain duplicated column names.r   r   Nrr   idFeaturer   r   r3   bbox)rC   r2   r^   r(   r)   r#   r6   	is_uniquerr   rI   astyper:   r?   rK   rH   	enumeratezipr   r7   r   bounds)rP   r   r   r   ids
geometriesproperties_colsr   na_maskir   geomna_mask_rowkvproperties_itemsr   fids                     r,   iterfeaturesGeoDataFrame.iterfeatures@  s6    N --1"677%%T1 ../s4 
 jj$ZZ%?%? @A
||%%STT,,++D,F,FG!#"3O(//7Jggo.55GV|&*
##J$5$56!}<")*K ),O+(N((NHA"! (N % ($ (,C,E'F$ G#S[1G"+(8%7;gdm
#59dkktGFO3 78 !1	T G#SX.G"+(*%7;gdm
#59dkktGFO 2/(s   EI#I
*I
0C3I#c           	         S[        U R                  XUS95      S.nU(       a&  [        U R                  R	                  5       5      US'   U$ )a  Return a python feature collection representation of the GeoDataFrame
as a dictionary with a list of features based on the ``__geo_interface__``
GeoJSON-like specification.

Parameters
----------
na : str, optional
    Options are {'null', 'drop', 'keep'}, default 'null'.
    Indicates how to output missing (NaN) values in the GeoDataFrame

    - null: output the missing entries as JSON null
    - drop: remove the property from the feature. This applies to each feature individually so that features may have different properties
    - keep: output the missing entries as NaN

show_bbox : bool, optional
    Include bbox (bounds) in the geojson. Default False.
drop_id : bool, default: False
    Whether to retain the index of the GeoDataFrame as the id property
    in the generated dictionary. Default is False, but may want True
    if the index is just arbitrary row numbers.

Examples
--------
>>> from shapely.geometry import Point
>>> d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
>>> gdf = geopandas.GeoDataFrame(d)
>>> gdf
    col1     geometry
0  name1  POINT (1 2)
1  name2  POINT (2 1)

>>> gdf.to_geo_dict()
{'type': 'FeatureCollection', 'features': [{'id': '0', 'type': 'Feature', 'properties': {'col1': 'name1'}, 'geometry': {'type': 'Point', 'coordinates': (1.0, 2.0)}}, {'id': '1', 'type': 'Feature', 'properties': {'col1': 'name2'}, 'geometry': {'type': 'Point', 'coordinates': (2.0, 1.0)}}]}

See Also
--------
GeoDataFrame.to_json : return a GeoDataFrame as a GeoJSON string

r   r   )r   r   r   )r\   r  tupletotal_boundstolist)rP   r   r   r   r   s        r,   r   GeoDataFrame.to_geo_dict  sQ    ^ (!!Rg!N
  1 1 8 8 :;CK
r.   c                    [        U R                  5       5      nUR                  UR                  S:H      H  n[	        X4   R
                  4SU0UD6X4'   M!     U$ )aX  
Encode all geometry columns in the GeoDataFrame to WKB.

Parameters
----------
hex : bool
    If true, export the WKB as a hexadecimal string.
    The default is to return a binary bytes object.
kwargs
    Additional keyword args will be passed to
    :func:`shapely.to_wkb`.

Returns
-------
DataFrame
    geometry columns are encoded to WKB
r3   hex)r   r&   r6   r]   r   rH   )rP   r  rR   r   ri   s        r,   r   GeoDataFrame.to_wkb  sU    $ tyy{# ::bii:56CRW^^???BG 7 	r.   c                    [        U R                  5       5      nUR                  UR                  S:H      H  n[	        X#   R
                  40 UD6X#'   M     U$ )z
Encode all geometry columns in the GeoDataFrame to WKT.

Parameters
----------
kwargs
    Keyword args will be passed to :func:`shapely.to_wkt`.

Returns
-------
DataFrame
    geometry columns are encoded to WKT
r3   )r   r&   r6   r]   r   rH   )rP   rR   r   ri   s       r,   r   GeoDataFrame.to_wkt   sP     tyy{# ::bii:56CRW^^6v6BG 7 	r.   WKBr#   geometry_encodinginterleaved	include_zc               :    SSK JnJn  U" U UUUUS9u  pxU" U5      $ )a4
  Encode a GeoDataFrame to GeoArrow format.

See https://geoarrow.org/ for details on the GeoArrow specification.

This function returns a generic Arrow data object implementing
the `Arrow PyCapsule Protocol`_ (i.e. having an ``__arrow_c_stream__``
method). This object can then be consumed by your Arrow implementation
of choice that supports this protocol.

.. _Arrow PyCapsule Protocol: https://arrow.apache.org/docs/format/CDataInterface/PyCapsuleInterface.html

.. versionadded:: 1.0

Parameters
----------
index : bool, default None
    If ``True``, always include the dataframe's index(es) as columns
    in the file output.
    If ``False``, the index(es) will not be written to the file.
    If ``None``, the index(ex) will be included as columns in the file
    output except `RangeIndex` which is stored as metadata only.
geometry_encoding : {'WKB', 'geoarrow' }, default 'WKB'
    The GeoArrow encoding to use for the data conversion.
interleaved : bool, default True
    Only relevant for 'geoarrow' encoding. If True, the geometries'
    coordinates are interleaved in a single fixed size list array.
    If False, the coordinates are stored as separate arrays in a
    struct type.
include_z : bool, default None
    Only relevant for 'geoarrow' encoding (for WKB, the dimensionality
    of the individial geometries is preserved).
    If False, return 2D geometries. If True, include the third dimension
    in the output (if a geometry has no third dimension, the z-coordinates
    will be NaN). By default, will infer the dimensionality from the
    input geometries. Note that this inference can be unreliable with
    empty geometries (for a guaranteed result, it is recommended to
    specify the keyword).

Returns
-------
ArrowTable
    A generic Arrow table object with geometry columns encoded to
    GeoArrow.

Examples
--------
>>> from shapely.geometry import Point
>>> data = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
>>> gdf = geopandas.GeoDataFrame(data)
>>> gdf
    col1     geometry
0  name1  POINT (1 2)
1  name2  POINT (2 1)

>>> arrow_table = gdf.to_arrow()
>>> arrow_table
<geopandas.io._geoarrow.ArrowTable object at ...>

The returned data object needs to be consumed by a library implementing
the Arrow PyCapsule Protocol. For example, wrapping the data as a
pyarrow.Table (requires pyarrow >= 14.0):

>>> import pyarrow as pa
>>> table = pa.table(arrow_table)
>>> table
pyarrow.Table
col1: string
geometry: binary
----
col1: [["name1","name2"]]
geometry: [[0101000000000000000000F03F0000000000000040,01010000000000000000000040000000000000F03F]]

r   )
ArrowTablegeopandas_to_arrowr  )r   r  r  )	rP   r#   r  r  r  r  r  r   _s	            r,   to_arrowGeoDataFrame.to_arrow  s1    d 	J%/#
 %  r.   c           	         UR                  SS5      nUS;  a  [        SU< S35      eSSKJn	  U	" U U4UUUUUS.UD6  g	)
a%  Write a GeoDataFrame to the Parquet format.

By default, all geometry columns present are serialized to WKB format
in the file.

Requires 'pyarrow'.

.. versionadded:: 0.8

Parameters
----------
path : str, path object
index : bool, default None
    If ``True``, always include the dataframe's index(es) as columns
    in the file output.
    If ``False``, the index(es) will not be written to the file.
    If ``None``, the index(ex) will be included as columns in the file
    output except `RangeIndex` which is stored as metadata only.
compression : {'snappy', 'gzip', 'brotli', 'lz4', 'zstd', None}, default 'snappy'
    Name of the compression to use. Use ``None`` for no compression.
geometry_encoding : {'WKB', 'geoarrow'}, default 'WKB'
    The encoding to use for the geometry columns. Defaults to "WKB"
    for maximum interoperability. Specify "geoarrow" to use one of the
    native GeoArrow-based single-geometry type encodings.
    Note: the "geoarrow" option is part of the newer GeoParquet 1.1
    specification, should be considered as experimental, and may not
    be supported by all readers.
write_covering_bbox : bool, default False
    Writes the bounding box column for each row entry with column
    name 'bbox'. Writing a bbox column can be computationally
    expensive, but allows you to specify a `bbox` in :
    func:`read_parquet` for filtered reading.
    Note: this bbox column is part of the newer GeoParquet 1.1
    specification and should be considered as experimental. While
    writing the column is backwards compatible, using it for filtering
    may not be supported by all readers.
schema_version : {'0.1.0', '0.4.0', '1.0.0', '1.1.0', None}
    GeoParquet specification version; if not provided, will default to
    latest supported stable version (1.0.0).
kwargs
    Additional keyword arguments passed to :func:`pyarrow.parquet.write_table`.

Examples
--------
>>> gdf.to_parquet('data.parquet')  # doctest: +SKIP

See Also
--------
GeoDataFrame.to_feather : write GeoDataFrame to feather
GeoDataFrame.to_file : write GeoDataFrame to file
engineauto)r  pyarrowzDGeoPandas only supports using pyarrow as the engine for to_parquet: z passed instead.r   )_to_parquet)compressionr  r#   schema_versionwrite_covering_bboxN)r   rC   geopandas.io.arrowr!  )
rP   pathr#   r"  r  r$  r#  rR   r  r!  s
             r,   
to_parquetGeoDataFrame.to_parquets  sp    B Hf-,,%j(8: 
 	3		
 $/) 3		
 		
r.   c                ,    SSK Jn  U" U U4UUUS.UD6  g)a  Write a GeoDataFrame to the Feather format.

Any geometry columns present are serialized to WKB format in the file.

Requires 'pyarrow' >= 0.17.

.. versionadded:: 0.8

Parameters
----------
path : str, path object
index : bool, default None
    If ``True``, always include the dataframe's index(es) as columns
    in the file output.
    If ``False``, the index(es) will not be written to the file.
    If ``None``, the index(ex) will be included as columns in the file
    output except `RangeIndex` which is stored as metadata only.
compression : {'zstd', 'lz4', 'uncompressed'}, optional
    Name of the compression to use. Use ``"uncompressed"`` for no
    compression. By default uses LZ4 if available, otherwise uncompressed.
schema_version : {'0.1.0', '0.4.0', '1.0.0', None}
    GeoParquet specification version; if not provided will default to
    latest supported version.
kwargs
    Additional keyword arguments passed to
    :func:`pyarrow.feather.write_feather`.

Examples
--------
>>> gdf.to_feather('data.feather')  # doctest: +SKIP

See Also
--------
GeoDataFrame.to_parquet : write GeoDataFrame to parquet
GeoDataFrame.to_file : write GeoDataFrame to file
r   )_to_feather)r#   r"  r#  N)r%  r*  )rP   r&  r#   r"  r#  rR   r*  s          r,   
to_featherGeoDataFrame.to_feather  s0    X 	3	
 #)	
 	
r.   c                &    SSK Jn  U" XX#U40 UD6  g)a  Write the ``GeoDataFrame`` to a file.

By default, an ESRI shapefile is written, but any OGR data source
supported by Pyogrio or Fiona can be written. A dictionary of supported OGR
providers is available via:

>>> import pyogrio
>>> pyogrio.list_drivers()  # doctest: +SKIP

Parameters
----------
filename : string
    File path or file handle to write to. The path may specify a
    GDAL VSI scheme.
driver : string, default None
    The OGR format driver used to write the vector file.
    If not specified, it attempts to infer it from the file extension.
    If no extension is specified, it saves ESRI Shapefile to a folder.
schema : dict, default None
    If specified, the schema dictionary is passed to Fiona to
    better control how the file is written. If None, GeoPandas
    will determine the schema based on each column's dtype.
    Not supported for the "pyogrio" engine.
index : bool, default None
    If True, write index into one or more columns (for MultiIndex).
    Default None writes the index into one or more columns only if
    the index is named, is a MultiIndex, or has a non-integer data
    type. If False, no index is written.

    .. versionadded:: 0.7
        Previously the index was not written.
mode : string, default 'w'
    The write mode, 'w' to overwrite the existing file and 'a' to append.
    Not all drivers support appending. The drivers that support appending
    are listed in fiona.supported_drivers or
    https://github.com/Toblerity/Fiona/blob/master/fiona/drvsupport.py
crs : pyproj.CRS, default None
    If specified, the CRS is passed to Fiona to
    better control how the file is written. If None, GeoPandas
    will determine the crs based on crs df attribute.
    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. The keyword
    is not supported for the "pyogrio" engine.
engine : str, "pyogrio" or "fiona"
    The underlying library that is used to write the file. Currently, the
    supported options are "pyogrio" and "fiona". Defaults to "pyogrio" if
    installed, otherwise tries "fiona".
metadata : dict[str, str], default None
    Optional metadata to be stored in the file. Keys and values must be
    strings. Supported only for "GPKG" driver.
**kwargs :
    Keyword args to be passed to the engine, and can be used to write
    to multi-layer data, store data within archives (zip files), etc.
    In case of the "pyogrio" engine, the keyword arguments are passed to
    `pyogrio.write_dataframe`. In case of the "fiona" engine, the keyword
    arguments are passed to fiona.open`. For more information on possible
    keywords, type: ``import pyogrio; help(pyogrio.write_dataframe)``.

Notes
-----
The format drivers will attempt to detect the encoding of your data, but
may fail. In this case, the proper encoding can be specified explicitly
by using the encoding keyword parameter, e.g. ``encoding='utf-8'``.

See Also
--------
GeoSeries.to_file
GeoDataFrame.to_postgis : write GeoDataFrame to PostGIS database
GeoDataFrame.to_parquet : write GeoDataFrame to parquet
GeoDataFrame.to_feather : write GeoDataFrame to feather

Examples
--------
>>> gdf.to_file('dataframe.shp')  # doctest: +SKIP

>>> gdf.to_file('dataframe.gpkg', driver='GPKG', layer='name')  # doctest: +SKIP

>>> gdf.to_file('dataframe.geojson', driver='GeoJSON')  # doctest: +SKIP

With selected drivers you can also append to a file with `mode="a"`:

>>> gdf.to_file('dataframe.shp', mode="a")  # doctest: +SKIP

Using the engine-specific keyword arguments it is possible to e.g. create a
spatialite file with a custom layer name:

>>> gdf.to_file(
...     'dataframe.sqlite', driver='SQLite', spatialite=True, layer='test'
... )  # doctest: +SKIP

r   )_to_fileN)geopandas.io.filer.  )rP   r   driverschemar#   rR   r.  s          r,   to_fileGeoDataFrame.to_file  s    H 	/A&Ar.   c                    g ro   rp   rP   r"   r   r<   allow_overrides        r,   set_crsGeoDataFrame.set_crsg  rt   r.   c                    g ro   rp   r5  s        r,   r7  r8  p  rv   r.   c                z    U(       d  U R                  5       nOU nUR                  R                  XUSS9Ul        U$ )u  
Set the Coordinate Reference System (CRS) of the ``GeoDataFrame``.

If there are multiple geometry columns within the GeoDataFrame, only
the CRS of the active geometry column is set.

Pass ``None`` to remove CRS from the active geometry column.

Notes
-----
The underlying geometries are not transformed to this CRS. To
transform the geometries to a new CRS, use the ``to_crs`` method.

Parameters
----------
crs : pyproj.CRS | None, optional
    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
    EPSG code specifying the projection.
inplace : bool, default False
    If True, the CRS of the GeoDataFrame will be changed in place
    (while still returning the result) instead of making a copy of
    the GeoDataFrame.
allow_override : bool, default False
    If the the GeoDataFrame already has a CRS, allow to replace the
    existing CRS, even when both are not equal.

Examples
--------
>>> from shapely.geometry import Point
>>> d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
>>> gdf = geopandas.GeoDataFrame(d)
>>> gdf
    col1     geometry
0  name1  POINT (1 2)
1  name2  POINT (2 1)

Setting CRS to a GeoDataFrame without one:

>>> gdf.crs is None
True

>>> gdf = gdf.set_crs('epsg:3857')
>>> gdf.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

Overriding existing CRS:

>>> gdf = gdf.set_crs(4326, allow_override=True)

Without ``allow_override=True``, ``set_crs`` returns an error if you try to
override CRS.

See Also
--------
GeoDataFrame.to_crs : re-project to another CRS

T)r"   r   r6  r<   )r&   r3   r7  )rP   r"   r   r<   r6  r   s         r,   r7  r8  y  sA    ` BBkk))~t * 
 	r.   c                    g ro   rp   rP   r"   r   r<   s       r,   r   GeoDataFrame.to_crs  s     r.   c                    g ro   rp   r<  s       r,   r   r=    s     r.   c                    U(       a  U nOU R                  5       nUR                  R                  XS9nXTl        U(       d  U$ g)u	  Transform geometries to a new coordinate reference system.

Transform all geometries in an active geometry column to a different coordinate
reference system.  The ``crs`` attribute on the current GeoSeries 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.
inplace : bool, optional, default: False
    Whether to return a new GeoDataFrame or do the transformation in
    place.

Returns
-------
GeoDataFrame

Examples
--------
>>> from shapely.geometry import Point
>>> d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
>>> gdf = geopandas.GeoDataFrame(d, crs=4326)
>>> gdf
    col1     geometry
0  name1  POINT (1 2)
1  name2  POINT (2 1)
>>> gdf.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

>>> gdf = gdf.to_crs(3857)
>>> gdf
    col1                       geometry
0  name1  POINT (111319.491 222684.209)
1  name2  POINT (222638.982 111325.143)
>>> gdf.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

See Also
--------
GeoDataFrame.set_crs : assign CRS without re-projection
)r"   r   N)r&   r3   r   )rP   r"   r   r<   r   r   s         r,   r   r=    sA    b BB{{!!c!5I r.   c                4    U R                   R                  US9$ )uM  Return the estimated UTM CRS based on the bounds of the dataset.

.. versionadded:: 0.9

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_health")
... )
>>> df.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
)
datum_name)r3   estimate_utm_crs)rP   rA  s     r,   rB  GeoDataFrame.estimate_utm_crs<  s    H }}---DDr.   c                  > [         TU ]  U5      n[        R                  R                  R                  U5      (       a  US:X  a  [        U R                  [        R                  5      (       a`  [        U[        5      (       aK  [        U5      (       d;  U R                  R                  U5      nU R                  SS2U4   R                  SS9nU R                  n[        U[        5      (       a,  [        UR                  [         5      (       a  ["        Ul        U$ [        U[&        5      (       aI  UR(                  S:H  R+                  5       S:  a  [-        U 5      Ul        XB;   a  XBl        U$ [&        Ul        U$ )z
If the result is a column containing only 'geometry', return a
GeoSeries. If it's a DataFrame with any columns of GeometryDtype,
return a GeoDataFrame.
 Nr6   axisr3   r   )rA   __getitem__r?   re   rf   	is_scalarr%   r6   
MultiIndexr   r   get_locilocsqueezer2   r9   r   r   rT   r   r]   rF   r   )rP   keyresultlocgeo_colrT   s        r,   rH  GeoDataFrame.__getitem__b  s%    $S) FFLL""3''r	4<<7766**$V,,,,&&s+CYYq#v&..I.>F,,ff%%*V\\=*Q*Q(F  	**+002Q6#': $3:0  $- r.   c                    U R                   c5  SU R                  ;  a$  Sn[        R                  " U[        SS9  SU l         ggg)z`Persist the default geometry column name of 'geometry' temporarily for
backwards compatibility.
Nr3   a  You are adding a column named 'geometry' to a GeoDataFrame constructed without an active geometry column. Currently, this automatically sets the active geometry column to 'geometry' but in the future that will no longer happen. Instead, either provide geometry to the GeoDataFrame constructor (GeoDataFrame(... geometry=GeoSeries()) or use `set_geometry('geometry')` to explicitly set the active geometry column.   r{   )r2   r6   r   r   r   )rP   r_   s     r,   rh   2GeoDataFrame._persist_old_default_geometry_colname  sI    
 %%-*DLL2P@  MM#!D)3D& 3Q-r.   c                x  > [         R                  R                  R                  U5      (       d  XR                  :X  d  US:X  a  U R                  c  [         R                  R                  R                  U5      (       d  [        U[        5      (       a  U/U R                  S   -  n[        U SS5      n[        U[         R                  [         R                  -  5      (       a  Sn [        X#S9nUS:X  a  U R                  5         ["        TU ]I  X5        g! [         a    [        R                   " SSS9   N1f = f)	zzOverridden to preserve CRS of GeometryArray.

Important for cases like
df['geometry'] = [geom... for geom in df.geometry]
r3   Nr   r"   r!   z*Geometry column does not contain geometry.rz   r   )r?   re   rf   rg   r2   rI  r%   r
   r	   r   r   r   r-   rh   rM   r   r   rA   __setitem__)rP   rN  r   r"   rT   s       r,   rW  GeoDataFrame.__setitem__  s     vv||((-----z!d&@&@&Hvv||%%e,,
5,0O0O$**Q-/$t,C #ryy2<<788	A(8 *$>>@C'  @ s   (	D D98D9c                   > [         TU ]  US9n[        U5      [        R                  L a!  [        U 5      Ul        U R                  Ul        U$ )Nrx   )rA   r&   r   r?   r   rT   r2   )rP   ry   copiedrT   s      r,   r&   GeoDataFrame.copy  sB    4(<2<<'#DzF+/+E+EF(r.   c                V  > [         TU ]  " U4X#XES.UD6n[        U[        5      (       al  U R                  UR
                  ;   aR   UR                  U R                  5      nU R                  b'  UR                  c  UR                  U R                  SS9  U$ [        U[        5      (       aA  UR                  S:X  a1  UR                  5       R                  5       (       d   [        U5      nU$ U$ ! [         a     U$ f = f! [        [        R                   R"                  4 a     U$ f = f)N)rG  rawresult_typerQ   Trd   r:   )rA   applyr%   r   r2   r6   rO   r"   r7  rM   r   r9   rK   rL   r-   shapelyerrorsGeometryTypeError)	rP   funcrG  r]  r^  rQ   rR   rO  rT   s	           r,   r_  GeoDataFrame.apply  s!    
+
LR

 vy))**fnn<;,,T-G-GH 88'FJJ,>NN488TN:  ''FLLH,D ;;=$$&&-f5F
 v#    # "7>>#C#CD s$   C/  D  /
C=<C= $D('D(c                    U " U0 UD6nUR                   S:H  n[        U5      S:X  d  UR                  5       S:X  a  [        R                  " U5      nU$ )zA flexible constructor for GeoDataFrame._constructor, which falls back
to returning a DataFrame (if a certain operation does not preserve the
geometry column).
r3   r   )r]   rI   rF   r?   r   )r   rQ   rR   r   geometry_cols_masks        r,   '_geodataframe_constructor_with_fallback4GeoDataFrame._geodataframe_constructor_with_fallback  sT     $!&!YY*4!"a'+=+A+A+Cq+Hb!B	r.   c                    U R                   $ ro   )rg  r   s    r,   _constructorGeoDataFrame._constructor  s    ;;;r.   c                   [        S UR                   5       5      (       d.  U R                  [        R                  R                  X5      5      $ U R                  X5      nUR                  S:H  R                  5       S:X  a  SUl        U$ )Nc              3  V   #    U  H  n[        UR                  [        5      v   M!     g 7fro   )r%   r9   r   ).0blocks     r,   	<genexpr>5GeoDataFrame._constructor_from_mgr.<locals>.<genexpr>  s     Rze:ekk=99zs   ')r3   r   )	anyblocksrg  r?   r   	_from_mgrr6   rF   r2   )rP   mgraxesgdfs       r,   _constructor_from_mgr"GeoDataFrame._constructor_from_mgr  sw     RszzRRR??&&s1  nnS' KK:%**,1(2C%
r.   c                   ^  U 4S jnU$ )Nc                    > [         R                  " U 0 UD6nUR                  R                  TR                  5      n[        U5      (       a  U(       d  [        U5      nU$ )a  A specialized (Geo)Series constructor which can fall back to a
Series if a certain operation does not produce geometries.

Note:

- We only return a GeoSeries if the data is actually of geometry
  dtype (and so we don't try to convert geometry objects such as
  the normal GeoSeries(..) constructor does with `_ensure_geometry`).
- When we get here from obtaining a row or column from a
  GeoDataFrame, the goal is to only return a GeoSeries for a
  geometry column, and not return a GeoSeries for a row that happened
  to come from a DataFrame with only geometry dtype columns (and
  thus could have a geometry dtype). Therefore, we don't return a
  GeoSeries if we are sure we are in a row selection case (by
  checking the identity of the index)
)r?   r   r#   is_r6   r   r   )rQ   rR   srsis_row_proxyrP   s       r,    _geodataframe_constructor_slicedJGeoDataFrame._constructor_sliced.<locals>._geodataframe_constructor_sliced
  sI    " ))T,V,C99==6L$$\nJr.   rp   )rP   r  s   ` r,   _constructor_sliced GeoDataFrame._constructor_sliced  s    	. 0/r.   c                
   UR                   R                  U R                  5      n[        UR                  S   R
                  [        5      (       a  U(       d  [        R                  " X5      $ [        R                  " X5      $ )Nr   )
r#   r|  r6   r%   rs  r9   r   r   rt  r   )rP   ru  rv  r~  s       r,   _constructor_sliced_from_mgr)GeoDataFrame._constructor_sliced_from_mgr#  sW    yy}}T\\2cjjm))=99,&&s11**r.   c           
       > [         TU ]  " U4SU0UD6n US:X  a@  U R                   H.  n[        R	                  X[        UR                  US5      5        M0     U $ US:X  a  U R                   H1  n[        R	                  X[        UR                  S   US5      5        M3     U R                  R                  S:X  a+  U R                  U R                  :H  R                  5       S:  dT  U R                  R                  S:  aS  U R                  R                  S5      U R                  :H  R                  5       S:  a  [        SU R                   S35      eU $ US	:X  a  SU l
        SU l        U $ )
z&Propagate metadata from other to self.methodmergeNconcatr   r   zRConcat operation has resulted in multiple columns using the geometry column name 'zF'.
Please ensure this column from the first DataFrame is not repeated.unstack)rA   __finalize__	_metadatar:   rW   r   leftobjsr6   rE   r2   rF   get_level_valuesrC   r   )rP   otherr  rR   r$   rT   s        r,   r  GeoDataFrame.__finalize__*  sW    w#EC&CFC W""4wuzz4/NO '8 3 x""4wuzz!}dD/QR ' $$)\\T%?%??DDFJ$$q(LL11!48R8RR#%
 !1151K1K0L M     y  *.D&DIr.   c
                \  ^^	 Uc!  Uc  [         R                  " [        U 5      SS9nUUUUUS.nU R                  U R                  R
                  SS9nUR                  " S
0 UD6R                  " U40 U
D6nUR                  R                  5       Ul        U	U4S jnU R                  " S
SS0UD6U R                  R
                     R                  U5      n[        U 5      " XR                  R
                  U R                  S	9nUR                  U5      nU(       d  UR                  5       nU$ )a  
Dissolve geometries within `groupby` into single observation.
This is accomplished by applying the `union_all` method
to all geometries within a groupself.

Observations associated with each `groupby` group will be aggregated
using the `aggfunc`.

Parameters
----------
by : str or list-like, default None
    Column(s) whose values define the groups to be dissolved. If None,
    the entire GeoDataFrame is considered as a single group. If a list-like
    object is provided, the values in the list are treated as categorical
    labels, and polygons will be combined based on the equality of
    these categorical labels.
aggfunc : function or string, default "first"
    Aggregation function for manipulation of data associated
    with each group. Passed to pandas `groupby.agg` method.
    Accepted combinations are:

    - function
    - string function name
    - list of functions and/or function names, e.g. [np.sum, 'mean']
    - dict of axis labels -> functions, function names or list of such.
as_index : boolean, default True
    If true, groupby columns become index of result.
level : int or str or sequence of int or sequence of str, default None
    If the axis is a MultiIndex (hierarchical), group by a
    particular level or levels.
sort : bool, default True
    Sort group keys. Get better performance by turning this off.
    Note this does not influence the order of observations within
    each group. Groupby preserves the order of rows within each group.
observed : bool, default False
    This only applies if any of the groupers are Categoricals.
    If True: only show observed values for categorical groupers.
    If False: show all values for categorical groupers.
dropna : bool, default True
    If True, and if group keys contain NA values, NA values
    together with row/column will be dropped. If False, NA
    values will also be treated as the key in groups.
method : str (default ``"unary"``)
    The method to use for the union. Options are:

    * ``"unary"``: use the unary union algorithm. This option is the most robust
      but can be slow for large numbers of geometries (default).
    * ``"coverage"``: use the coverage union algorithm. This option is optimized
      for non-overlapping polygons and can be significantly faster than the
      unary union algorithm. However, it can produce invalid geometries if the
      polygons overlap.
    * ``"disjoint_subset:``: use the disjoint subset union algorithm. This
      option is optimized for inputs that can be divided into subsets that do
      not intersect. If there is only one such subset, performance can be
      expected to be worse than ``"unary"``.  Requires Shapely >= 2.1.


grid_size : float, default None
    When grid size is specified, a fixed-precision space is used to perform the
    union operations. This can be useful when unioning geometries that are not
    perfectly snapped or to avoid geometries not being unioned because of
    `robustness issues <https://libgeos.org/usage/faq/#why-doesnt-a-computed-point-lie-exactly-on-a-line>`_.
    The inputs are first snapped to a grid of the given size. When a line
    segment of a geometry is within tolerance off a vertex of another geometry,
    this vertex will be inserted in the line segment. Finally, the result
    vertices are computed on the same grid. Is only supported for ``method``
    ``"unary"``. If None, the highest precision of the inputs will be used.
    Defaults to None.

    .. versionadded:: 1.1.0
**kwargs :
    Keyword arguments to be passed to the pandas `DataFrameGroupby.agg` method
    which is used by `dissolve`. In particular, `numeric_only` may be
    supplied, which will be required in pandas 2.0 for certain aggfuncs.

    .. versionadded:: 0.13.0

Returns
-------
GeoDataFrame

Examples
--------
>>> from shapely.geometry import Point
>>> d = {
...     "col1": ["name1", "name2", "name1"],
...     "geometry": [Point(1, 2), Point(2, 1), Point(0, 1)],
... }
>>> gdf = geopandas.GeoDataFrame(d, crs=4326)
>>> gdf
    col1     geometry
0  name1  POINT (1 2)
1  name2  POINT (2 1)
2  name1  POINT (0 1)

>>> dissolved = gdf.dissolve('col1')
>>> dissolved  # doctest: +SKIP
                        geometry
col1
name1  MULTIPOINT ((0 1), (1 2))
name2                POINT (2 1)

See Also
--------
GeoDataFrame.explode : explode multi-part geometries into single geometries

int64r8   )byr   sortobserveddropnar   )labelsrG  c                (   > U R                  TTS9nU$ )N)r  	grid_size)	union_all)ro  merged_geomr  r  s     r,   merge_geometries/GeoDataFrame.dissolve.<locals>.merge_geometries  s    //9/MKr.   
group_keysFr4   rp   )r(   zerosrI   rr   r3   r$   groupbyaggr6   to_flat_indexr   r"   joinreset_index)rP   r  aggfuncas_indexr   r  r  r  r  r  rR   groupby_kwargsr*   aggregated_datar  gaggregated_geometry
aggregateds           ``        r,   dissolveGeoDataFrame.dissolveP  s   p :%-#d)73B  
 yy 2 2y;,,88<<WOO"1"9"9"G"G"I	 LL<E<^<T]]=O=OPTT

 #4j]]5G5GTXXV(--o>
 #//1Jr.   c           
       > Uc  U R                   R                  n[        X   R                  [        5      (       d  [
        TU ]  " U4SU0UD6$ U R                   R                  SS9R                  SS9nU R                  U R                  SS9R                  UR                  R                  S5      5      nUR                  XeR                  '   UR                  U R                  5      R                  U 5      nU(       a  UR                  SSS9  U$ U(       aR  UR!                  UR                  R                  [#        [%        UR                  R&                  S-
  5      5      5      SS	9nU$ )
u  
Explode multi-part geometries into multiple single geometries.

Each row containing a multi-part geometry will be split into
multiple rows with single geometries, thereby increasing the vertical
size of the GeoDataFrame.

Parameters
----------
column : string, default None
    Column to explode. In the case of a geometry column, multi-part
    geometries are converted to single-part.
    If None, the active geometry column is used.
ignore_index : bool, default False
    If True, the resulting index will be labelled 0, 1, …, n - 1,
    ignoring `index_parts`.
index_parts : boolean, default False
    If True, the resulting index will be a multi-index (original
    index with an additional level indicating the multiple
    geometries: a new zero-based index for each single part geometry
    per multi-part geometry).

Returns
-------
GeoDataFrame
    Exploded geodataframe with each single geometry
    as a separate entry in the geodataframe.

Examples
--------
>>> from shapely.geometry import MultiPoint
>>> d = {
...     "col1": ["name1", "name2"],
...     "geometry": [
...         MultiPoint([(1, 2), (3, 4)]),
...         MultiPoint([(2, 1), (0, 0)]),
...     ],
... }
>>> gdf = geopandas.GeoDataFrame(d, crs=4326)
>>> gdf
    col1               geometry
0  name1  MULTIPOINT ((1 2), (3 4))
1  name2  MULTIPOINT ((2 1), (0 0))

>>> exploded = gdf.explode(index_parts=True)
>>> exploded
      col1     geometry
0 0  name1  POINT (1 2)
  1  name1  POINT (3 4)
1 0  name2  POINT (2 1)
  1  name2  POINT (0 0)

>>> exploded = gdf.explode(index_parts=False)
>>> exploded
    col1     geometry
0  name1  POINT (1 2)
0  name1  POINT (3 4)
1  name2  POINT (2 1)
1  name2  POINT (0 0)

>>> exploded = gdf.explode(ignore_index=True)
>>> exploded
    col1     geometry
0  name1  POINT (1 2)
1  name1  POINT (3 4)
2  name2  POINT (2 1)
3  name2  POINT (0 0)

See Also
--------
GeoDataFrame.dissolve : dissolve geometries into a single observation.

ignore_indexT)rr   )index_partsr   rF  )r<   rr   )r   )r3   r$   r%   r9   r   rA   exploder  rr   r2   taker#   	droplevelrH   rO   r  	set_indexr\   rangerE   )rP   columnr  r  rR   exploded_geomr   rT   s          r,   r  GeoDataFrame.explode  sL   b >]]''F$,,,m<<7?6OOOO11t1<DDQUDVYYt11Y:??))"-
 "/!5!5__T778EEdKNN4dN3 	  ##--}22::Q>?@ 	  B 	r.   c	                ^    [         R                  R                  R                  XX#XEXgU5	        g)a  
Upload GeoDataFrame into PostGIS database.

This method requires SQLAlchemy and GeoAlchemy2, and a PostgreSQL
Python driver (psycopg or psycopg2) to be installed.

It is also possible to use :meth:`~GeoDataFrame.to_file` to write to a database.
Especially for file geodatabases like GeoPackage or SpatiaLite this can be
easier.

Parameters
----------
name : str
    Name of the target table.
con : sqlalchemy.engine.Connection or sqlalchemy.engine.Engine
    Active connection to the PostGIS database.
if_exists : {'fail', 'replace', 'append'}, default 'fail'
    How to behave if the table already exists:

    - fail: Raise a ValueError.
    - replace: Drop the table before inserting new values.
    - append: Insert new values to the existing table.
schema : string, optional
    Specify the schema. If None, use default schema: 'public'.
index : bool, default False
    Write DataFrame index as a column.
    Uses *index_label* as the column name in the table.
index_label : string or sequence, default None
    Column label for index column(s).
    If None is given (default) and index is True,
    then the index names are used.
chunksize : int, optional
    Rows will be written in batches of this size at a time.
    By default, all rows will be written at once.
dtype : dict of column name to SQL type, default None
    Specifying the datatype for columns.
    The keys should be the column names and the values
    should be the SQLAlchemy types.

Examples
--------
>>> from sqlalchemy import create_engine
>>> engine = create_engine("postgresql://myusername:mypassword@myhost:5432/mydatabase")  # doctest: +SKIP
>>> gdf.to_postgis("my_table", engine)  # doctest: +SKIP

See Also
--------
GeoDataFrame.to_file : write GeoDataFrame to file
read_postgis : read PostGIS database to GeoDataFrame

N)r   r   r   _write_postgis)	rP   r$   r   r1  	if_existsr#   index_labelr   r9   s	            r,   
to_postgisGeoDataFrame.to_postgis[	  s(    ~ 	''Y{u	
r.   plotc                     [        U /UQ70 UD6$ ro   r   )rP   rQ   rR   s      r,   exploreGeoDataFrame.explore	  s    .t.v..r.   c           
     <    [         R                  " SU UUUUUS.UD6$ )a  Spatial join of two GeoDataFrames.

See the User Guide page :doc:`../../user_guide/mergingdata` for details.

Parameters
----------
df : GeoDataFrame
how : string, default 'inner'
    The type of join:

    * 'left': use keys from left_df; retain only left_df geometry column
    * 'right': use keys from right_df; retain only right_df geometry column
    * 'inner': use intersection of keys from both dfs; retain only
      left_df geometry column

predicate : string, default 'intersects'
    Binary predicate. Valid values are determined by the spatial index used.
    You can check the valid values in left_df or right_df as
    ``left_df.sindex.valid_query_predicates`` or
    ``right_df.sindex.valid_query_predicates``
lsuffix : string, default 'left'
    Suffix to apply to overlapping column names (left GeoDataFrame).
rsuffix : string, default 'right'
    Suffix to apply to overlapping column names (right GeoDataFrame).
distance : number or array_like, optional
    Distance(s) around each input geometry within which to query the tree
    for the 'dwithin' predicate. If array_like, must be
    one-dimesional with length equal to length of left GeoDataFrame.
    Required if ``predicate='dwithin'``.
on_attribute : string, list or tuple
    Column name(s) to join on as an additional join restriction on top
    of the spatial predicate. These must be found in both DataFrames.
    If set, observations are joined only if the predicate applies
    and values in specified columns match.

Examples
--------
>>> import geodatasets
>>> chicago = geopandas.read_file(
...     geodatasets.get_path("geoda.chicago_commpop")
... )
>>> groceries = geopandas.read_file(
...     geodatasets.get_path("geoda.groceries")
... ).to_crs(chicago.crs)

>>> chicago.head()  # doctest: +SKIP
         community  ...                                           geometry
0          DOUGLAS  ...  MULTIPOLYGON (((-87.60914 41.84469, -87.60915 ...
1          OAKLAND  ...  MULTIPOLYGON (((-87.59215 41.81693, -87.59231 ...
2      FULLER PARK  ...  MULTIPOLYGON (((-87.62880 41.80189, -87.62879 ...
3  GRAND BOULEVARD  ...  MULTIPOLYGON (((-87.60671 41.81681, -87.60670 ...
4          KENWOOD  ...  MULTIPOLYGON (((-87.59215 41.81693, -87.59215 ...

[5 rows x 9 columns]

>>> groceries.head()  # doctest: +SKIP
   OBJECTID     Ycoord  ...  Category                           geometry
0        16  41.973266  ...       NaN  MULTIPOINT ((-87.65661 41.97321))
1        18  41.696367  ...       NaN  MULTIPOINT ((-87.68136 41.69713))
2        22  41.868634  ...       NaN  MULTIPOINT ((-87.63918 41.86847))
3        23  41.877590  ...       new  MULTIPOINT ((-87.65495 41.87783))
4        27  41.737696  ...       NaN  MULTIPOINT ((-87.62715 41.73623))
[5 rows x 8 columns]

>>> groceries_w_communities = groceries.sjoin(chicago)
>>> groceries_w_communities[["OBJECTID", "community", "geometry"]].head()
   OBJECTID       community                           geometry
0        16          UPTOWN  MULTIPOINT ((-87.65661 41.97321))
1        18     MORGAN PARK  MULTIPOINT ((-87.68136 41.69713))
2        22  NEAR WEST SIDE  MULTIPOINT ((-87.63918 41.86847))
3        23  NEAR WEST SIDE  MULTIPOINT ((-87.65495 41.87783))
4        27         CHATHAM  MULTIPOINT ((-87.62715 41.73623))

Notes
-----
Every operation in GeoPandas is planar, i.e. the potential third
dimension is not taken into account.

See Also
--------
GeoDataFrame.sjoin_nearest : nearest neighbor join
sjoin : equivalent top-level function
)left_dfright_dfhow	predicatelsuffixrsuffixrp   )r   sjoin)rP   r   r  r  r  r  rR   s          r,   r  GeoDataFrame.sjoin	  s7    x  

 
 	
r.   c                8    [         R                  " U UUUUUUUS9$ )a  
Spatial join of two GeoDataFrames based on the distance between their
geometries.

Results will include multiple output records for a single input record
where there are multiple equidistant nearest or intersected neighbors.

See the User Guide page
https://geopandas.readthedocs.io/en/latest/docs/user_guide/mergingdata.html
for more details.


Parameters
----------
right : GeoDataFrame
how : string, default 'inner'
    The type of join:

    * 'left': use keys from left_df; retain only left_df geometry column
    * 'right': use keys from right_df; retain only right_df geometry column
    * 'inner': use intersection of keys from both dfs; retain only
      left_df geometry column

max_distance : float, default None
    Maximum distance within which to query for nearest geometry.
    Must be greater than 0.
    The max_distance used to search for nearest items in the tree may have a
    significant impact on performance by reducing the number of input
    geometries that are evaluated for nearest items in the tree.
lsuffix : string, default 'left'
    Suffix to apply to overlapping column names (left GeoDataFrame).
rsuffix : string, default 'right'
    Suffix to apply to overlapping column names (right GeoDataFrame).
distance_col : string, default None
    If set, save the distances computed between matching geometries under a
    column of this name in the joined GeoDataFrame.
exclusive : bool, optional, default False
    If True, the nearest geometries that are equal to the input geometry
    will not be returned, default False.

Examples
--------
>>> import geodatasets
>>> groceries = geopandas.read_file(
...     geodatasets.get_path("geoda.groceries")
... )
>>> chicago = geopandas.read_file(
...     geodatasets.get_path("geoda.chicago_health")
... ).to_crs(groceries.crs)

>>> chicago.head()  # doctest: +SKIP
   ComAreaID  ...                                           geometry
0         35  ...  POLYGON ((-87.60914 41.84469, -87.60915 41.844...
1         36  ...  POLYGON ((-87.59215 41.81693, -87.59231 41.816...
2         37  ...  POLYGON ((-87.62880 41.80189, -87.62879 41.801...
3         38  ...  POLYGON ((-87.60671 41.81681, -87.60670 41.816...
4         39  ...  POLYGON ((-87.59215 41.81693, -87.59215 41.816...
[5 rows x 87 columns]

>>> groceries.head()  # doctest: +SKIP
   OBJECTID     Ycoord  ...  Category                           geometry
0        16  41.973266  ...       NaN  MULTIPOINT ((-87.65661 41.97321))
1        18  41.696367  ...       NaN  MULTIPOINT ((-87.68136 41.69713))
2        22  41.868634  ...       NaN  MULTIPOINT ((-87.63918 41.86847))
3        23  41.877590  ...       new  MULTIPOINT ((-87.65495 41.87783))
4        27  41.737696  ...       NaN  MULTIPOINT ((-87.62715 41.73623))
[5 rows x 8 columns]

>>> groceries_w_communities = groceries.sjoin_nearest(chicago)
>>> groceries_w_communities[["Chain", "community", "geometry"]].head(2)
               Chain    community                                geometry
0     VIET HOA PLAZA       UPTOWN   MULTIPOINT ((1168268.672 1933554.35))
1  COUNTY FAIR FOODS  MORGAN PARK  MULTIPOINT ((1162302.618 1832900.224))


To include the distances:

>>> groceries_w_communities = groceries.sjoin_nearest(chicago, distance_col="distances")
>>> groceries_w_communities[["Chain", "community", "distances"]].head(2)
               Chain    community  distances
0     VIET HOA PLAZA       UPTOWN        0.0
1  COUNTY FAIR FOODS  MORGAN PARK        0.0

In the following example, we get multiple groceries for Uptown because all
results are equidistant (in this case zero because they intersect).
In fact, we get 4 results in total:

>>> chicago_w_groceries = groceries.sjoin_nearest(chicago, distance_col="distances", how="right")
>>> uptown_results = chicago_w_groceries[chicago_w_groceries["community"] == "UPTOWN"]
>>> uptown_results[["Chain", "community"]]
            Chain community
30  VIET HOA PLAZA    UPTOWN
30      JEWEL OSCO    UPTOWN
30          TARGET    UPTOWN
30       Mariano's    UPTOWN

See Also
--------
GeoDataFrame.sjoin : binary predicate joins
sjoin_nearest : equivalent top-level function

Notes
-----
Since this join relies on distances, results will be inaccurate
if your geometries are in a geographic CRS.

Every operation in GeoPandas is planar, i.e. the potential third
dimension is not taken into account.
)r  max_distancer  r  distance_col	exclusive)r   sjoin_nearest)rP   rightr  r  r  r  r  r  s           r,   r  GeoDataFrame.sjoin_nearest

  s0    v &&%%	
 		
r.   c                ,    [         R                  " XX#S9$ )a  Clip points, lines, or polygon geometries to the mask extent.

Both layers must be in the same Coordinate Reference System (CRS).
The GeoDataFrame will be clipped to the full extent of the ``mask`` object.

If there are multiple polygons in mask, data from the GeoDataFrame will be
clipped to the total boundary of all polygons in mask.

Parameters
----------
mask : GeoDataFrame, GeoSeries, (Multi)Polygon, list-like
    Polygon vector layer used to clip the GeoDataFrame.
    The mask's geometry is dissolved into one geometric feature
    and intersected with GeoDataFrame.
    If the mask is list-like with four elements ``(minx, miny, maxx, maxy)``,
    ``clip`` will use a faster rectangle clipping
    (:meth:`~GeoSeries.clip_by_rect`), possibly leading to slightly different
    results.
keep_geom_type : boolean, default False
    If True, return only geometries of original type in case of intersection
    resulting in multiple geometry types or GeometryCollections.
    If False, return all resulting geometries (potentially mixed types).
sort : boolean, default False
    If True, the order of rows in the clipped GeoDataFrame will be preserved at
    small performance cost. If False the order of rows in the clipped
    GeoDataFrame will be random.

Returns
-------
GeoDataFrame
    Vector data (points, lines, polygons) from the GeoDataFrame clipped to
    polygon boundary from mask.

See Also
--------
clip : equivalent top-level function

Examples
--------
Clip points (grocery stores) with polygons (the Near West Side community):

>>> import geodatasets
>>> chicago = geopandas.read_file(
...     geodatasets.get_path("geoda.chicago_health")
... )
>>> near_west_side = chicago[chicago["community"] == "NEAR WEST SIDE"]
>>> groceries = geopandas.read_file(
...     geodatasets.get_path("geoda.groceries")
... ).to_crs(chicago.crs)
>>> groceries.shape
(148, 8)

>>> nws_groceries = groceries.clip(near_west_side)
>>> nws_groceries.shape
(7, 8)
)maskkeep_geom_typer  )r   clip)rP   r  r  r  s       r,   r  GeoDataFrame.clip
  s    v ~~dnXXr.   c                .    [         R                  " XX#US9$ )a  Perform spatial overlay between GeoDataFrames.

Currently only supports data GeoDataFrames with uniform geometry types,
i.e. containing only (Multi)Polygons, or only (Multi)Points, or a
combination of (Multi)LineString and LinearRing shapes.
Implements several methods that are all effectively subsets of the union.

See the User Guide page :doc:`../../user_guide/set_operations` for details.

Parameters
----------
right : GeoDataFrame
how : string
    Method of spatial overlay: 'intersection', 'union',
    'identity', 'symmetric_difference' or 'difference'.
keep_geom_type : bool
    If True, return only geometries of the same geometry type the GeoDataFrame
    has, if False, return all resulting geometries. Default is None,
    which will set keep_geom_type to True but warn upon dropping
    geometries.
make_valid : bool, default True
    If True, any invalid input geometries are corrected with a call to
    make_valid(), if False, a `ValueError` is raised if any input geometries
    are invalid.

Returns
-------
df : GeoDataFrame
    GeoDataFrame with new set of polygons and attributes
    resulting from the overlay

Examples
--------
>>> from shapely.geometry import Polygon
>>> polys1 = geopandas.GeoSeries([Polygon([(0,0), (2,0), (2,2), (0,2)]),
...                               Polygon([(2,2), (4,2), (4,4), (2,4)])])
>>> polys2 = geopandas.GeoSeries([Polygon([(1,1), (3,1), (3,3), (1,3)]),
...                               Polygon([(3,3), (5,3), (5,5), (3,5)])])
>>> df1 = geopandas.GeoDataFrame({'geometry': polys1, 'df1_data':[1,2]})
>>> df2 = geopandas.GeoDataFrame({'geometry': polys2, 'df2_data':[1,2]})

>>> df1.overlay(df2, how='union')
   df1_data  df2_data                                           geometry
0       1.0       1.0                POLYGON ((2 2, 2 1, 1 1, 1 2, 2 2))
1       2.0       1.0                POLYGON ((2 2, 2 3, 3 3, 3 2, 2 2))
2       2.0       2.0                POLYGON ((4 4, 4 3, 3 3, 3 4, 4 4))
3       1.0       NaN      POLYGON ((2 0, 0 0, 0 2, 1 2, 1 1, 2 1, 2 0))
4       2.0       NaN  MULTIPOLYGON (((3 4, 3 3, 2 3, 2 4, 3 4)), ((4...
5       NaN       1.0  MULTIPOLYGON (((2 3, 2 2, 1 2, 1 3, 2 3)), ((3...
6       NaN       2.0      POLYGON ((3 5, 5 5, 5 3, 4 3, 4 4, 3 4, 3 5))

>>> df1.overlay(df2, how='intersection')
   df1_data  df2_data                             geometry
0         1         1  POLYGON ((2 2, 2 1, 1 1, 1 2, 2 2))
1         2         1  POLYGON ((2 2, 2 3, 3 3, 3 2, 2 2))
2         2         2  POLYGON ((4 4, 4 3, 3 3, 3 4, 4 4))

>>> df1.overlay(df2, how='symmetric_difference')
   df1_data  df2_data                                           geometry
0       1.0       NaN      POLYGON ((2 0, 0 0, 0 2, 1 2, 1 1, 2 1, 2 0))
1       2.0       NaN  MULTIPOLYGON (((3 4, 3 3, 2 3, 2 4, 3 4)), ((4...
2       NaN       1.0  MULTIPOLYGON (((2 3, 2 2, 1 2, 1 3, 2 3)), ((3...
3       NaN       2.0      POLYGON ((3 5, 5 5, 5 3, 4 3, 4 4, 3 4, 3 5))

>>> df1.overlay(df2, how='difference')
                                            geometry  df1_data
0      POLYGON ((2 0, 0 0, 0 2, 1 2, 1 1, 2 1, 2 0))         1
1  MULTIPOLYGON (((3 4, 3 3, 2 3, 2 4, 3 4)), ((4...         2

>>> df1.overlay(df2, how='identity')
   df1_data  df2_data                                           geometry
0         1       1.0                POLYGON ((2 2, 2 1, 1 1, 1 2, 2 2))
1         2       1.0                POLYGON ((2 2, 2 3, 3 3, 3 2, 2 2))
2         2       2.0                POLYGON ((4 4, 4 3, 3 3, 3 4, 4 4))
3         1       NaN      POLYGON ((2 0, 0 0, 0 2, 1 2, 1 1, 2 1, 2 0))
4         2       NaN  MULTIPOLYGON (((3 4, 3 3, 2 3, 2 4, 3 4)), ((4...

See Also
--------
GeoDataFrame.sjoin : spatial join
overlay : equivalent top-level function

Notes
-----
Every operation in GeoPandas is planar, i.e. the potential third
dimension is not taken into account.
)r  r  
make_valid)r   overlay)rP   r  r  r  r  s        r,   r  GeoDataFrame.overlay
  s    @   SJ
 	
r.   )r   r2   r"   ro   )r3   
Any | Noner"   r  )returnr   )...)rr   bool | Noner<   Literal[True]r"   r  r  Nonerr   r  r<   Literal[False]r"   r  r  r0   NFN)rr   r  r<   boolr"   r  r  GeoDataFrame | None).)ri   r7   r<   r  r  r  )ri   r7   r<   r  r  r0   )F)ri   r7   r<   r  r  r  )r  r   )r  r   )r  r  )NN)r*   r   r"   r  r  r0   )r   os.PathLike | typing.IOr  r0   )r"   r  r6   zIterable[str] | Noner  r0   )r   NNTNNN)r   zstr | sqlalchemy.textr   r7   r"   r  r   zstr | list[str] | Noner   r  r   zlist | dict | Noner   zlist | tuple | dict | Noner   
int | Noner  r0   )r3   
str | Noner   dict | None)r   FFF)
r   zLiteral['null', 'drop', 'keep']r   r  r   r  r   r  r  r7   )r  r   )r   FF)r   r7   r   r  r   r  r  ztyping.Generator[dict])r   r  r   r  r   r  r  r   )r  r  r  pd.DataFrame)r  r  )r#   r  r  r   r  r  r  r  )Nsnappyr  FN)r&  r  r#   r  r"  r7   r  r   r$  r  r#  !SUPPORTED_VERSIONS_LITERAL | Noner  r  )NNN)r&  zos.PathLiker#   r  r"  r  r#  r  )r   r  r0  r  r1  r  r#   r  )....)
r"   r  r   r  r<   r  r6  r  r  r  )
r"   r  r   r  r<   r  r6  r  r  r0   )NNFF)
r"   r  r   r  r<   r  r6  r  r  r  )r"   r  r   r  r<   r  r  r0   )r"   r  r   r  r<   r  r  r  )NNF)r"   r  r   r  r<   r  r  r  )zWGS 84)rA  r7   r  r   )T)ry   r  r  r0   )r   FNrp   )r]  r  )r  zpd.DataFrame | GeoDataFrame)r  zDataFrame | GeoDataFrame)r  zSeries | GeoSeries)r  r  r  zGeoDataFrame | GeoSeries)	NfirstTNTFTunaryN)r  r  r  r  r  r  r  r  r  r  r  z/Literal['unary', 'coverage', 'disjoint_subset']r  float | Noner  r0   )NFF)r  r  r  r  r  r  r  zGeoDataFrame | DataFrame)NfailFNNN)r$   r7   r1  r  r  z$Literal['fail', 'replace', 'append']r#   r  r  zIterable[str] | str | Noner   r  r  r  )r  z
folium.Map)inner
intersectsr  r  )r   r0   r  !Literal['left', 'right', 'inner']r  r7   r  r7   r  r7   r  r0   )r  Nr  r  NF)r  r0   r  r  r  r  r  r7   r  r7   r  r  r  r  r  r0   )FF)r  r  r  r  r  r0   )intersectionNT)r  r0   r  zRLiteral['intersection', 'union', 'identity', 'symmetric_difference', 'difference']r  r  r  r  )I__name__
__module____qualname____firstlineno____doc__r  r   _internal_namesset_internal_names_setr2   rB   rW   ra   rj   propertyr3   typingoverloadrO   r   r   r"   setterr   classmethodr   r   r   r   r   r   r   r  r   r   r   r  r'  r+  r2  r7  r   rB  rH  rh   rW  r   r?   r&   r_  rg  rj  rx  r  r  r  r  r  r  r   r   plottingGeoplotAccessorr  r   r  r  r  r  r  __static_attributes____classcell__)rT   s   @r,   r0   r0   S   sf
   9v ))I//:,>Oo.  d  $d 	d
 d dL+0>- 4TH __  !$  	
  
  __  "%   	
  
  !\ \ 	\
 \ 
\| __ "%  
	  __ #&   
	 '4R * *. ' 'R 	ZZ 6<  	:: 	: 
: :< 0@ 0@d OSV3&V38LV3	V3 V3p 
 ,0!*.-1 $P"P 	P
 P *P P (P +P P 
P Pd QU+
(+
CN+
 +
^ /5b)+b) b) 	b)
 b) 
b)H J JB JOjj+/jBFj	jZ QV88268IM8	8t42 "8= !%[! [! 6	[!
 [! [!@ "#8=$)<@S
%S
 S
 	S

 6S
 "S
 :S
 
S
p ""&<@5
5
 5
  	5

 :5
t ""!fB)fB fB 	fB
 fBP __ !$"  	
  
  __ "%"   	
  
  $WW W 	W
 W 
Wr __ "%	   	
 
  __ !$	  	
 
  	XX X 	X
 
Xt$EL>4&(B 	   	 % 	% %N 	$   < < 0 04+ +/$'$	!$ $P BI"&[[ 	[ [ [ [ @[  [ 
[@ ""!	kk k 	k 
"k kb ":@26 $A
A
 	A

 8A
 A
 0A
 A
 
A
F FI..>>?D]/ / 29%d
d
 /d
 	d

 d
 d
 
d
R 29%)#'D
D
 /D
 #	D

 D
 D
 !D
 D
 
D
N @E;Y$(;Y8<;Y	;YD &*b
b

b
 $b
 b
 b
r.   r0   c                ^    U(       a  [        S5      e[        U 5      nUR                  XSUS9$ )NzGCan't do inplace setting when converting from DataFrame to GeoDataFrameF)rr   r<   r"   )rC   r0   rO   )rP   ri   rr   r<   r"   gfs         r,   _dataframe_set_geometryr
  2  s8     U
 	
 
d	B??35c?BBr.   ro   )r"   r  r  zGeoSeries | GeometryArrayr  r  );
__future__r   r   r   r   r   r   numpyr(   pandasr?   r   r   shapely.errorsr`  shapely.geometryr   r	   shapely.geometry.baser
   r   geopandas.arrayr   r   r   r   r   geopandas.baser   r   geopandas.explorer   geopandas.geoseriesr   _compatr   r   
_decoratorr   pandas.core.accessorr   r   TYPE_CHECKINGoscollections.abcr   foliumsqlalchemy.text
sqlalchemyr   r   r%  r   r   r-   rD   r0   r
  rO   rp   r.   r,   <module>r     s    "       $  + .  V V : & ) - -? 
(<; \+
=) \+
DW #C C 	C
 
C C  1	 r.   