
    Ch;                         S SK r S SKJr  S SKrS SKrS SKJr  S SK	J
r
  S SKr/ SQrSSSSSSSSSSSSS	SSS
S
SSSS0 0 0 0 0 0 0 0 4S jrS rS rSSSSSS
S
SS0 0 0 0 4S jrg)    N)mean)is_datetime64_any_dtype
LineString)locationprefer_canvasno_touch
disable_3dpng_enabledzoom_controlcrs
zoom_startlefttoppositionmin_zoommax_zoommin_latmax_latmin_lonmax_lon
max_boundsOpenStreetMapTF   z100%c                    ^^^^S^T^U S[US4S jjn SSK n SSKn!SSKn"SSKJn#  SSKJn$  SSKJmS  SSKJ	n%   SSKn&Sn'U R                  5       n(U R                  S
:H  n)U)R                  5       (       a,  U(R                   U)   R#                  S 5      U(R                   U)'   [%        U([&        R(                  5      (       a  U(R+                  5       n(U(R,                  c  SUS'   SnO1U(R,                  R/                  S5      (       d  U(R1                  S5      n(U(R2                  U(R2                   V*s/ s H  n*[5        U(U*   5      PM     sn*   R7                  U(R2                  U(R8                  S:H     5      n+[;        U+5      S:  a#  U(R=                  U+ V*s0 s H  n*U*S_M     sn*5      n([%        U(R>                  [@        RB                  5      (       dT  [5        U(R>                  5      (       d  U(R>                  RD                  S:X  a   U(R>                  R=                  S5      U(l        UGc  U(RF                  n,URI                  SS5      n-U-cm  [J        RL                  " U,5      RO                  5       (       dD  [Q        U,S   U,S   /5      n.[Q        U,S   U,S   /5      n/U/U.4n-SURS                  5       ;   a  S	n0OSn0OS	n0[T         H!  n1U1U;   d  M  [W        SU1 SU1 SUU1    S35      e   0 UEURS                  5        V1s0 s H  n1U1[T        ;   d  M  U1UU1   _M     sn1EnU'(       a  [%        U[X        5      (       a   W&RZ                  R]                  U5      n[%        UW&R^                  5      (       aZ  U(       a  UOUR`                  nSU;  a  URc                  SS5      US'   SU;  a  URc                  SS5      US'   URe                  SS9nU"Rf                  " S\U-UUUUUS.UD6nU0(       a#  URi                  U,S   U,S   /U,S   U,S   //5        U(Rj                  RO                  5       (       a  [l        Rn                  " S [p        SS!9  U$ [T         H  n2URI                  U2S5        M     Sn3UGbn  [@        Rr                  Rt                  Rw                  U5      (       a1  [;        U5      U(Rx                  S   :w  a  [W        S"5      eS#n4UU(U4'   U4nO[%        U(U   RD                  [@        Rz                  5      (       a  Ub  [W        S$5      eSn
O[@        Rr                  Rt                  R}                  U(U   5      (       di  [@        Rr                  Rt                  R                  U(U   5      (       d8  [@        Rr                  Rt                  R                  U(U   5      (       d  U(       a  Sn
[@        R                  " U(U   5      n3U
(       Ga  [@        R                  " U(U   U3)    US%9n5[;        U5R                  5      n6U(       a  UOS&nUU#R                  5       ;   ae  [J        R                  " U%R                  SU" UU6U5R                  S'95      m[J        R                  " U%R                  SU" UU6[        U65      S'95      n7GO`[%        UU%R                  5      (       ae  [J        R                  " U%R                  SU" U5R                  5      5      m[J        R                  " U%R                  SU" [        U65      5      5      n7GO[@        Rr                  Rt                  Rw                  U5      (       af  U6[;        U5      :  a  UU6[;        U5      -  S-   -  n[J        R                  " UU5R                  5      m[J        R                  " U[        U65      5      n7GOL[W        S(5      e[        U5      (       a  X    V.s/ s H  n.U" U.5      PM     sn.mGOUc  U(U   R                  5       OUnUc  U(U   R                  5       OUnUbr  Uc  0 nS)U;  a  UUS)'   U$" [J        R                  " U(U   U3)    5      U40 UD6n8[J        R                  " U%R                  SU" UU8R                  U8R                  S'95      mOo[J        R                  " XS*5      SS n9U$" [J        R                  " U(U   U3)    5      S+U9S,9n8[J        R                  " U%R                  SU" US-U8R                  S'95      mS.T;  a  S/TS.'   S0T;  a  STS0'   S1T;   a2  TS1   mU[        TU5      (       d  [W        S25      eTRI                  S15        OS3 n:U:mUTb  [%        T[X        5      (       a:  [%        U([&        R                  5      (       a  TU(R2                  ;   a  UUUU4S4 jn;U;n<O[%        U([&        R(                  5      (       a  [&        R                  " U(S59n(U3b?  U3R                  5       (       a*  URI                  S6S5      n=U=U(S7'   TU(R                  U3) S74'   OTU(S7'   TRI                  S6S5      mTTT(       d
  UUU4S8 jn>U>n<OUTUUU4S9 jn?U?n<O	UUU4S: jn@U@n<U	(       a  S.T;  a  S;TS.'   U4S< jnAUAnBOSnBUc  S=nUnC[%        U[X        5      (       a  US>:X  a  U"R                  " S\0 UD6nCOgUS?:X  a  U"R                  " S\0 UD6nCONUS=:X  a=  URc                  S@S5      US@'   URc                  SAS5      USA'   U"R                  " S\0 UD6nCO[W        SB5      e[%        U([&        R                  5      (       af  U(R8                  SC:H  R                  5        VDVEs/ s H-  u  nDnEUE(       d  M  WDU(R                   R                  :w  d  M+  WDPM/     nFnDnEU(R                  UFSD9n([%        U([&        R                  5      (       aD  U(R>                  R                  b  U(R                  5       n([        SEUU(40 UD6n[        SFUU(40 UD6nOSnSnU(U(R                   R                  5       U(R                   Rj                  -  )    R                  nGUGSG    HL  nHUHSH    H@  nI[%        WHSH   UI   [X        5      (       d  M   U R                  SISJ WHSH   WI   5      UHSH   UI'   MB     MN     U"R                  " WG4UUWCU<WBSK.UD6R                  U5        U(       Ga_  US#:X  d  UOSLnJURI                  SMUJ5      nJU
(       a  W5R                  R                  5       nW7R                  5       n7U3R                  5       (       a9  W=(       a2  UR                  URI                  SNSO5      5        U7R                  U=5        [        UWJUU75        U$ UGb  URI                  SPS5      nK0 nLSQU;   a  URI                  SQ5      WLSQ'   U(       Gah  [J        R                  " U%R                  SU" UW8R                  [        U8R                  5      S'95      nMWK(       a\  URI                  SRS5      (       a  U/U8R                  R                  5       -   nNOSnNU!R                  R                  " WM4UUWJWNSS.WLD6nOGO~URI                  STSU5      nPSVU;   a  USV   nO?U8R                  WP5      nURI                  SWS	5      nQUQ(       d  U V*s/ s H  n*U*SSX PM
     nn*U3R                  5       (       a?  W=(       a8  UR                  URI                  SNSO5      5        [J        R                  " WMU=5      nM[        UWJUWM5        O[%        UU!R                  R                  5      (       a  UnOOU" U5      nR[J        R                  " U%R                  SUR" [        URR                  5      5      5      nMURR                  SY:  a"  U!R                  R                  " WM4UUWJSZ.WLD6nOO!U!R                  R                  " WM4UUWJSZ.WLD6nOWK(       aM  U3R                  5       (       a'  W=(       a   [        USLURI                  SNSO5      /U=/5        UR                  WO5        U$ ! [        [        4 a    [        S5      ef = f! [        [        4 a    S	n' GNf = fs  sn*f s  sn*f s  sn1f ! [V         a     GNf = fs  sn.f s  snEnDf s  sn*f )]u$  Explore data in interactive map based on GeoPandas and folium/leaflet.js.

Generate an interactive leaflet map based on :class:`~geopandas.GeoDataFrame`

Parameters
----------
column : str, np.array, pd.Series (default None)
    The name of the dataframe column, :class:`numpy.array`,
    or :class:`pandas.Series` to be plotted. If :class:`numpy.array` or
    :class:`pandas.Series` are used then it must have same length as dataframe.
cmap : str, matplotlib.Colormap, branca.colormap or function (default None)
    The name of a colormap recognized by ``matplotlib``, a list-like of colors,
    :class:`matplotlib.colors.Colormap`, a :class:`branca.colormap.ColorMap` or
    function that returns a named color or hex based on the column
    value, e.g.::

        def my_colormap(value):  # scalar value defined in 'column'
            if value > 1:
                return "green"
            return "red"

color : str, array-like (default None)
    Named color or a list-like of colors (named or hex).
m : folium.Map (default None)
    Existing map instance on which to draw the plot.
tiles : str, xyzservices.TileProvider (default 'OpenStreetMap Mapnik')
    Map tileset to use. Can choose from the list supported by folium, query a
    :class:`xyzservices.TileProvider` by a name from ``xyzservices.providers``,
    pass :class:`xyzservices.TileProvider` object or pass custom XYZ URL.
    The current list of built-in providers (when ``xyzservices`` is not available):

    ``["OpenStreetMap", "CartoDB positron", “CartoDB dark_matter"]``

    You can pass a custom tileset to Folium by passing a Leaflet-style URL
    to the tiles parameter: ``http://{s}.yourtiles.com/{z}/{x}/{y}.png``.
    Be sure to check their terms and conditions and to provide attribution with
    the ``attr`` keyword.
attr : str (default None)
    Map tile attribution; only required if passing custom tile URL.
tooltip : bool, str, int, list (default True)
    Display GeoDataFrame attributes when hovering over the object.
    ``True`` includes all columns. ``False`` removes tooltip. Pass string or list of
    strings to specify a column(s). Integer specifies first n columns to be
    included. Defaults to ``True``.
popup : bool, str, int, list (default False)
    Input GeoDataFrame attributes for object displayed when clicking.
    ``True`` includes all columns. ``False`` removes popup. Pass string or list of
    strings to specify a column(s). Integer specifies first n columns to be
    included. Defaults to ``False``.
highlight : bool (default True)
    Enable highlight functionality when hovering over a geometry.
categorical : bool (default False)
    If ``False``, ``cmap`` will reflect numerical values of the
    column being plotted. For non-numerical columns, this
    will be set to True.
legend : bool (default True)
    Plot a legend in choropleth plots.
    Ignored if no ``column`` is given.
scheme : str (default None)
    Name of a choropleth classification scheme (requires ``mapclassify`` >= 2.4.0).
    A :func:`mapclassify.classify` will be used
    under the hood. Supported are all schemes provided by ``mapclassify`` (e.g.
    ``'BoxPlot'``, ``'EqualInterval'``, ``'FisherJenks'``, ``'FisherJenksSampled'``,
    ``'HeadTailBreaks'``, ``'JenksCaspall'``, ``'JenksCaspallForced'``,
    ``'JenksCaspallSampled'``, ``'MaxP'``, ``'MaximumBreaks'``,
    ``'NaturalBreaks'``, ``'Quantiles'``, ``'Percentiles'``, ``'StdMean'``,
    ``'UserDefined'``). Arguments can be passed in ``classification_kwds``.
k : int (default 5)
    Number of classes
vmin : None or float (default None)
    Minimum value of ``cmap``. If ``None``, the minimum data value
    in the column to be plotted is used.
vmax : None or float (default None)
    Maximum value of ``cmap``. If ``None``, the maximum data value
    in the column to be plotted is used.
width : pixel int or percentage string (default: '100%')
    Width of the folium :class:`~folium.folium.Map`. If the argument
    m is given explicitly, width is ignored.
height : pixel int or percentage string (default: '100%')
    Height of the folium :class:`~folium.folium.Map`. If the argument
    m is given explicitly, height is ignored.
categories : list-like
    Ordered list-like object of categories to be used for categorical plot.
classification_kwds : dict (default None)
    Keyword arguments to pass to mapclassify
control_scale : bool, (default True)
    Whether to add a control scale on the map.
marker_type : str, folium.Circle, folium.CircleMarker, folium.Marker (default None)
    Allowed string options are ('marker', 'circle', 'circle_marker'). Defaults to
    folium.CircleMarker.
marker_kwds: dict (default {})
    Additional keywords to be passed to the selected ``marker_type``, e.g.:

    radius : float (default 2 for ``circle_marker`` and 50 for ``circle``))
        Radius of the circle, in meters (for ``circle``) or pixels
        (for ``circle_marker``).
    fill : bool (default True)
        Whether to fill the ``circle`` or ``circle_marker`` with color.
    icon : folium.map.Icon
        the :class:`folium.map.Icon` object to use to render the marker.
    draggable : bool (default False)
        Set to True to be able to drag the marker around the map.

style_kwds : dict (default {})
    Additional style to be passed to folium ``style_function``:

    stroke : bool (default True)
        Whether to draw stroke along the path. Set it to ``False`` to
        disable borders on polygons or circles.
    color : str
        Stroke color
    weight : int
        Stroke width in pixels
    opacity : float (default 1.0)
        Stroke opacity
    fill : boolean (default True)
        Whether to fill the path with color. Set it to ``False`` to
        disable filling on polygons or circles.
    fillColor : str
        Fill color. Defaults to the value of the color option
    fillOpacity : float (default 0.5)
        Fill opacity.
    style_function : callable
        Function mapping a GeoJson Feature to a style ``dict``.

        * Style properties :func:`folium.vector_layers.path_options`
        * GeoJson features :class:`GeoDataFrame.__geo_interface__`

        e.g.::

            lambda x: {"color":"red" if x["properties"]["gdp_md_est"]<10**6
                                         else "blue"}

    Plus all supported by :func:`folium.vector_layers.path_options`. See the
    documentation of :class:`folium.features.GeoJson` for details.

highlight_kwds : dict (default {})
    Style to be passed to folium highlight_function. Uses the same keywords
    as ``style_kwds``. When empty, defaults to ``{"fillOpacity": 0.75}``.
missing_kwds : dict (default {})
    Additional style for missing values:

    color : str
        Color of missing values. Defaults to ``None``, which uses Folium's default.
    label : str (default "NaN")
        Legend entry for missing values.
tooltip_kwds : dict (default {})
    Additional keywords to be passed to :class:`folium.features.GeoJsonTooltip`,
    e.g. ``aliases``, ``labels``, or ``sticky``.
popup_kwds : dict (default {})
    Additional keywords to be passed to :class:`folium.features.GeoJsonPopup`,
    e.g. ``aliases`` or ``labels``.
legend_kwds : dict (default {})
    Additional keywords to be passed to the legend.

    Currently supported customisation:

    caption : string
        Custom caption of the legend. Defaults to the column name.

    Additional accepted keywords when ``scheme`` is specified:

    colorbar : bool (default True)
        An option to control the style of the legend. If True, continuous
        colorbar will be used. If False, categorical legend will be used for bins.
    scale : bool (default True)
        Scale bins along the colorbar axis according to the bin edges (True)
        or use the equal length for each bin (False)
    fmt : string (default "{:.2f}")
        A formatting specification for the bin edges of the classes in the
        legend. For example, to have no decimals: ``{"fmt": "{:.0f}"}``. Applies
        if ``colorbar=False``.
    labels : list-like
        A list of legend labels to override the auto-generated labels.
        Needs to have the same number of elements as the number of
        classes (`k`). Applies if ``colorbar=False``.
    interval : boolean (default False)
        An option to control brackets from mapclassify legend.
        If True, open/closed interval brackets are shown in the legend.
        Applies if ``colorbar=False``.
    max_labels : int, default 10
        Maximum number of colorbar tick labels (requires branca>=0.5.0)
map_kwds : dict (default {})
    Additional keywords to be passed to folium :class:`~folium.folium.Map`,
    e.g. ``dragging``, or ``scrollWheelZoom``.


**kwargs : dict
    Additional options to be passed on to the folium object.

Returns
-------
m : folium.folium.Map
    folium :class:`~folium.folium.Map` instance

Examples
--------
>>> import geodatasets
>>> df = geopandas.read_file(
...     geodatasets.get_path("geoda.chicago_health")
... )
>>> df.head(2)  # 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 rows x 87 columns]

>>> df.explore("Pop2012", cmap="Blues")  # doctest: +SKIP
Nc                    > U(       d  TR                  U 5      $ TR                  U 5      R                  U5      " U5      $ )zPReturn the color map specified.

Helper function for MPL deprecation - GH#2596.
)get_cmap	resampled)_cmap
n_resampleidxcms      dC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\geopandas/explore.py_colormap_helper"_explore.<locals>._colormap_helper  s6    
 ;;u%%;;u%//
;C@@    r   )classify)	colormaps)colorszThe 'folium>=0.12', 'matplotlib' and 'mapclassify' packages are required for 'explore()'. You can install them using 'conda install -c conda-forge "folium>=0.12" matplotlib mapclassify' or 'pip install "folium>=0.12" matplotlib mapclassify'.TF
LinearRingc                     [        U 5      $ Nr   )gs    r#   <lambda>_explore.<locals>.<lambda>@  s    jmr&   Simpler   i  objectstringr            r   'z.' cannot be specified in 'map_kwds'. Use the '=z' argument instead.r   r      z{r})scale_factor)r   control_scaletilesattrwidthheightzeThe GeoSeries you are attempting to plot is composed of empty geometries. Nothing has been displayed.)
stacklevelz@The GeoDataFrame and given column have different number of rows.__plottable_columnz=Cannot specify 'categories' when column has categorical dtype)
categoriestab20)r    r!   zo'cmap' is invalid. For categorical plots, pass either valid named matplotlib colormap or a list-like of colors.ki  UserDefined)bins   fillOpacityg      ?weightstyle_functionz%'style_function' has to be a callablec                     0 $ r,    xs    r#   	_no_style_explore.<locals>._no_style  s    Ir&   c                 4   > SU S   T   0TEn0 UET" U 5      E$ )N	fillColor
propertiesrK   )rM   
base_stylecolor
style_kwdsstyle_kwds_functions     r#   _style_color_explore.<locals>._style_color  s?    <!7 
 )!, r&   )geometryrT   __folium_colorc                 B   > U S   S   U S   S   S.TEn0 UET" U 5      E$ NrR   rZ   )rQ   rT   rK   )rM   rS   rU   rV   s     r#   _style_column_explore.<locals>._style_column3  sM    %&|_5E%F!"<1A!B" %"J
$-a0 r&   c                 6   > U S   S   TS.TEn0 UET" U 5      E$ r\   rK   )rM   rS   stroke_colorrU   rV   s     r#   _style_stroke_explore.<locals>._style_strokeA  sC    %&|_5E%F!-" %"J
$-a0 r&   c                    > 0 TET" U 5      E$ r,   rK   )rM   rU   rV   s    r#   _style_default _explore.<locals>._style_defaultO  s    ;j;$7$:;;r&   g      ?c                    > 0 TE$ r,   rK   )rM   highlight_kwdss    r#   _style_highlight"_explore.<locals>._style_highlightX  s    %n%%r&   circle_markermarkercircleradiusfillzKOnly 'marker', 'circle', and 'circle_marker' are supported as marker valuesrY   )columnstooltippopupfeaturesrR   z\{{2,}c                 0    SU R                  S5      -   S-   $ )Nz	{% raw %}r   z{% endraw %})grouprL   s    r#   r.   r/     s    kAGGAJ6Gr&   )rp   rq   rk   rI   highlight_function captionlabelNaNcolorbar
max_labelsscale)vminvmaxrw   indexfmtz{:.2f}labelsinterval   )r}   r~   rw   )NNrK   )krebrancafoliummatplotlib.pyplotpyplotmapclassifyr'   
matplotlibr(   r)   ImportErrorModuleNotFoundErrorxyzservicescopy	geom_typeanyrY   apply
isinstance	geopandas	GeoSeriesto_framer   equalsto_crsro   r   uniondtypeslenastyper   pd
MultiIndexdtypetotal_boundspopnpisnanallr   keys_MAP_KWARGS
ValueErrorstr	providers
query_nameTileProviderhtml_attributionget	build_urlMap
fit_boundsis_emptywarningswarnUserWarningapitypesis_list_likeshapeCategoricalDtypeis_object_dtypeis_bool_dtypeis_string_dtypeisnaCategoricalrA   apply_along_axisto_hexcodesrangeColormaptakecallableminmaxasarrayrC   yblinspaceGeoDataFramelocMarkerCircleCircleMarkeritemsnamedropreset_index_tooltip_popup__geo_interface__subGeoJsonadd_toto_listtolistappend_categorical_legendrE   colormapStepColormapget_legend_classesColorMapNLinearColormap	add_child)VdfcolumncmaprT   mr;   r<   rp   rq   	highlightcategoricallegendschemerC   r}   r~   r=   r>   rA   classification_kwdsr:   marker_typemarker_kwdsrU   rg   missing_kwdstooltip_kwds
popup_kwdslegend_kwdsmap_kwdskwargsr$   r   bcr   pltr'   r)   r   HAS_XYZSERVICESgdf
rings_maskcjson_not_supported_colsboundsr   rM   yfitimap_kwdnan_idxcolumn_namecatr   legend_colorsbinningrE   rN   rW   rI   	nan_colorr]   ra   rd   rh   ru   rk   r   valnon_active_geomsfeature_collectionfeatureproprw   cbarcolormap_kwds	cb_colorsr   rz   r   show_intervalmp_cmapr"   r`   rV   sV      `                   ``                                                          @@@r#   _explorer  "   s   hA
'(.%  '')C -J~~#&<<
#;#A#A#$
Z  #y**++lln
ww uWW^^D!!jj "kk25++>+Q	 Q	(+>eCKK

h./0  "#a'jj/FG/F!!X+/FGHcii//		**syy(/JII$$X.	 	y!!::j$/BHHV$4$8$8$:$:fQi+,AfQi+,A1vHv{{},C AH} s   !s!HQK=0CE  

%+[[]G]a;6F|q&)|]G

 %%%'11<<UCE %!9!9::#t)?)?X-+099Z+CHZ(X-+099Z+DHZ(U;JJ 
'
 
 LL6!9fQi06!9fQi2HIJ
||H		
 

7D!  G66<<$$V,,6{ciil* V  3#)K $F))2+>+>??% S  KFFLL((V55vv||))#f+66vv||++CK88K''#f+&..VgX!6:NCCNN#A4WD s}}&++MM$TaSYYG
 !# 3 3MM1&6tuUVx&X!
 D&//22++FMM1d399oN " 3 3FMM1d5QR8n U **400s4y=1D	>A#56Dcii0 "eAh 7 !J 
 d^^&(j1jT!Wj1E )-3v;??$$D(,3v;??$$D !&.*,'11/0',"JJs6{G845vAT ++MM$TgiiWZZP {{4s3AB7"JJs6{G845}4 ++MM$TcwzzJ J&$'
=!z! 
8:%()9:+,,DEE'(	 ( uc""3	 6 677$ *N#y2233,,c:"w{{}}(,,Wd;	(1$%6;"223(-$%%>>'48L	 "/	 "/	< (.,0N=)	& .! %F+s##("]]1[1FH$]]1[1FO+$/OOHa$@K!"-//&$"?K((7;7F-  #y--.. "jjJ6==?
?	c s||000 ? 	 

 hh/h0 #y--..99>>%//#C GSILIwsAjA
,,


 5 5
56  &j1L)D',/5s;;.0ffGL)$//%d+ * 2 NN%-  fQi &*> >&B//)W5//1J)002M{{}}!!,"2"27E"BC$$Y/7JFX HW ??:t4DM{*.9ool.Kl+//MM$TgiiU799EUV	
 "w55!%)<)<)> > $!{{77! !! '#  ( H &//%:C;.%0%:
%,%?%?%D
(3
E(J,;E)F:a!Ab':J)F{{}}")),*:*:7E*JK$&IIi$C	'7J	J dBKK$8$899#H.t4G " 3 3q'%		2B*C!I
 yy2~#%;;#=#=%$!%!%$+	$
 ,$ $&;;#;#;%$!%!%$+	$
 ,$ ;;==Y'2 0 0% @AI; H%H] ,- 
H
 	

 ,-   , 	? H@ H " J 2n
p *Gsx   $0 A@ )A@(A@-2A@2
A@2/A@7 %AAAA0AAAA(AA0A@@A@%@$A@%@7
AAAAAc                 d   SSK nUSL d	  Ub  US:X  a  gUSL a>  UR                  R                  UR                  R                  5      R                  5       nOn[        U[        5      (       aA  UR                  R                  UR                  R                  5      R                  5       SU nO[        U[        5      (       a  U/nS H  nXQ;   d  M
  UR                  U5        M     [        [        [        U5      5      nU S:X  a  UR                  " U40 UD6$ U S:X  a  UR                  " U40 UD6$ g)zGet tooltip or popup.r   NFT)r@   rZ   rp   rq   )r   ro   r   rY   r   r   r   intr   removelistmapGeoJsonTooltipGeoJsonPopup)typefieldsr   kwdsr   fields         r#   r   r     s    &.FaKT>[[%%cll&7&78@@BF$$[[%%cll&7&78@@B7FKF$$XF9?MM%  :
 #c6"#Fy$$V4t44	""62T22 
r&   c                    SnSSK nUR                  R                  5       nUR                  R                  U5      Ul        U R                  5       R                  U5        SU SU S3n[        X#5       H  u  pUSU	 SU S	3-  nM     US
-  nUR                  R                  US5      nU R                  5       R                  R                  U5        g)a  Add categorical legend to a map.

The implementation is using the code originally written by Michel Metran
(@michelmetran) and released on GitHub
(https://github.com/michelmetran/package_folium) under MIT license.

Copyright (c) 2020 Michel Metran

Parameters
----------
m : folium.Map
    Existing map instance on which to draw the plot
title : str
    title of the legend (e.g. column name)
categories : list-like
    list of categories
colors : list-like
    list of colors (in the same order as categories)
aI  
    {% macro header(this, kwargs) %}
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    <script>$( function() {
        $( ".maplegend" ).draggable({
            start: function (event, ui) {
                $(this).css({
                    right: "auto",
                    top: "auto",
                    bottom: "auto"
                });
            }
        });
    });
    </script>
    <style type='text/css'>
      .maplegend {
        position: absolute;
        z-index:9999;
        background-color: rgba(255, 255, 255, .8);
        border-radius: 5px;
        box-shadow: 0 0 15px rgba(0,0,0,0.2);
        padding: 10px;
        font: 12px/14px Arial, Helvetica, sans-serif;
        right: 10px;
        bottom: 20px;
      }
      .maplegend .legend-title {
        text-align: left;
        margin-bottom: 5px;
        font-weight: bold;
        }
      .maplegend .legend-scale ul {
        margin: 0;
        margin-bottom: 0px;
        padding: 0;
        float: left;
        list-style: none;
        }
      .maplegend .legend-scale ul li {
        list-style: none;
        margin-left: 0;
        line-height: 16px;
        margin-bottom: 2px;
        }
      .maplegend ul.legend-labels li span {
        display: block;
        float: left;
        height: 14px;
        width: 14px;
        margin-right: 5px;
        margin-left: 0;
        border: 0px solid #ccc;
        }
      .maplegend .legend-source {
        color: #777;
        clear: both;
        }
      .maplegend a {
        color: #777;
        }
    </style>
    {% endmacro %}
    r   Nz
    <div id='maplegend z7' class='maplegend'>
        <div class='legend-title'>zP</div>
        <div class='legend-scale'>
            <ul class='legend-labels'>z-
                <li><span style='background:z	'></span>z</li>z1
            </ul>
        </div>
    </div>
    r   )
r   elementMacroElementTemplate	_templateget_rootr   zipElementhtml)
r   titlerA   r)   headr   macrobodyrx   rT   s
             r#   r   r     s    *?D@  JJ##%Ejj))$/EOJJL5!w ##(' *'*D J/ --2G9UG5L 	L 0 	  D ::dH-DJJL%r&   c                 6    [        U 4UUUUUUUUU	U
UUUS.UD6$ )u  Interactive map based on GeoPandas and folium/leaflet.js.

Generate an interactive leaflet map based on :class:`~geopandas.GeoSeries`

Parameters
----------
color : str, array-like (default None)
    Named color or a list-like of colors (named or hex).
m : folium.Map (default None)
    Existing map instance on which to draw the plot.
tiles : str, xyzservices.TileProvider (default 'OpenStreetMap Mapnik')
    Map tileset to use. Can choose from the list supported by folium, query a
    :class:`xyzservices.TileProvider` by a name from ``xyzservices.providers``,
    pass :class:`xyzservices.TileProvider` object or pass custom XYZ URL.
    The current list of built-in providers (when ``xyzservices`` is not available):

    ``["OpenStreetMap", "CartoDB positron", “CartoDB dark_matter"]``

    You can pass a custom tileset to Folium by passing a Leaflet-style URL
    to the tiles parameter: ``http://{s}.yourtiles.com/{z}/{x}/{y}.png``.
    Be sure to check their terms and conditions and to provide attribution with
    the ``attr`` keyword.
attr : str (default None)
    Map tile attribution; only required if passing custom tile URL.
highlight : bool (default True)
    Enable highlight functionality when hovering over a geometry.
width : pixel int or percentage string (default: '100%')
    Width of the folium :class:`~folium.folium.Map`. If the argument
    m is given explicitly, width is ignored.
height : pixel int or percentage string (default: '100%')
    Height of the folium :class:`~folium.folium.Map`. If the argument
    m is given explicitly, height is ignored.
control_scale : bool, (default True)
    Whether to add a control scale on the map.
marker_type : str, folium.Circle, folium.CircleMarker, folium.Marker (default None)
    Allowed string options are ('marker', 'circle', 'circle_marker'). Defaults to
    folium.Marker.
marker_kwds: dict (default {})
    Additional keywords to be passed to the selected ``marker_type``, e.g.:

    radius : float
        Radius of the circle, in meters (for ``'circle'``) or pixels
        (for ``circle_marker``).
    icon : folium.map.Icon
        the :class:`folium.map.Icon` object to use to render the marker.
    draggable : bool (default False)
        Set to True to be able to drag the marker around the map.

style_kwds : dict (default {})
    Additional style to be passed to folium ``style_function``:

    stroke : bool (default True)
        Whether to draw stroke along the path. Set it to ``False`` to
        disable borders on polygons or circles.
    color : str
        Stroke color
    weight : int
        Stroke width in pixels
    opacity : float (default 1.0)
        Stroke opacity
    fill : boolean (default True)
        Whether to fill the path with color. Set it to ``False`` to
        disable filling on polygons or circles.
    fillColor : str
        Fill color. Defaults to the value of the color option
    fillOpacity : float (default 0.5)
        Fill opacity.
    style_function : callable
        Function mapping a GeoJson Feature to a style ``dict``.

        * Style properties :func:`folium.vector_layers.path_options`
        * GeoJson features :class:`GeoSeries.__geo_interface__`

        e.g.::

            lambda x: {"color":"red" if x["properties"]["gdp_md_est"]<10**6
                                         else "blue"}


    Plus all supported by :func:`folium.vector_layers.path_options`. See the
    documentation of :class:`folium.features.GeoJson` for details.

highlight_kwds : dict (default {})
    Style to be passed to folium highlight_function. Uses the same keywords
    as ``style_kwds``. When empty, defaults to ``{"fillOpacity": 0.75}``.
map_kwds : dict (default {})
    Additional keywords to be passed to folium :class:`~folium.folium.Map`,
    e.g. ``dragging``, or ``scrollWheelZoom``.

**kwargs : dict
    Additional options to be passed on to the folium.

Returns
-------
m : folium.folium.Map
    folium :class:`~folium.folium.Map` instance

)rT   r   r;   r<   r   r=   r>   r:   r   r   rU   rg   r   )r  )srT   r   r;   r<   r   r=   r>   r:   r   r   rU   rg   r   r   s                  r#   _explore_geoseriesr,    sK    f 	
#%  r&   )r   
statisticsr   numpyr   pandasr   pandas.api.typesr   shapely.geometryr   r   r   r  r   r   r,  rK   r&   r#   <module>r2     s        4 ' 0 	


	
		
=Vr36o&h 

	
Cr&   