Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Jupyter] cleanup examples (#574)

Shan He89ddae46658d
diff --git a/bindings/kepler.gl-jupyter/.gitignore b/bindings/kepler.gl-jupyter/.gitignore
index 867fd5aae..995560053 100644
--- a/bindings/kepler.gl-jupyter/.gitignore
+++ b/bindings/kepler.gl-jupyter/.gitignore
@@ -21,7 +21,6 @@ setup.orig2.py
notebooks/*.html
notebooks/*.sh
notebooks/*.js
-notebooks/scratch_paper.ipynb
notebooks/ignore_*
*/*.tgz
diff --git a/bindings/kepler.gl-jupyter/notebooks/Geometry as String.ipynb b/bindings/kepler.gl-jupyter/notebooks/Geometry as String.ipynb
deleted file mode 100644
index 09893f6cf..000000000
--- a/bindings/kepler.gl-jupyter/notebooks/Geometry as String.ipynb
+++ /dev/null
@@ -1,95 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [],
- "source": [
- "%run geojson_as_string.py"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "metadata": {},
- "outputs": [],
- "source": [
- "import pandas as pd\n",
- "df = pd.read_csv('geojson_as_string.csv')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Documentation: https://github.com/keplergl/kepler.gl/blob/master/docs/keplergl-jupyter/user-guide.md\n"
- ]
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "61a58296ec024a869d67b634fa117149",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "KeplerGl()"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "from keplergl import KeplerGl\n",
- "map_1 = KeplerGl()\n",
- "map_1"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [],
- "source": [
- "map_1.add_data(df, 'data_1')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {},
- "outputs": [],
- "source": [
- "map_1.config = config"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 2",
- "language": "python",
- "name": "python2"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 2
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython2",
- "version": "2.7.15"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}
diff --git a/bindings/kepler.gl-jupyter/notebooks/geojson_as_string.py b/bindings/kepler.gl-jupyter/notebooks/geojson_as_string.py
deleted file mode 100644
index e5739f7bb..000000000
--- a/bindings/kepler.gl-jupyter/notebooks/geojson_as_string.py
+++ /dev/null
@@ -1 +0,0 @@
-config = {u'version': u'v1', u'config': {u'visState': {u'layers': [{u'type': u'geojson', u'visualChannels': {u'sizeField': None, u'radiusScale': u'linear', u'colorScale': u'quantile', u'colorField': {u'type': u'integer', u'name': u'm_median_income'}, u'heightScale': u'linear', u'heightField': {u'type': u'integer', u'name': u'm_median_income'}, u'radiusField': None, u'sizeScale': u'linear'}, u'config': {u'dataId': u'data_1', u'color': [218, 112, 191, 255], u'textLabel': {u'color': [255, 255, 255], u'field': None, u'size': 50, u'anchor': u'middle', u'offset': [0, 0]}, u'label': u'data_1', u'isVisible': True, u'visConfig': {u'opacity': 0.8, u'sizeRange': [0, 10], u'wireframe': False, u'thickness': 0.5, u'elevationScale': 37.3, u'radius': 10, u'colorRange': {u'category': u'ColorBrewer', u'colors': [u'#0c2c84', u'#225ea8', u'#1d91c0', u'#41b6c4', u'#7fcdbb', u'#c7e9b4', u'#edf8b1', u'#ffffd9'], u'type': u'sequential', u'reversed': True, u'name': u'ColorBrewer YlGnBu-8'}, u'hi-precision': False, u'enable3d': True, u'radiusRange': [0, 50], u'heightRange': [0, 500], u'filled': True, u'stroked': False}, u'columns': {u'geojson': u'simplified_shape_v2'}}, u'id': u'udt1eoe'}], u'interactionConfig': {u'brush': {u'enabled': False, u'size': 0.5}, u'tooltip': {u'fieldsToShow': {u'data_1': [u'city_id', u'territory', u'a_zip', u'zip_area', u'c_avg_12wk_tpr']}, u'enabled': True}}, u'splitMaps': [], u'layerBlending': u'normal', u'filters': []}, u'mapState': {u'bearing': -22.0507614213198, u'dragRotate': True, u'zoom': 8.055028773146017, u'longitude': -74.53934625108548, u'isSplit': False, u'pitch': 49.9049743818884, u'latitude': 40.258563152633556}, u'mapStyle': {u'mapStyles': {}, u'topLayerGroups': {}, u'styleType': u'light', u'visibleLayerGroups': {u'building': True, u'land': True, u'3d building': False, u'label': True, u'water': True, u'border': False, u'road': True}}}}
\ No newline at end of file
diff --git a/bindings/kepler.gl-jupyter/notebooks/scratch_paper.ipynb b/bindings/kepler.gl-jupyter/notebooks/scratch_paper.ipynb
deleted file mode 100644
index ffb833b04..000000000
--- a/bindings/kepler.gl-jupyter/notebooks/scratch_paper.ipynb
+++ /dev/null
@@ -1,1154 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 126,
- "metadata": {},
- "outputs": [],
- "source": [
- "import pandas as pd\n",
- "import geopandas\n",
- "import shapely.wkt\n",
- "import json"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 30,
- "metadata": {},
- "outputs": [],
- "source": [
- "def _gdf_to_dict(gdf):\n",
- " # get name of the geometry column\n",
- " name = gdf.geometry.name\n",
- " \n",
- " copy = gdf.copy()\n",
- " # convert it to wkt\n",
- " copy[name] = copy.geometry.apply(lambda x: shapely.wkt.dumps(x))\n",
- "\n",
- " return _df_to_dict(copy)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 35,
- "metadata": {},
- "outputs": [],
- "source": [
- "def _df_to_dict(df):\n",
- " ''' Create an input dict for Kepler.gl using a DataFrame object\n",
- "\n",
- " Inputs:\n",
- " - df: a DataFrame object\n",
- "\n",
- " Returns:\n",
- " - dictionary: a dictionary variable that can be used in Kepler.gl\n",
- "\n",
- " '''\n",
- " return df.to_dict('split')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 56,
- "metadata": {},
- "outputs": [],
- "source": [
- "df = pd.DataFrame(\n",
- " {'City': ['Buenos Aires', 'Brasilia', 'Santiago', 'Bogota', 'Caracas'],\n",
- " 'Country': ['Argentina', 'Brazil', 'Chile', 'Colombia', 'Venezuela'],\n",
- " 'Latitude': [-34.58, -15.78, -33.45, 4.60, 10.48],\n",
- " 'Longitude': [-58.66, -47.91, -70.66, -74.08, -66.86]})\n",
- "\n",
- "df2 = pd.DataFrame(\n",
- " {'City': ['Buenos Aires', 'Brasilia', 'Santiago', 'Bogota', 'Caracas'],\n",
- " 'Country': ['Argentina', 'Brazil', 'Chile', 'Colombia', 'Venezuela']})"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 62,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<style scoped>\n",
- " .dataframe tbody tr th:only-of-type {\n",
- " vertical-align: middle;\n",
- " }\n",
- "\n",
- " .dataframe tbody tr th {\n",
- " vertical-align: top;\n",
- " }\n",
- "\n",
- " .dataframe thead th {\n",
- " text-align: right;\n",
- " }\n",
- "</style>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>City</th>\n",
- " <th>Country</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>Buenos Aires</td>\n",
- " <td>Argentina</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>Brasilia</td>\n",
- " <td>Brazil</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>2</th>\n",
- " <td>Santiago</td>\n",
- " <td>Chile</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3</th>\n",
- " <td>Bogota</td>\n",
- " <td>Colombia</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>4</th>\n",
- " <td>Caracas</td>\n",
- " <td>Venezuela</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "</div>"
- ],
- "text/plain": [
- " City Country\n",
- "0 Buenos Aires Argentina\n",
- "1 Brasilia Brazil\n",
- "2 Santiago Chile\n",
- "3 Bogota Colombia\n",
- "4 Caracas Venezuela"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "ename": "AttributeError",
- "evalue": "No geometry data set yet (expected in column 'geometry'.",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m<ipython-input-62-5d8ae7b0a888>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mgdf2\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mgeopandas\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mGeoDataFrame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdf2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0mdisplay\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgdf2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0;32mprint\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mgdf2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgeometry\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
- "\u001b[0;32m/usr/local/lib/python2.7/site-packages/pandas/core/generic.pyc\u001b[0m in \u001b[0;36m__getattr__\u001b[0;34m(self, name)\u001b[0m\n\u001b[1;32m 4374\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_info_axis\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_can_hold_identifiers_and_holds_name\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4375\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 4376\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mobject\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__getattribute__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4377\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4378\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__setattr__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;32m/usr/local/lib/python2.7/site-packages/geopandas/geodataframe.pyc\u001b[0m in \u001b[0;36m_get_geometry\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 68\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_geometry_column_name\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 69\u001b[0m raise AttributeError(\"No geometry data set yet (expected in\"\n\u001b[0;32m---> 70\u001b[0;31m \" column '%s'.\" % self._geometry_column_name)\n\u001b[0m\u001b[1;32m 71\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_geometry_column_name\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 72\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mAttributeError\u001b[0m: No geometry data set yet (expected in column 'geometry'."
- ]
- }
- ],
- "source": [
- "# gdf = geopandas.GeoDataFrame(df, geometry=geopandas.points_from_xy(df.Longitude, df.Latitude))\n",
- "# gdf.rename(index=str, columns={\"geometry\": \"point\"})\n",
- "# display(gdf)\n",
- "# gdf = geopandas.GeoDataFrame(df)\n",
- "gdf2 = geopandas.GeoDataFrame(df2)\n",
- "display(gdf2)\n",
- "print (gdf2.geometry.name)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 38,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " City Country Latitude Longitude geometry\n",
- "0 Buenos Aires Argentina -34.58 -58.66 POINT (-58.66 -34.58)\n",
- "1 Brasilia Brazil -15.78 -47.91 POINT (-47.91 -15.78)\n",
- "2 Santiago Chile -33.45 -70.66 POINT (-70.66 -33.45)\n",
- "3 Bogota Colombia 4.60 -74.08 POINT (-74.08 4.6)\n",
- "4 Caracas Venezuela 10.48 -66.86 POINT (-66.86 10.48)\n",
- "True\n",
- "False\n"
- ]
- }
- ],
- "source": [
- "print(gdf.head())\n",
- "print(isinstance(gdf, geopandas.GeoDataFrame))\n",
- "print(isinstance(df, geopandas.GeoDataFrame))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 50,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "True\n"
- ]
- },
- {
- "ename": "AttributeError",
- "evalue": "No geometry data set yet (expected in column 'geometry'.",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
- "\u001b[0;32m<ipython-input-50-14a79efc3f92>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;31m# display(gdf2)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0m_gdf_to_dict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgdf2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
- "\u001b[0;32m<ipython-input-30-d4bf73b8ff6e>\u001b[0m in \u001b[0;36m_gdf_to_dict\u001b[0;34m(gdf)\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_gdf_to_dict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgdf\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0;31m# get name of the geometry column\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mname\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mgdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgeometry\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mcopy\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mgdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcopy\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;32m/usr/local/lib/python2.7/site-packages/pandas/core/generic.pyc\u001b[0m in \u001b[0;36m__getattr__\u001b[0;34m(self, name)\u001b[0m\n\u001b[1;32m 4374\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_info_axis\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_can_hold_identifiers_and_holds_name\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4375\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 4376\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mobject\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__getattribute__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4377\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4378\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__setattr__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;32m/usr/local/lib/python2.7/site-packages/geopandas/geodataframe.pyc\u001b[0m in \u001b[0;36m_get_geometry\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 68\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_geometry_column_name\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 69\u001b[0m raise AttributeError(\"No geometry data set yet (expected in\"\n\u001b[0;32m---> 70\u001b[0;31m \" column '%s'.\" % self._geometry_column_name)\n\u001b[0m\u001b[1;32m 71\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_geometry_column_name\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 72\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
- "\u001b[0;31mAttributeError\u001b[0m: No geometry data set yet (expected in column 'geometry'."
- ]
- }
- ],
- "source": [
- "# gdf1 = _gdf_to_dict(gdf)\n",
- "# display(gdf1)\n",
- "print(isinstance(gdf2, geopandas.GeoDataFrame))\n",
- "\n",
- "# display(gdf2)\n",
- "_gdf_to_dict(gdf2)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 22,
- "metadata": {},
- "outputs": [],
- "source": [
- "# get name of the geometry column\n",
- "name = gdf.geometry.name\n",
- "# convert it to wkt\n",
- "gdf[name] = gdf.geometry.apply(lambda x: shapely.wkt.dumps(x))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 23,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<style scoped>\n",
- " .dataframe tbody tr th:only-of-type {\n",
- " vertical-align: middle;\n",
- " }\n",
- "\n",
- " .dataframe tbody tr th {\n",
- " vertical-align: top;\n",
- " }\n",
- "\n",
- " .dataframe thead th {\n",
- " text-align: right;\n",
- " }\n",
- "</style>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>City</th>\n",
- " <th>Country</th>\n",
- " <th>Latitude</th>\n",
- " <th>Longitude</th>\n",
- " <th>geometry</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>Buenos Aires</td>\n",
- " <td>Argentina</td>\n",
- " <td>-34.58</td>\n",
- " <td>-58.66</td>\n",
- " <td>POINT (-58.6599999999999966 -34.5799999999999983)</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>Brasilia</td>\n",
- " <td>Brazil</td>\n",
- " <td>-15.78</td>\n",
- " <td>-47.91</td>\n",
- " <td>POINT (-47.9099999999999966 -15.7799999999999994)</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>2</th>\n",
- " <td>Santiago</td>\n",
- " <td>Chile</td>\n",
- " <td>-33.45</td>\n",
- " <td>-70.66</td>\n",
- " <td>POINT (-70.6599999999999966 -33.4500000000000028)</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3</th>\n",
- " <td>Bogota</td>\n",
- " <td>Colombia</td>\n",
- " <td>4.60</td>\n",
- " <td>-74.08</td>\n",
- " <td>POINT (-74.0799999999999983 4.5999999999999996)</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>4</th>\n",
- " <td>Caracas</td>\n",
- " <td>Venezuela</td>\n",
- " <td>10.48</td>\n",
- " <td>-66.86</td>\n",
- " <td>POINT (-66.8599999999999994 10.4800000000000004)</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "</div>"
- ],
- "text/plain": [
- " City Country Latitude Longitude \\\n",
- "0 Buenos Aires Argentina -34.58 -58.66 \n",
- "1 Brasilia Brazil -15.78 -47.91 \n",
- "2 Santiago Chile -33.45 -70.66 \n",
- "3 Bogota Colombia 4.60 -74.08 \n",
- "4 Caracas Venezuela 10.48 -66.86 \n",
- "\n",
- " geometry \n",
- "0 POINT (-58.6599999999999966 -34.5799999999999983) \n",
- "1 POINT (-47.9099999999999966 -15.7799999999999994) \n",
- "2 POINT (-70.6599999999999966 -33.4500000000000028) \n",
- "3 POINT (-74.0799999999999983 4.5999999999999996) \n",
- "4 POINT (-66.8599999999999994 10.4800000000000004) "
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "display(gdf)\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 24,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "{'columns': ['City', 'Country', 'Latitude', 'Longitude', 'geometry'],\n",
- " 'data': [['Buenos Aires',\n",
- " 'Argentina',\n",
- " -34.58,\n",
- " -58.66,\n",
- " 'POINT (-58.6599999999999966 -34.5799999999999983)'],\n",
- " ['Brasilia',\n",
- " 'Brazil',\n",
- " -15.78,\n",
- " -47.91,\n",
- " 'POINT (-47.9099999999999966 -15.7799999999999994)'],\n",
- " ['Santiago',\n",
- " 'Chile',\n",
- " -33.45,\n",
- " -70.66,\n",
- " 'POINT (-70.6599999999999966 -33.4500000000000028)'],\n",
- " ['Bogota',\n",
- " 'Colombia',\n",
- " 4.6,\n",
- " -74.08,\n",
- " 'POINT (-74.0799999999999983 4.5999999999999996)'],\n",
- " ['Caracas',\n",
- " 'Venezuela',\n",
- " 10.48,\n",
- " -66.86,\n",
- " 'POINT (-66.8599999999999994 10.4800000000000004)']],\n",
- " 'index': [0, 1, 2, 3, 4]}"
- ]
- },
- "execution_count": 24,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "gdf.to_dict('split')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 63,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<style scoped>\n",
- " .dataframe tbody tr th:only-of-type {\n",
- " vertical-align: middle;\n",
- " }\n",
- "\n",
- " .dataframe tbody tr th {\n",
- " vertical-align: top;\n",
- " }\n",
- "\n",
- " .dataframe thead th {\n",
- " text-align: right;\n",
- " }\n",
- "</style>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>scalerank</th>\n",
- " <th>featureclass</th>\n",
- " <th>geometry</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-59.57209469261153 -80.0401787250963...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-159.2081835601977 -79.4970594217087...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>2</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-45.15475765642103 -78.0470696005867...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>3</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-121.2115113938571 -73.5009904990060...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>4</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-125.5595664068953 -73.4813534547352...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>5</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-98.98154964882391 -71.9333342489997...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>6</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-68.45134599473033 -70.9558228557667...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>7</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-58.61414282900103 -64.1524671301332...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>8</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-67.75 -53.85, -66.45 -54.45, -65.05...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>9</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-58.55 -51.1, -57.75 -51.55, -58.05 ...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>10</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((70.28 -49.71, 68.745 -49.775, 68.72 ...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>11</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((145.3979781434949 -40.79254851660599...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>12</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((173.0203747907408 -40.91905242285642...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>13</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((174.6120089053306 -36.15639739354056...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>14</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((167.1200114280869 -22.15999073658352...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>15</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((178.3736000000002 -17.33992, 178.718...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>16</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((179.3641426619643 -16.80135407694685...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>17</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-179.9173693847653 -16.5017831356493...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>18</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((167.8448767438451 -16.46633310309716...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>19</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((167.1077124372015 -14.93392017991395...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>20</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((50.05651085795725 -13.55576140712201...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>21</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((143.5618111513 -13.76365569423221, 1...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>22</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((162.1190246930409 -10.48271900802114...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>23</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((120.7156087586305 -10.23958139408788...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>24</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((160.852228631838 -9.872937106977105,...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>25</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((161.6799817242891 -9.599982191611375...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>26</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((124.4359501486194 -10.14000090906144...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>27</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((117.9000183452078 -8.095681247594925...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>28</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((122.9035372254361 -8.094234307490751...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>29</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((159.8750272971986 -8.337320244991716...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>...</th>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " <td>...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>97</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-104.5 73.42, -105.38 72.76000000000...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>98</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-76.34 73.10268498995302, -76.251403...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>99</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-86.56217851433405 73.15744700793854...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>100</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-100.35642 73.84389, -99.16387 73.63...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>101</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((143.60385 73.21244, 142.08763 73.205...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>102</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-93.19629553910013 72.77199249947327...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>103</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-120.46 71.40000000000001, -123.0921...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>104</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((150.73167 75.08405999999999, 149.575...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>105</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-93.61275590694041 74.97999726022442...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>106</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((145.086285 75.56262, 144.3 74.819999...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>107</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-98.5 76.72, -97.735585 76.256560000...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>108</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-108.21141 76.20168, -107.8194299999...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>109</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((57.5356925799924 70.72046397570224, ...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>110</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-94.68408586299947 77.09787832305838...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>111</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-116.1985865955074 77.64528677032621...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>112</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((106.9702758789063 76.97430419921875,...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>113</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-93.84000301794401 77.5199972602345,...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>114</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-110.1869380359131 77.69701487905039...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>115</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((24.72412 77.85384999999999, 22.49032...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>116</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-109.6631457182026 78.60197256134569...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>117</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-95.83029496944926 78.05694122996334...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>118</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-100.0601918200522 78.32475434031582...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>119</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((105.07547 78.30689, 99.43814 77.9210...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>120</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((18.25183 79.70175, 21.54383 78.95611...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>121</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((25.44762535981198 80.40734039989459,...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>122</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((51.13618655783139 80.54728017854103,...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>123</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((99.93976000000001 78.88094, 97.75794...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>124</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-87.02 79.66, -85.81435 79.3369, -87...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>125</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-68.5 83.10632151676583, -65.82735 8...</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>126</th>\n",
- " <td>1</td>\n",
- " <td>Country</td>\n",
- " <td>POLYGON ((-27.10046 83.51966, -20.84539 82.726...</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "<p>127 rows × 3 columns</p>\n",
- "</div>"
- ],
- "text/plain": [
- " scalerank featureclass geometry\n",
- "0 1 Country POLYGON ((-59.57209469261153 -80.0401787250963...\n",
- "1 1 Country POLYGON ((-159.2081835601977 -79.4970594217087...\n",
- "2 1 Country POLYGON ((-45.15475765642103 -78.0470696005867...\n",
- "3 1 Country POLYGON ((-121.2115113938571 -73.5009904990060...\n",
- "4 1 Country POLYGON ((-125.5595664068953 -73.4813534547352...\n",
- "5 1 Country POLYGON ((-98.98154964882391 -71.9333342489997...\n",
- "6 1 Country POLYGON ((-68.45134599473033 -70.9558228557667...\n",
- "7 1 Country POLYGON ((-58.61414282900103 -64.1524671301332...\n",
- "8 1 Country POLYGON ((-67.75 -53.85, -66.45 -54.45, -65.05...\n",
- "9 1 Country POLYGON ((-58.55 -51.1, -57.75 -51.55, -58.05 ...\n",
- "10 1 Country POLYGON ((70.28 -49.71, 68.745 -49.775, 68.72 ...\n",
- "11 1 Country POLYGON ((145.3979781434949 -40.79254851660599...\n",
- "12 1 Country POLYGON ((173.0203747907408 -40.91905242285642...\n",
- "13 1 Country POLYGON ((174.6120089053306 -36.15639739354056...\n",
- "14 1 Country POLYGON ((167.1200114280869 -22.15999073658352...\n",
- "15 1 Country POLYGON ((178.3736000000002 -17.33992, 178.718...\n",
- "16 1 Country POLYGON ((179.3641426619643 -16.80135407694685...\n",
- "17 1 Country POLYGON ((-179.9173693847653 -16.5017831356493...\n",
- "18 1 Country POLYGON ((167.8448767438451 -16.46633310309716...\n",
- "19 1 Country POLYGON ((167.1077124372015 -14.93392017991395...\n",
- "20 1 Country POLYGON ((50.05651085795725 -13.55576140712201...\n",
- "21 1 Country POLYGON ((143.5618111513 -13.76365569423221, 1...\n",
- "22 1 Country POLYGON ((162.1190246930409 -10.48271900802114...\n",
- "23 1 Country POLYGON ((120.7156087586305 -10.23958139408788...\n",
- "24 1 Country POLYGON ((160.852228631838 -9.872937106977105,...\n",
- "25 1 Country POLYGON ((161.6799817242891 -9.599982191611375...\n",
- "26 1 Country POLYGON ((124.4359501486194 -10.14000090906144...\n",
- "27 1 Country POLYGON ((117.9000183452078 -8.095681247594925...\n",
- "28 1 Country POLYGON ((122.9035372254361 -8.094234307490751...\n",
- "29 1 Country POLYGON ((159.8750272971986 -8.337320244991716...\n",
- ".. ... ... ...\n",
- "97 1 Country POLYGON ((-104.5 73.42, -105.38 72.76000000000...\n",
- "98 1 Country POLYGON ((-76.34 73.10268498995302, -76.251403...\n",
- "99 1 Country POLYGON ((-86.56217851433405 73.15744700793854...\n",
- "100 1 Country POLYGON ((-100.35642 73.84389, -99.16387 73.63...\n",
- "101 1 Country POLYGON ((143.60385 73.21244, 142.08763 73.205...\n",
- "102 1 Country POLYGON ((-93.19629553910013 72.77199249947327...\n",
- "103 1 Country POLYGON ((-120.46 71.40000000000001, -123.0921...\n",
- "104 1 Country POLYGON ((150.73167 75.08405999999999, 149.575...\n",
- "105 1 Country POLYGON ((-93.61275590694041 74.97999726022442...\n",
- "106 1 Country POLYGON ((145.086285 75.56262, 144.3 74.819999...\n",
- "107 1 Country POLYGON ((-98.5 76.72, -97.735585 76.256560000...\n",
- "108 1 Country POLYGON ((-108.21141 76.20168, -107.8194299999...\n",
- "109 1 Country POLYGON ((57.5356925799924 70.72046397570224, ...\n",
- "110 1 Country POLYGON ((-94.68408586299947 77.09787832305838...\n",
- "111 1 Country POLYGON ((-116.1985865955074 77.64528677032621...\n",
- "112 1 Country POLYGON ((106.9702758789063 76.97430419921875,...\n",
- "113 1 Country POLYGON ((-93.84000301794401 77.5199972602345,...\n",
- "114 1 Country POLYGON ((-110.1869380359131 77.69701487905039...\n",
- "115 1 Country POLYGON ((24.72412 77.85384999999999, 22.49032...\n",
- "116 1 Country POLYGON ((-109.6631457182026 78.60197256134569...\n",
- "117 1 Country POLYGON ((-95.83029496944926 78.05694122996334...\n",
- "118 1 Country POLYGON ((-100.0601918200522 78.32475434031582...\n",
- "119 1 Country POLYGON ((105.07547 78.30689, 99.43814 77.9210...\n",
- "120 1 Country POLYGON ((18.25183 79.70175, 21.54383 78.95611...\n",
- "121 1 Country POLYGON ((25.44762535981198 80.40734039989459,...\n",
- "122 1 Country POLYGON ((51.13618655783139 80.54728017854103,...\n",
- "123 1 Country POLYGON ((99.93976000000001 78.88094, 97.75794...\n",
- "124 1 Country POLYGON ((-87.02 79.66, -85.81435 79.3369, -87...\n",
- "125 1 Country POLYGON ((-68.5 83.10632151676583, -65.82735 8...\n",
- "126 1 Country POLYGON ((-27.10046 83.51966, -20.84539 82.726...\n",
- "\n",
- "[127 rows x 3 columns]"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "url = \"http://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_110m_land.geojson\"\n",
- "country_gdf = geopandas.read_file(url)\n",
- "display(country_gdf)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": 66,
- "metadata": {},
- "outputs": [],
- "source": [
- "df = pd.read_csv('hex-data.csv')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 67,
- "metadata": {},
- "outputs": [],
- "source": [
- "# assign config = hex_config\n",
- "%run hex_config.py"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 121,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Documentation: https://github.com/keplergl/kepler.gl/blob/master/docs/keplergl-jupyter/user-guide.md\n"
- ]
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "8dca2f6dc2ec4559bc099daa0afa0944",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "KeplerGl(height=500)"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "import keplergl_jupyter as keplergl\n",
- "map_1 = keplergl.KeplerGl(height=500)\n",
- "map_1"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 110,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<style scoped>\n",
- " .dataframe tbody tr th:only-of-type {\n",
- " vertical-align: middle;\n",
- " }\n",
- "\n",
- " .dataframe tbody tr th {\n",
- " vertical-align: top;\n",
- " }\n",
- "\n",
- " .dataframe thead th {\n",
- " text-align: right;\n",
- " }\n",
- "</style>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>geojson_string</th>\n",
- " <th>id</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>{\"type\":\"Polygon\", \"coordinates\":[[[-74.158491...</td>\n",
- " <td>1</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>{\"type\":\"Polygon\", \"coordinates\":[[[-74.387589...</td>\n",
- " <td>2</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "</div>"
- ],
- "text/plain": [
- " geojson_string id\n",
- "0 {\"type\":\"Polygon\", \"coordinates\":[[[-74.158491... 1\n",
- "1 {\"type\":\"Polygon\", \"coordinates\":[[[-74.387589... 2"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "df_with_geometry = pd.DataFrame(\n",
- " {'id': [1, 2],\n",
- " 'geojson_string': [\n",
- " '{\"type\":\"Polygon\", \"coordinates\":[[[-74.158491,40.835947],[-74.157914,40.83902],[-74.148473,40.834522],[-74.146471,40.836645],[-74.142598,40.833128],[-74.140177,40.832492],[-74.136732,40.836791],[-74.142706,40.840604],[-74.144667,40.84312],[-74.142936,40.844974],[-74.136054,40.84119],[-74.1356,40.841703],[-74.133665,40.840712],[-74.133028,40.841321],[-74.13274,40.839586],[-74.121853,40.834098],[-74.121087,40.831],[-74.124447,40.822169],[-74.130031,40.819962],[-74.149242,40.830537],[-74.148818,40.830916],[-74.150888,40.833143],[-74.151923,40.832074],[-74.158491,40.835947]]]}',\n",
- " '{\"type\":\"Polygon\", \"coordinates\":[[[-74.387589,40.632238],[-74.401749,40.640393],[-74.386745,40.653316],[-74.374682,40.646553],[-74.372634,40.6468],[-74.371828,40.644885],[-74.374122,40.642352],[-74.37327,40.641829],[-74.375777,40.636295],[-74.37717,40.634842],[-74.382333,40.632417],[-74.384457,40.630453],[-74.387589,40.632238]]]}' \n",
- " ]\n",
- "})\n",
- "display(df_with_geometry)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 112,
- "metadata": {},
- "outputs": [],
- "source": [
- "df_w_wkt = pd.DataFrame(\n",
- " {'id': [1, 2],\n",
- " 'geojson_string': [\n",
- " \"POLYGON ((-74.158491 40.835947, -74.130031 40.819962, -74.149242 40.830537, -74.148818 40.830916, -74.150888 40.833143, -74.151923 40.832074, -74.158491 40.835947))\",\n",
- " \"POLYGON ((-74.387589 40.632238, -74.375777 40.636295, -74.37717 40.634842, -74.382333 40.632417, -74.384457 40.630453, -74.387589 40.632238))\"\n",
- " ]\n",
- "})"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 133,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "\n"
- ]
- },
- {
- "data": {
- "text/html": [
- "<div>\n",
- "<style scoped>\n",
- " .dataframe tbody tr th:only-of-type {\n",
- " vertical-align: middle;\n",
- " }\n",
- "\n",
- " .dataframe tbody tr th {\n",
- " vertical-align: top;\n",
- " }\n",
- "\n",
- " .dataframe thead th {\n",
- " text-align: right;\n",
- " }\n",
- "</style>\n",
- "<table border=\"1\" class=\"dataframe\">\n",
- " <thead>\n",
- " <tr style=\"text-align: right;\">\n",
- " <th></th>\n",
- " <th>geojson_string</th>\n",
- " <th>id</th>\n",
- " </tr>\n",
- " </thead>\n",
- " <tbody>\n",
- " <tr>\n",
- " <th>0</th>\n",
- " <td>{\"type\": \"Polygon\", \"coordinates\": [[[-74.1584...</td>\n",
- " <td>1</td>\n",
- " </tr>\n",
- " <tr>\n",
- " <th>1</th>\n",
- " <td>{\"type\": \"Polygon\", \"coordinates\": [[[-74.1584...</td>\n",
- " <td>2</td>\n",
- " </tr>\n",
- " </tbody>\n",
- "</table>\n",
- "</div>"
- ],
- "text/plain": [
- " geojson_string id\n",
- "0 {\"type\": \"Polygon\", \"coordinates\": [[[-74.1584... 1\n",
- "1 {\"type\": \"Polygon\", \"coordinates\": [[[-74.1584... 2"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "geometryString = {\n",
- " 'type': 'Polygon',\n",
- " 'coordinates': [[[-74.158491,40.835947],[-74.148473,40.834522],[-74.142598,40.833128],[-74.151923,40.832074],[-74.158491,40.835947]]]\n",
- "}\n",
- "json_str = json.dumps(geometryString)\n",
- "print \n",
- "\n",
- "df_with_geometry = pd.DataFrame({\n",
- " 'id': [1, 2], 'geojson_string': [json_str, json_str]\n",
- "})\n",
- "display(df_with_geometry)\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 134,
- "metadata": {},
- "outputs": [],
- "source": [
- "map_1.add_data(df_with_geometry, \"df_with_geometry_3\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 114,
- "metadata": {},
- "outputs": [],
- "source": [
- "map_1.add_data(df_w_wkt, \"df_w_wkt\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 88,
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "{'df_with_geometry': {'columns': ['geojson_string', 'id'],\n",
- " 'data': [['{type:Polygon,coordinates:[[[-74.158491,40.835947],[-74.157914,40.83902],[-74.148473,40.834522],[-74.146471,40.836645],[-74.142598,40.833128],[-74.140177,40.832492],[-74.136732,40.836791],[-74.142706,40.840604],[-74.144667,40.84312],[-74.142936,40.844974],[-74.136054,40.84119],[-74.1356,40.841703],[-74.133665,40.840712],[-74.133028,40.841321],[-74.13274,40.839586],[-74.121853,40.834098],[-74.121087,40.831],[-74.124447,40.822169],[-74.130031,40.819962],[-74.149242,40.830537],[-74.148818,40.830916],[-74.150888,40.833143],[-74.151923,40.832074],[-74.158491,40.835947]]]}',\n",
- " 1],\n",
- " ['{type:Polygon,coordinates:[[[-74.387589,40.632238],[-74.401749,40.640393],[-74.386745,40.653316],[-74.374682,40.646553],[-74.372634,40.6468],[-74.371828,40.644885],[-74.374122,40.642352],[-74.37327,40.641829],[-74.375777,40.636295],[-74.37717,40.634842],[-74.382333,40.632417],[-74.384457,40.630453],[-74.387589,40.632238]]]}',\n",
- " 2]],\n",
- " 'index': [0, 1]}}"
- ]
- },
- "execution_count": 88,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "map_1.data"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 2",
- "language": "python",
- "name": "python2"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 2
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython2",
- "version": "2.7.15"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}