{"id":13586328,"url":"https://github.com/pbugnion/gmaps","last_synced_at":"2025-05-15T09:06:41.071Z","repository":{"id":23988143,"uuid":"27371456","full_name":"pbugnion/gmaps","owner":"pbugnion","description":"Google maps for Jupyter notebooks","archived":false,"fork":false,"pushed_at":"2022-04-15T13:31:22.000Z","size":110082,"stargazers_count":760,"open_issues_count":79,"forks_count":144,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-04-14T15:00:35.055Z","etag":null,"topics":["google-maps","jupyter","jupyter-widget","maps","python"],"latest_commit_sha":null,"homepage":"https://jupyter-gmaps.readthedocs.io/en/stable/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pbugnion.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-01T09:12:06.000Z","updated_at":"2025-03-25T22:51:22.000Z","dependencies_parsed_at":"2022-08-07T11:00:52.220Z","dependency_job_id":null,"html_url":"https://github.com/pbugnion/gmaps","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pbugnion%2Fgmaps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pbugnion%2Fgmaps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pbugnion%2Fgmaps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pbugnion%2Fgmaps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pbugnion","download_url":"https://codeload.github.com/pbugnion/gmaps/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254233847,"owners_count":22036792,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google-maps","jupyter","jupyter-widget","maps","python"],"created_at":"2024-08-01T15:05:28.760Z","updated_at":"2025-05-15T09:06:36.056Z","avatar_url":"https://github.com/pbugnion.png","language":"Python","readme":"|travis| |pypi| |docs|\n\ngmaps\n=====\n\ngmaps is a plugin for including interactive Google maps in the IPython Notebook.\n\nLet's plot a `heatmap \u003chttp://jupyter-gmaps.readthedocs.io/en/latest/tutorial.html#heatmaps\u003e`_ of taxi pickups in San Francisco:\n\n.. code:: python\n\n    import gmaps\n    import gmaps.datasets\n    gmaps.configure(api_key=\"AI...\") # Your Google API key\n\n    # load a Numpy array of (latitude, longitude) pairs\n    locations = gmaps.datasets.load_dataset(\"taxi_rides\")\n\n    fig = gmaps.figure()\n    fig.add_layer(gmaps.heatmap_layer(locations))\n    fig\n\n.. image:: docs/source/_images/taxi_example.png\n\nWe can also plot chloropleth maps using `GeoJSON \u003chttp://jupyter-gmaps.readthedocs.io/en/latest/tutorial.html#geojson-layer\u003e`_:\n\n.. code:: python\n\n    from matplotlib.cm import viridis\n    from matplotlib.colors import to_hex\n\n    import gmaps\n    import gmaps.datasets\n    import gmaps.geojson_geometries\n\n    gmaps.configure(api_key=\"AI...\") # Your Google API key\n\n    countries_geojson = gmaps.geojson_geometries.load_geometry('countries') # Load GeoJSON of countries\n\n    rows = gmaps.datasets.load_dataset('gini') # 'rows' is a list of tuples\n    country2gini = dict(rows) # dictionary mapping 'country' -\u003e gini coefficient\n    min_gini = min(country2gini.values())\n    max_gini = max(country2gini.values())\n    gini_range = max_gini - min_gini\n\n    def calculate_color(gini):\n        \"\"\"\n        Convert the GINI coefficient to a color\n        \"\"\"\n        # make gini a number between 0 and 1\n        normalized_gini = (gini - min_gini) / gini_range\n\n        # invert gini so that high inequality gives dark color\n        inverse_gini = 1.0 - normalized_gini\n\n        # transform the gini coefficient to a matplotlib color\n        mpl_color = viridis(inverse_gini)\n\n        # transform from a matplotlib color to a valid CSS color\n        gmaps_color = to_hex(mpl_color, keep_alpha=False)\n\n        return gmaps_color\n\n    # Calculate a color for each GeoJSON feature\n    colors = []\n    for feature in countries_geojson['features']:\n        country_name = feature['properties']['name']\n        try:\n            gini = country2gini[country_name]\n            color = calculate_color(gini)\n        except KeyError:\n            # no GINI for that country: return default color\n            color = (0, 0, 0, 0.3)\n        colors.append(color)\n\n    fig = gmaps.figure()\n    gini_layer = gmaps.geojson_layer(\n        countries_geojson,\n        fill_color=colors,\n        stroke_color=colors,\n        fill_opacity=0.8)\n    fig.add_layer(gini_layer)\n    fig\n\n.. image:: docs/source/_images/geojson-2.png\n\nOr, for coffee fans, a map of all Starbucks in the UK:\n\n.. code:: python\n\n    import gmaps\n    import gmaps.datasets\n    gmaps.configure(api_key=\"AI...\") # Your Google API key\n\n    df = gmaps.datasets.load_dataset_as_df('starbucks_kfc_uk')\n\n    starbucks_df = df[df['chain_name'] == 'starbucks']\n    starbucks_df = starbucks_df[['latitude', 'longitude']]\n\n    starbucks_layer = gmaps.symbol_layer(\n\tstarbucks_df, fill_color=\"green\", stroke_color=\"green\", scale=2\n    )\n    fig = gmaps.figure()\n    fig.add_layer(starbucks_layer)\n    fig\n\n\n.. image:: docs/source/_images/starbucks-symbols.png\n\n\nInstallation\n------------\n\nInstalling `jupyter-gmaps` with `conda`\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe easiest way to install `gmaps` is with `conda`::\n\n    $ conda install -c conda-forge gmaps\n\nInstalling `jupyter-gmaps` with `pip`\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nMake sure that you have enabled `ipywidgets` widgets extensions::\n\n    $ jupyter nbextension enable --py --sys-prefix widgetsnbextension\n\nYou can then install gmaps with::\n\n    $ pip install gmaps\n\nThen tell Jupyter to load the extension with::\n\n    $ jupyter nbextension enable --py --sys-prefix gmaps\n\n\nInstalling `jupyter-gmaps` for JupyterLab\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nTo use `jupyter-gmaps` with JupyterLab, you will need to install the jupyter\nwidgets extension for JupyterLab::\n\n    $ jupyter labextension install @jupyter-widgets/jupyterlab-manager\n\nYou can then install `jupyter-gmaps` via pip (or conda)::\n\n    $ pip install gmaps\n\nNext time you open JupyterLab, you will be prompted to rebuild JupyterLab: this\nis necessary to include the `jupyter-gmaps` frontend code into your JupyterLab\ninstallation. You can also trigger this directly on the command line with::\n\n    $ jupyter lab build\n\nSupport for JupyterLab pre 1.0\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nTo install `jupyter-gmaps` with versions of JupyterLab pre 1.0, you will need to pin the version of `jupyterlab-manager` and of `jupyter-gmaps`. Find the version of the `jupyterlab-manager` that you need from `this compatibility table \u003chttps://github.com/jupyter-widgets/ipywidgets/tree/master/packages/jupyterlab-manager\u003e`_. For instance, for JupyterLab 0.35.x::\n\n    $ jupyter labextension install @jupyter-widgets/jupyterlab-manager@0.38\n\nThen, install a pinned version of `jupyter-gmaps`::\n\n    $ pip install gmaps==0.8.4\n\nYou will then need to rebuild JupyterLab with::\n\n    $ jupyter lab build\n\n\nGoogle API keys\n---------------\n\nTo access Google maps, `gmaps` needs a Google API key. This key tells Google who you are, presumably so it can keep track of rate limits and such things. To create an API key, follow the instructions in the `documentation \u003chttp://jupyter-gmaps.readthedocs.io/en/latest/authentication.html\u003e`_. Once you have an API key, pass it to `gmaps` before creating widgets:\n\n.. code:: python\n\n    gmaps.configure(api_key=\"AI...\")\n\nDocumentation\n-------------\n\nDocumentation for `gmaps` is available `here \u003chttp://jupyter-gmaps.readthedocs.io/en/latest/\u003e`_.\n\nSimilar libraries\n-----------------\n\nThe current version of this library is inspired by the `ipyleaflet \u003chttps://github.com/ellisonbg/ipyleaflet\u003e`_ notebook widget extension. This extension aims to provide much of the same functionality as `gmaps`, but for `leaflet maps`, not `Google maps`.\n\nVision and roadmap\n------------------\n\nJupyter-gmaps is built for data scientists. Data scientists should be able to visualize geographical data on a map with minimal friction. Beyond just visualization, they should be able to integrate gmaps into their widgets so they can build interactive applications.\n\nWe see the priorities of gmaps as:\n\n- responding to events, like user clicks, so that maps can be used interactively.\n- adding greater flexibility and customisability (e.g. choosing map styles)\n\n\nIssue reporting and contributing\n--------------------------------\n\nReport issues using the `github issue tracker \u003chttps://github.com/pbugnion/gmaps/issues\u003e`_.\n\nContributions are welcome. Read the CONTRIBUTING guide to learn how to contribute.\n\n.. |travis| image:: https://travis-ci.org/pbugnion/gmaps.svg?branch=master\n    :target: https://travis-ci.org/pbugnion/gmaps\n    :alt: Travis build status\n\n.. |pypi| image:: https://img.shields.io/pypi/v/gmaps.svg?style=flat-square\u0026label=version\n    :target: https://pypi.python.org/pypi/gmaps\n    :alt: Latest version released on PyPi\n\n.. |docs| image:: https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat\n    :target: http://jupyter-gmaps.readthedocs.io/en/latest/\n    :alt: Latest documentation\n","funding_links":[],"categories":["Python","地理Geo处理","交互式小部件和可视化","Visualization"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpbugnion%2Fgmaps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpbugnion%2Fgmaps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpbugnion%2Fgmaps/lists"}