├── README.md
├── data
├── US_Unemployment_Oct2012.csv
├── data.json
├── itaguare_cropped.jpg
├── mercator_temperature.mat
├── tri.json
└── us-states.json
├── environment.yml
├── test_3D.ipynb
├── test_add_tile_layer.ipynb
├── test_choropleth.ipynb
├── test_choropleth_geostr.ipynb
├── test_choropleth_negative_values.ipynb
├── test_choropleth_own_scale.ipynb
├── test_choropleth_topojson.ipynb
├── test_clustered_markes.ipynb
├── test_control_scale.ipynb
├── test_custom_icon.ipynb
├── test_devs.ipynb
├── test_embed.ipynb
├── test_feature_group.ipynb
├── test_filled_polygon.ipynb
├── test_fit_bounds.ipynb
├── test_geojson_popup.ipynb
├── test_heatmap.ipynb
├── test_icon.ipynb
├── test_image_overlay.ipynb
├── test_image_overlay_geodetic.ipynb
├── test_image_overlay_gulf_stream.ipynb
├── test_image_overlay_wms.ipynb
├── test_key_on.ipynb
├── test_lines.ipynb
├── test_mplleaflet.ipynb
├── test_multipolyline.ipynb
├── test_no_tiles_just_geojson.ipynb
├── test_png_mpld3_vega_popup.ipynb
├── test_popups.ipynb
├── test_popups_formats.ipynb
├── test_scatter_plot.ipynb
├── test_tiles.ipynb
├── test_vincent_popup_width.ipynb
├── test_width_height.ipynb
├── test_wms.ipynb
├── test_zoom.ipynb
└── test_zorder.ipynb
/README.md:
--------------------------------------------------------------------------------
1 | # Folium notebooks examples
2 |
3 | [](https://mybinder.org/v2/gh/ocefpaf/folium_notebooks/main)
4 |
5 | Some misc notebook showing how to use folium.
6 |
7 |
--------------------------------------------------------------------------------
/data/US_Unemployment_Oct2012.csv:
--------------------------------------------------------------------------------
1 | State,Unemployment
2 | AL,7.1
3 | AK,6.8
4 | AZ,8.1
5 | AR,7.2
6 | CA,10.1
7 | CO,7.7
8 | CT,8.4
9 | DE,7.1
10 | FL,8.2
11 | GA,8.8
12 | HI,5.4
13 | ID,6.6
14 | IL,8.8
15 | IN,8.4
16 | IA,5.1
17 | KS,5.6
18 | KY,8.1
19 | LA,5.9
20 | ME,7.2
21 | MD,6.8
22 | MA,6.7
23 | MI,9.1
24 | MN,5.6
25 | MS,9.1
26 | MO,6.7
27 | MT,5.8
28 | NE,3.9
29 | NV,10.3
30 | NH,5.7
31 | NJ,9.6
32 | NM,6.8
33 | NY,8.4
34 | NC,9.4
35 | ND,3.2
36 | OH,6.9
37 | OK,5.2
38 | OR,8.5
39 | PA,8
40 | RI,10.1
41 | SC,8.8
42 | SD,4.4
43 | TN,7.8
44 | TX,6.4
45 | UT,5.5
46 | VT,5
47 | VA,5.8
48 | WA,7.8
49 | WV,7.5
50 | WI,6.8
51 | WY,5.1
--------------------------------------------------------------------------------
/data/data.json:
--------------------------------------------------------------------------------
1 | [{"WA": 7.8, "DE": 7.1, "WI": 6.8, "WV": 7.5, "HI": 5.4, "FL": 8.2, "WY": 5.1, "NH": 5.7, "NJ": 9.6, "NM": 6.8, "TX": 6.4, "LA": 5.9, "NC": 9.4, "ND": 3.2, "NE": 3.9, "TN": 7.8, "NY": 8.4, "PA": 8.0, "CA": 10.1, "NV": 10.3, "VA": 5.8, "CO": 7.7, "AK": 6.8, "AL": 7.1, "AR": 7.2, "VT": 5.0, "IL": 8.8, "GA": 8.8, "IN": 8.4, "IA": 5.1, "OK": 5.2, "AZ": 8.1, "ID": 6.6, "CT": 8.4, "ME": 7.2, "MD": 6.8, "MA": 6.7, "OH": 6.9, "UT": 5.5, "MO": 6.7, "MN": 5.6, "MI": 9.1, "RI": 10.1, "KS": 5.6, "MT": 5.8, "MS": 9.1, "SC": 8.8, "KY": 8.1, "OR": 8.5, "SD": 4.4}]
--------------------------------------------------------------------------------
/data/itaguare_cropped.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocefpaf/folium_notebooks/1c15d3ab698951349fda8fd9d436989ea46a3efc/data/itaguare_cropped.jpg
--------------------------------------------------------------------------------
/data/mercator_temperature.mat:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocefpaf/folium_notebooks/1c15d3ab698951349fda8fd9d436989ea46a3efc/data/mercator_temperature.mat
--------------------------------------------------------------------------------
/data/tri.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "FeatureCollection",
3 | "features": [
4 | {
5 | "geometry": {
6 | "type": "Polygon",
7 | "coordinates": [
8 | [
9 | [
10 | -117.7495299744,
11 | 35.7405399984
12 | ],
13 | [
14 | -117.7422264169,
15 | 35.7472081889
16 | ],
17 | [
18 | -117.7521555454,
19 | 35.7536368252
20 | ]
21 | ]
22 | ]
23 | },
24 | "type": "Feature",
25 | "id": 1,
26 | "properties": {
27 | "name": "AirportLake,Subsection0",
28 | "popupContent": "sid:1 fault:AirportLake,Subsection0"
29 | }
30 | }
31 | ]
32 | }
33 |
--------------------------------------------------------------------------------
/environment.yml:
--------------------------------------------------------------------------------
1 | # conda env create environment.yml
2 | name: folium
3 | channels:
4 | - ioos
5 | dependencies:
6 | - cartopy
7 | - folium
8 | - mpld3
9 | - numpy
10 | - oceans
11 | - pandas
12 | - pillow
13 | - scipy
14 | - vincent
15 |
--------------------------------------------------------------------------------
/test_3D.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [],
33 | "source": [
34 | "from folium.features import Template\n",
35 | "\n",
36 | "class Map3d(folium.Map):\n",
37 | " def __init__(self, location=None, width='100%', height='100%', left='0%',\n",
38 | " top='0%', position='relative', tiles='OpenStreetMap', API_key=None,\n",
39 | " max_zoom=18, min_zoom=1, zoom_start=10, attr=None, min_lat=-90,\n",
40 | " max_lat=90, min_lon=-180, max_lon=180, detect_retina=False, crs='EPSG3857'):\n",
41 | " super(Map3d, self).__init__(location=location, width=width, height=height,\n",
42 | " left=left, top=top, position=position, tiles=tiles,\n",
43 | " API_key=API_key, max_zoom=max_zoom, min_zoom=min_zoom,\n",
44 | " zoom_start=zoom_start, attr=attr, min_lat=min_lat,\n",
45 | " max_lat=max_lat, min_lon=min_lon, max_lon=max_lon,\n",
46 | " detect_retina=detect_retina, crs=crs)\n",
47 | " self._template = Template(u\"\"\"\n",
48 | " {% macro header(this, kwargs) %}\n",
49 | " \n",
50 | " \n",
58 | " {% endmacro %}\n",
59 | " {% macro html(this, kwargs) %}\n",
60 | "
\n",
61 | " {% endmacro %}\n",
62 | "\n",
63 | " {% macro script(this, kwargs) %}\n",
64 | "\n",
65 | " var southWest = L.latLng({{ this.min_lat }}, {{ this.min_lon }});\n",
66 | " var northEast = L.latLng({{ this.max_lat }}, {{ this.max_lon }});\n",
67 | " var bounds = L.latLngBounds(southWest, northEast);\n",
68 | "\n",
69 | " var {{this.get_name()}} = WE.map('{{this.get_name()}}', {\n",
70 | " center:[{{this.location[0]}},{{this.location[1]}}],\n",
71 | " zoom: {{this.zoom_start}},\n",
72 | " maxBounds: bounds,\n",
73 | " layers: [],\n",
74 | " crs: L.CRS.{{this.crs}}\n",
75 | " });\n",
76 | " {% endmacro %}\n",
77 | " \"\"\")\n",
78 | "\n",
79 | "\n",
80 | "class TileLayer3d(folium.TileLayer):\n",
81 | " def __init__(self, tiles='OpenStreetMap', min_zoom=1, max_zoom=18, attr=None,\n",
82 | " API_key=None, detect_retina=False, name=None, overlay=False, control=True):\n",
83 | " super(TileLayer3d, self).__init__(tiles=tiles,\n",
84 | " min_zoom=min_zoom, max_zoom=max_zoom, attr=attr,\n",
85 | " API_key=API_key, detect_retina=detect_retina, name=name,\n",
86 | " overlay=overlay, control=control)\n",
87 | " self._template = Template(u\"\"\"\n",
88 | " {% macro script(this, kwargs) %}\n",
89 | " var {{this.get_name()}} = WE.tileLayer(\n",
90 | " '{{this.tiles}}',\n",
91 | " {\n",
92 | " maxZoom: {{this.max_zoom}},\n",
93 | " minZoom: {{this.min_zoom}},\n",
94 | " attribution: '{{this.attr}}',\n",
95 | " detectRetina: {{this.detect_retina.__str__().lower()}}\n",
96 | " }\n",
97 | " ).addTo({{this._parent.get_name()}});\n",
98 | "\n",
99 | " {% endmacro %}\n",
100 | " \"\"\")"
101 | ]
102 | },
103 | {
104 | "cell_type": "code",
105 | "execution_count": 3,
106 | "metadata": {
107 | "collapsed": false
108 | },
109 | "outputs": [
110 | {
111 | "data": {
112 | "text/html": [
113 | ""
114 | ],
115 | "text/plain": [
116 | "<__main__.Map3d at 0x7f1a482210d0>"
117 | ]
118 | },
119 | "execution_count": 3,
120 | "metadata": {},
121 | "output_type": "execute_result"
122 | }
123 | ],
124 | "source": [
125 | "mapa = Map3d(location=[-42, -42], tiles=None, zoom_start=2)\n",
126 | "mapa.add_child(TileLayer3d(tiles='OpenStreetMap'))\n",
127 | "\n",
128 | "url = ('http://services.arcgisonline.com/arcgis/rest/services'\n",
129 | " 'Ocean/World_Ocean_Base'\n",
130 | " 'MapServer/tile/{z}/{y}/{x}')\n",
131 | "\n",
132 | "folium.TileLayer(tiles=url,\n",
133 | " name='World_Ocean_Base',\n",
134 | " attr='ESRI',\n",
135 | " overlay=True).add_to(mapa)\n",
136 | "\n",
137 | "folium.LayerControl().add_to(mapa)\n",
138 | "\n",
139 | "mapa"
140 | ]
141 | }
142 | ],
143 | "metadata": {
144 | "kernelspec": {
145 | "display_name": "Iris (Python 2)",
146 | "language": "python",
147 | "name": "iris_python2"
148 | },
149 | "language_info": {
150 | "codemirror_mode": {
151 | "name": "ipython",
152 | "version": 2
153 | },
154 | "file_extension": ".py",
155 | "mimetype": "text/x-python",
156 | "name": "python",
157 | "nbconvert_exporter": "python",
158 | "pygments_lexer": "ipython2",
159 | "version": "2.7.8"
160 | }
161 | },
162 | "nbformat": 4,
163 | "nbformat_minor": 0
164 | }
165 |
--------------------------------------------------------------------------------
/test_add_tile_layer.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [
33 | {
34 | "data": {
35 | "text/html": [
36 | ""
37 | ],
38 | "text/plain": [
39 | ""
40 | ]
41 | },
42 | "execution_count": 2,
43 | "metadata": {},
44 | "output_type": "execute_result"
45 | }
46 | ],
47 | "source": [
48 | "mapa = folium.Map(location=[-10, -20], zoom_start=4)\n",
49 | "\n",
50 | "pre = 'http://services.arcgisonline.com/arcgis/rest/services'\n",
51 | "pos = 'MapServer/tile/{z}/{y}/{x}'\n",
52 | "\n",
53 | "ESRI = dict(World_Ocean_Base='Ocean/World_Ocean_Base',\n",
54 | " World_Ocean_Reference='Ocean/World_Ocean_Reference',\n",
55 | " NatGeo_World_Map='NatGeo_World_Map/MapServer',\n",
56 | " World_Imagery='World_Imagery/MapServer',\n",
57 | " World_Physical_Map='World_Physical_Map/MapServer',\n",
58 | " World_Shaded_Relief='World_Shaded_Relief/MapServer',\n",
59 | " World_Street_Map='World_Street_Map/MapServer',\n",
60 | " World_Terrain_Base='World_Terrain_Base/MapServer',\n",
61 | " World_Topo_Map='World_Topo_Map/MapServer')\n",
62 | "\n",
63 | "for name, tile in ESRI.items():\n",
64 | " url = '{}/{}/{}'.format(pre, tile, pos)\n",
65 | " w = folium.TileLayer(tiles=url,\n",
66 | " name=name,\n",
67 | " attr='ESRI',\n",
68 | " overlay=True)\n",
69 | " w.add_to(mapa)\n",
70 | "\n",
71 | "\n",
72 | "# FIXME: active=False by default.\n",
73 | "mapa.add_children(folium.LayerControl())\n",
74 | "mapa"
75 | ]
76 | },
77 | {
78 | "cell_type": "markdown",
79 | "metadata": {},
80 | "source": [
81 | "# TODO: Add the rest of the options to the template and docstrings."
82 | ]
83 | },
84 | {
85 | "cell_type": "code",
86 | "execution_count": null,
87 | "metadata": {
88 | "collapsed": true
89 | },
90 | "outputs": [],
91 | "source": [
92 | "mapa = folium.Map(location=[-10, -20], zoom_start=1)\n",
93 | "\n",
94 | "url = ('http://services.arcgisonline.com/ArcGIS/'\n",
95 | " 'rest/services/Specialty/World_Navigation_Charts')\n",
96 | "\n",
97 | "kw = dict(minZoom=0, # Number\n",
98 | " maxZoom=18, # Number\n",
99 | " maxNativeZoom=None, # null, Number\n",
100 | " tileSize=256, # Number\n",
101 | " subdomains='abc', # 'abc', String or String[]\n",
102 | " errorTileUrl='', # String\n",
103 | " attr='', # String\n",
104 | " tms=False, # Boolean\n",
105 | " continuousWorld=False, # Boolean\n",
106 | " noWrap=False, # Boolean\n",
107 | " zoomOffset=0, # Number\n",
108 | " zoomReverse=False, # Boolean\n",
109 | " opacity=1.0, # Number\n",
110 | " zIndex=None, # null, Number\n",
111 | " unloadInvisibleTiles=False, # Boolean\n",
112 | " updateWhenIdle=False, # Boolean\n",
113 | " detectRetina=False, # Boolean\n",
114 | " reuseTiles=False, # Boolean\n",
115 | " bounds=None, # null, LatLngBounds\n",
116 | " )\n",
117 | "\n",
118 | "w = folium.TileLayer(tiles=url,\n",
119 | " name='World_Navigation_Charts',\n",
120 | " overlay=True, **kw)\n",
121 | "\n",
122 | "mapa.add_children(folium.LayerControl())\n",
123 | "mapa"
124 | ]
125 | }
126 | ],
127 | "metadata": {
128 | "kernelspec": {
129 | "display_name": "Iris (Python 2)",
130 | "language": "python",
131 | "name": "iris_python2"
132 | },
133 | "language_info": {
134 | "codemirror_mode": {
135 | "name": "ipython",
136 | "version": 2
137 | },
138 | "file_extension": ".py",
139 | "mimetype": "text/x-python",
140 | "name": "python",
141 | "nbconvert_exporter": "python",
142 | "pygments_lexer": "ipython2",
143 | "version": "2.7.8"
144 | }
145 | },
146 | "nbformat": 4,
147 | "nbformat_minor": 0
148 | }
149 |
--------------------------------------------------------------------------------
/test_control_scale.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [
33 | {
34 | "data": {
35 | "text/html": [
36 | ""
37 | ],
38 | "text/plain": [
39 | ""
40 | ]
41 | },
42 | "execution_count": 2,
43 | "metadata": {},
44 | "output_type": "execute_result"
45 | }
46 | ],
47 | "source": [
48 | "lon, lat = -38.625, -12.875\n",
49 | "\n",
50 | "zoom_start = 8\n",
51 | "\n",
52 | "folium.Map(location=[lat, lon], tiles=\"OpenStreetMap\", zoom_start=zoom_start, control_scale=True)"
53 | ]
54 | }
55 | ],
56 | "metadata": {
57 | "gist_id": "8f78beb9f1779a152836",
58 | "kernelspec": {
59 | "display_name": "Iris (Python 2)",
60 | "language": "python",
61 | "name": "iris_python2"
62 | },
63 | "language_info": {
64 | "codemirror_mode": {
65 | "name": "ipython",
66 | "version": 2
67 | },
68 | "file_extension": ".py",
69 | "mimetype": "text/x-python",
70 | "name": "python",
71 | "nbconvert_exporter": "python",
72 | "pygments_lexer": "ipython2",
73 | "version": "2.7.8"
74 | }
75 | },
76 | "nbformat": 4,
77 | "nbformat_minor": 0
78 | }
79 |
--------------------------------------------------------------------------------
/test_custom_icon.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [
33 | {
34 | "data": {
35 | "text/html": [
36 | ""
37 | ],
38 | "text/plain": [
39 | ""
40 | ]
41 | },
42 | "execution_count": 2,
43 | "metadata": {},
44 | "output_type": "execute_result"
45 | }
46 | ],
47 | "source": [
48 | "from folium.features import CustomIcon\n",
49 | "\n",
50 | "mapa = folium.Map(location=[45.372, -121.6972], zoom_start=12,tiles='Stamen Terrain')\n",
51 | "\n",
52 | "icon_image = \"http://leafletjs.com/docs/images/leaf-green.png\"\n",
53 | "shadow_image = \"http://leafletjs.com/docs/images/leaf-shadow.png\"\n",
54 | "\n",
55 | "icon = CustomIcon(icon_image,\n",
56 | " icon_size=(38,95),\n",
57 | " icon_anchor=(22,94),\n",
58 | " shadow_image=shadow_image,\n",
59 | " shadow_size=(50,64),\n",
60 | " shadow_anchor=(4,62),\n",
61 | " popup_anchor=(-3,-76))\n",
62 | "\n",
63 | "marker = folium.Marker([45.3288, -121.6625], icon=icon,\n",
64 | " popup='Mt. Hood Meadows')\n",
65 | "\n",
66 | "\n",
67 | "mapa.add_children(marker)\n",
68 | "mapa"
69 | ]
70 | }
71 | ],
72 | "metadata": {
73 | "kernelspec": {
74 | "display_name": "Iris (Python 2)",
75 | "language": "python",
76 | "name": "iris_python2"
77 | },
78 | "language_info": {
79 | "codemirror_mode": {
80 | "name": "ipython",
81 | "version": 2
82 | },
83 | "file_extension": ".py",
84 | "mimetype": "text/x-python",
85 | "name": "python",
86 | "nbconvert_exporter": "python",
87 | "pygments_lexer": "ipython2",
88 | "version": "2.7.8"
89 | }
90 | },
91 | "nbformat": 4,
92 | "nbformat_minor": 0
93 | }
94 |
--------------------------------------------------------------------------------
/test_devs.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [
33 | {
34 | "name": "stderr",
35 | "output_type": "stream",
36 | "text": [
37 | "-c:11: FutureWarning: simple_marker is deprecated. Use add_children(Marker) instead\n"
38 | ]
39 | },
40 | {
41 | "data": {
42 | "text/html": [
43 | ""
44 | ],
45 | "text/plain": [
46 | ""
47 | ]
48 | },
49 | "execution_count": 2,
50 | "metadata": {},
51 | "output_type": "execute_result"
52 | }
53 | ],
54 | "source": [
55 | "lon, lat, zoom_start = 0, 0, 4\n",
56 | "\n",
57 | "positron = folium.Map(location=[lat, lon], tiles='Cartodb Positron', zoom_start=zoom_start)\n",
58 | "\n",
59 | "devs = dict(ocefpaf=[-12.974722, -38.476667])\n",
60 | "\n",
61 | "url = \"http://github.com/{}?mobile=1\".format('ocefpaf')\n",
62 | "popup = \"\".format(url)\n",
63 | "\n",
64 | "for dev, location in devs.items():\n",
65 | " positron.simple_marker(location, popup=popup)\n",
66 | "\n",
67 | "positron"
68 | ]
69 | }
70 | ],
71 | "metadata": {
72 | "kernelspec": {
73 | "display_name": "Iris (Python 2)",
74 | "language": "python",
75 | "name": "iris_python2"
76 | },
77 | "language_info": {
78 | "codemirror_mode": {
79 | "name": "ipython",
80 | "version": 2
81 | },
82 | "file_extension": ".py",
83 | "mimetype": "text/x-python",
84 | "name": "python",
85 | "nbconvert_exporter": "python",
86 | "pygments_lexer": "ipython2",
87 | "version": "2.7.8"
88 | }
89 | },
90 | "nbformat": 4,
91 | "nbformat_minor": 0
92 | }
93 |
--------------------------------------------------------------------------------
/test_feature_group.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [
33 | {
34 | "data": {
35 | "text/html": [
36 | ""
37 | ],
38 | "text/plain": [
39 | ""
40 | ]
41 | },
42 | "execution_count": 2,
43 | "metadata": {},
44 | "output_type": "execute_result"
45 | }
46 | ],
47 | "source": [
48 | "from folium import Map, FeatureGroup, Marker, LayerControl\n",
49 | "\n",
50 | "mapa = Map(location=[45.372, -121.6972], zoom_start=12,\n",
51 | " tiles='Stamen Terrain')\n",
52 | "\n",
53 | "feature_group = FeatureGroup(name='Some icons')\n",
54 | "feature_group.add_children(Marker([45.3288, -121.6625], popup='Mt. Hood Meadows'))\n",
55 | "feature_group.add_children(Marker([45.3311, -121.7113], popup='Timberline Lodge'))\n",
56 | "mapa.add_children(feature_group)\n",
57 | "mapa.add_children(LayerControl())\n",
58 | "\n",
59 | "mapa"
60 | ]
61 | }
62 | ],
63 | "metadata": {
64 | "kernelspec": {
65 | "display_name": "Iris (Python 2)",
66 | "language": "python",
67 | "name": "iris_python2"
68 | },
69 | "language_info": {
70 | "codemirror_mode": {
71 | "name": "ipython",
72 | "version": 2
73 | },
74 | "file_extension": ".py",
75 | "mimetype": "text/x-python",
76 | "name": "python",
77 | "nbconvert_exporter": "python",
78 | "pygments_lexer": "ipython2",
79 | "version": "2.7.8"
80 | }
81 | },
82 | "nbformat": 4,
83 | "nbformat_minor": 0
84 | }
85 |
--------------------------------------------------------------------------------
/test_filled_polygon.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [
33 | {
34 | "data": {
35 | "text/html": [
36 | ""
37 | ],
38 | "text/plain": [
39 | ""
40 | ]
41 | },
42 | "execution_count": 2,
43 | "metadata": {},
44 | "output_type": "execute_result"
45 | }
46 | ],
47 | "source": [
48 | "mapa = folium.Map(location=[45.5236, -122.6750], zoom_start=13)\n",
49 | "\n",
50 | "p = folium.RegularPolygonMarker(location=[45.5318, -122.6745],\n",
51 | " popup='Broadway Bridge',\n",
52 | " color='red',\n",
53 | " opacity=1,\n",
54 | " weight=2,\n",
55 | " fill_color='blue',\n",
56 | " fill_opacity=1,\n",
57 | " number_of_sides=8,\n",
58 | " rotation=0,\n",
59 | " radius=10)\n",
60 | "mapa.add_children(p)\n",
61 | "mapa"
62 | ]
63 | }
64 | ],
65 | "metadata": {
66 | "kernelspec": {
67 | "display_name": "Iris (Python 2)",
68 | "language": "python",
69 | "name": "iris_python2"
70 | },
71 | "language_info": {
72 | "codemirror_mode": {
73 | "name": "ipython",
74 | "version": 2
75 | },
76 | "file_extension": ".py",
77 | "mimetype": "text/x-python",
78 | "name": "python",
79 | "nbconvert_exporter": "python",
80 | "pygments_lexer": "ipython2",
81 | "version": "2.7.8"
82 | }
83 | },
84 | "nbformat": 4,
85 | "nbformat_minor": 0
86 | }
87 |
--------------------------------------------------------------------------------
/test_geojson_popup.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [
33 | {
34 | "data": {
35 | "text/html": [
36 | ""
37 | ],
38 | "text/plain": [
39 | ""
40 | ]
41 | },
42 | "execution_count": 2,
43 | "metadata": {},
44 | "output_type": "execute_result"
45 | }
46 | ],
47 | "source": [
48 | "import json\n",
49 | "\n",
50 | "with open('data/tri.json') as f:\n",
51 | " gj = folium.GeoJson(json.load(f))\n",
52 | "\n",
53 | "mapa = folium.Map(location=[35.74053999839425, -117.7495299743632], zoom_start=12)\n",
54 | "mapa.add_children(gj)\n",
55 | "\n",
56 | "mapa"
57 | ]
58 | }
59 | ],
60 | "metadata": {
61 | "kernelspec": {
62 | "display_name": "Iris (Python 2)",
63 | "language": "python",
64 | "name": "iris_python2"
65 | },
66 | "language_info": {
67 | "codemirror_mode": {
68 | "name": "ipython",
69 | "version": 2
70 | },
71 | "file_extension": ".py",
72 | "mimetype": "text/x-python",
73 | "name": "python",
74 | "nbconvert_exporter": "python",
75 | "pygments_lexer": "ipython2",
76 | "version": "2.7.8"
77 | }
78 | },
79 | "nbformat": 4,
80 | "nbformat_minor": 0
81 | }
82 |
--------------------------------------------------------------------------------
/test_heatmap.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "from folium import plugins\n",
22 | "\n",
23 | "print(folium.__file__)\n",
24 | "print(folium.__version__)"
25 | ]
26 | },
27 | {
28 | "cell_type": "code",
29 | "execution_count": 2,
30 | "metadata": {
31 | "collapsed": false
32 | },
33 | "outputs": [],
34 | "source": [
35 | "import numpy as np\n",
36 | "\n",
37 | "data = (np.random.normal(size=(100, 3)) *\n",
38 | " np.array([[1, 1, 1]]) +\n",
39 | " np.array([[48, 5, 1]])).tolist()"
40 | ]
41 | },
42 | {
43 | "cell_type": "code",
44 | "execution_count": 3,
45 | "metadata": {
46 | "collapsed": false
47 | },
48 | "outputs": [
49 | {
50 | "data": {
51 | "text/html": [
52 | ""
53 | ],
54 | "text/plain": [
55 | ""
56 | ]
57 | },
58 | "execution_count": 3,
59 | "metadata": {},
60 | "output_type": "execute_result"
61 | }
62 | ],
63 | "source": [
64 | "mapa = folium.Map([48., 5.], tiles='stamentoner', zoom_start=6)\n",
65 | "mapa.add_children(plugins.HeatMap(data))\n",
66 | "mapa"
67 | ]
68 | }
69 | ],
70 | "metadata": {
71 | "kernelspec": {
72 | "display_name": "Iris (Python 2)",
73 | "language": "python",
74 | "name": "iris_python2"
75 | },
76 | "language_info": {
77 | "codemirror_mode": {
78 | "name": "ipython",
79 | "version": 2
80 | },
81 | "file_extension": ".py",
82 | "mimetype": "text/x-python",
83 | "name": "python",
84 | "nbconvert_exporter": "python",
85 | "pygments_lexer": "ipython2",
86 | "version": "2.7.8"
87 | }
88 | },
89 | "nbformat": 4,
90 | "nbformat_minor": 0
91 | }
92 |
--------------------------------------------------------------------------------
/test_icon.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [
33 | {
34 | "data": {
35 | "text/html": [
36 | ""
37 | ],
38 | "text/plain": [
39 | ""
40 | ]
41 | },
42 | "execution_count": 2,
43 | "metadata": {},
44 | "output_type": "execute_result"
45 | }
46 | ],
47 | "source": [
48 | "mapa = folium.Map(location=[45.372, -121.6972], zoom_start=12, tiles='Stamen Terrain')\n",
49 | "\n",
50 | "icon = folium.Icon(color='blue', icon_color='white', icon='cloud',\n",
51 | " angle=0, prefix='glyphicon')\n",
52 | "p0 = folium.Marker([45.3788, -121.6625], popup='Mt. Hood Meadows', icon=icon)\n",
53 | "\n",
54 | "icon = folium.Icon(color='green')\n",
55 | "p1 = folium.Marker([45.3711, -121.7113], popup='Timberline Lodge', icon=icon)\n",
56 | "\n",
57 | "p2 = folium.Marker([45.3700, -121.6823], popup='simple')\n",
58 | "\n",
59 | "mapa.add_children(p0)\n",
60 | "mapa.add_children(p1)\n",
61 | "mapa.add_children(p2)\n",
62 | "mapa"
63 | ]
64 | }
65 | ],
66 | "metadata": {
67 | "kernelspec": {
68 | "display_name": "Iris (Python 2)",
69 | "language": "python",
70 | "name": "iris_python2"
71 | },
72 | "language_info": {
73 | "codemirror_mode": {
74 | "name": "ipython",
75 | "version": 2
76 | },
77 | "file_extension": ".py",
78 | "mimetype": "text/x-python",
79 | "name": "python",
80 | "nbconvert_exporter": "python",
81 | "pygments_lexer": "ipython2",
82 | "version": "2.7.8"
83 | }
84 | },
85 | "nbformat": 4,
86 | "nbformat_minor": 0
87 | }
88 |
--------------------------------------------------------------------------------
/test_image_overlay.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [
33 | {
34 | "data": {
35 | "text/html": [
36 | ""
37 | ],
38 | "text/plain": [
39 | ""
40 | ]
41 | },
42 | "execution_count": 2,
43 | "metadata": {},
44 | "output_type": "execute_result"
45 | }
46 | ],
47 | "source": [
48 | "import matplotlib.pyplot as plt\n",
49 | "\n",
50 | "from folium import plugins\n",
51 | "\n",
52 | "fname = (\"https://raw.githubusercontent.com/ocefpaf/\"\n",
53 | " \"python4oceanographers/master/content/downloads/\"\n",
54 | " \"notebooks/data/itaguare_cropped.jpg\")\n",
55 | "\n",
56 | "min_lon = -(45 + (58 + 32.27/60) / 60) # 45°58'32.27\"W\n",
57 | "max_lon = -(45 + (57 + 54.54/60) / 60) # 45°57'54.54\"W\n",
58 | "min_lat = -(23 + (47 + 7.65/60) / 60) # 23°47' 7.65\"S\n",
59 | "max_lat = -(23 + (46 + 42.25/60) / 60) # 23°46'42.25\"S\n",
60 | "\n",
61 | "kw = dict(width=650, height=500,\n",
62 | " min_lon=min_lon, max_lon=max_lon,\n",
63 | " min_lat=min_lat, max_lat=max_lat,\n",
64 | " zoom_start=15)\n",
65 | "\n",
66 | "mapa = folium.Map(location=[-47.563861111111109, -91.940780555555563],\n",
67 | " tiles='Stamen Toner', **kw)\n",
68 | "\n",
69 | "plugins.ImageOverlay(fname,\n",
70 | " [[min_lat, min_lon], [max_lat, max_lon]], mercator_project=False,\n",
71 | " opacity=1).add_to(mapa)\n",
72 | "\n",
73 | "mapa"
74 | ]
75 | }
76 | ],
77 | "metadata": {
78 | "kernelspec": {
79 | "display_name": "Iris (Python 2)",
80 | "language": "python",
81 | "name": "iris_python2"
82 | },
83 | "language_info": {
84 | "codemirror_mode": {
85 | "name": "ipython",
86 | "version": 2
87 | },
88 | "file_extension": ".py",
89 | "mimetype": "text/x-python",
90 | "name": "python",
91 | "nbconvert_exporter": "python",
92 | "pygments_lexer": "ipython2",
93 | "version": "2.7.8"
94 | }
95 | },
96 | "nbformat": 4,
97 | "nbformat_minor": 0
98 | }
99 |
--------------------------------------------------------------------------------
/test_lines.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [],
33 | "source": [
34 | "import numpy as np\n",
35 | "\n",
36 | "\n",
37 | "def get_coordinates(bbox):\n",
38 | " \"\"\"\n",
39 | " Create bounding box coordinates for the map. It takes flat or\n",
40 | " nested list/numpy.array and returns 5 points that closes square\n",
41 | " around the borders.\n",
42 | "\n",
43 | " Examples\n",
44 | " --------\n",
45 | " >>> bbox = [-87.40, 24.25, -74.70, 36.70]\n",
46 | " >>> len(get_coordinates(bbox))\n",
47 | " 5\n",
48 | "\n",
49 | " \"\"\"\n",
50 | " bbox = np.asanyarray(bbox).ravel()\n",
51 | " if bbox.size == 4:\n",
52 | " bbox = bbox.reshape(2, 2)\n",
53 | " coordinates = []\n",
54 | " coordinates.append([bbox[0][1], bbox[0][0]])\n",
55 | " coordinates.append([bbox[0][1], bbox[1][0]])\n",
56 | " coordinates.append([bbox[1][1], bbox[1][0]])\n",
57 | " coordinates.append([bbox[1][1], bbox[0][0]])\n",
58 | " coordinates.append([bbox[0][1], bbox[0][0]])\n",
59 | " else:\n",
60 | " raise ValueError('Wrong number corners.'\n",
61 | " ' Expected 4 got {}'.format(bbox.size))\n",
62 | " return coordinates"
63 | ]
64 | },
65 | {
66 | "cell_type": "code",
67 | "execution_count": 3,
68 | "metadata": {
69 | "collapsed": false
70 | },
71 | "outputs": [
72 | {
73 | "data": {
74 | "text/html": [
75 | ""
76 | ],
77 | "text/plain": [
78 | ""
79 | ]
80 | },
81 | "execution_count": 3,
82 | "metadata": {},
83 | "output_type": "execute_result"
84 | }
85 | ],
86 | "source": [
87 | "lon = lat = 0\n",
88 | "zoom_start = 1\n",
89 | "\n",
90 | "mapa = folium.Map(location=[lat, lon], zoom_start=zoom_start)\n",
91 | "\n",
92 | "kw = dict(opacity=1.0, weight=4)\n",
93 | "\n",
94 | "# Wrong.\n",
95 | "l0 = folium.PolyLine(locations=[(2, 179), (2, -179)], color='red', **kw)\n",
96 | "\n",
97 | "# Correct.\n",
98 | "l1 = folium.PolyLine(locations=[(-2, 179), (-2, 181)], color='blue', **kw)\n",
99 | "\n",
100 | "# Correct.\n",
101 | "l2 = folium.PolyLine(locations=[(-6, -179), (-6, 179)], color='green', **kw)\n",
102 | "\n",
103 | "# Artifact?\n",
104 | "l3 = folium.PolyLine(locations=[(12, -179), (12, 190)], color='orange', **kw)\n",
105 | "\n",
106 | "for l in [l0, l1, l2, l3]:\n",
107 | " mapa.add_children(l)\n",
108 | "\n",
109 | "mapa"
110 | ]
111 | }
112 | ],
113 | "metadata": {
114 | "kernelspec": {
115 | "display_name": "Iris (Python 2)",
116 | "language": "python",
117 | "name": "iris_python2"
118 | },
119 | "language_info": {
120 | "codemirror_mode": {
121 | "name": "ipython",
122 | "version": 2
123 | },
124 | "file_extension": ".py",
125 | "mimetype": "text/x-python",
126 | "name": "python",
127 | "nbconvert_exporter": "python",
128 | "pygments_lexer": "ipython2",
129 | "version": "2.7.8"
130 | }
131 | },
132 | "nbformat": 4,
133 | "nbformat_minor": 0
134 | }
135 |
--------------------------------------------------------------------------------
/test_multipolyline.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [
33 | {
34 | "data": {
35 | "text/html": [
36 | ""
37 | ],
38 | "text/plain": [
39 | ""
40 | ]
41 | },
42 | "execution_count": 2,
43 | "metadata": {},
44 | "output_type": "execute_result"
45 | }
46 | ],
47 | "source": [
48 | "lat = +38.89399\n",
49 | "lon = -77.03659\n",
50 | "zoom_start = 17\n",
51 | "\n",
52 | "mapa = folium.Map(location=[lat, lon], zoom_start=zoom_start)\n",
53 | "\n",
54 | "kw = dict(fill_color='red', radius=20)\n",
55 | "c0 = folium.CircleMarker([38.89415, -77.03738], **kw)\n",
56 | "c1 = folium.CircleMarker([38.89415, -77.03578], **kw)\n",
57 | "\n",
58 | "\n",
59 | "locations = [[(38.893596444352134, -77.03814983367920), (38.893379333722040, -77.03792452812195)],\n",
60 | " [(38.893379333722040, -77.03792452812195), (38.893162222428310, -77.03761339187622)],\n",
61 | " [(38.893162222428310, -77.03761339187622), (38.893028615148424, -77.03731298446655)],\n",
62 | " [(38.893028615148424, -77.03731298446655), (38.892920059048464, -77.03691601753235)],\n",
63 | " [(38.892920059048464, -77.03691601753235), (38.892903358095296, -77.03637957572937)],\n",
64 | " [(38.892903358095296, -77.03637957572937), (38.893011914220770, -77.03592896461487)],\n",
65 | " [(38.893011914220770, -77.03592896461487), (38.893162222428310, -77.03549981117249)],\n",
66 | " [(38.893162222428310, -77.03549981117249), (38.893404384982480, -77.03514575958252)],\n",
67 | " [(38.893404384982480, -77.03514575958252), (38.893596444352134, -77.03496336936950)]]\n",
68 | "\n",
69 | "c3 = folium.MultiPolyLine(locations=locations, color='red', weight=2, opacity=1)\n",
70 | "\n",
71 | "for c in [c0, c1, c3]:\n",
72 | " mapa.add_children(c)\n",
73 | "\n",
74 | "mapa"
75 | ]
76 | }
77 | ],
78 | "metadata": {
79 | "kernelspec": {
80 | "display_name": "Iris (Python 2)",
81 | "language": "python",
82 | "name": "iris_python2"
83 | },
84 | "language_info": {
85 | "codemirror_mode": {
86 | "name": "ipython",
87 | "version": 2
88 | },
89 | "file_extension": ".py",
90 | "mimetype": "text/x-python",
91 | "name": "python",
92 | "nbconvert_exporter": "python",
93 | "pygments_lexer": "ipython2",
94 | "version": "2.7.8"
95 | }
96 | },
97 | "nbformat": 4,
98 | "nbformat_minor": 0
99 | }
100 |
--------------------------------------------------------------------------------
/test_popups_formats.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [
33 | {
34 | "data": {
35 | "text/html": [
36 | ""
37 | ],
38 | "text/plain": [
39 | ""
40 | ]
41 | },
42 | "execution_count": 2,
43 | "metadata": {},
44 | "output_type": "execute_result"
45 | }
46 | ],
47 | "source": [
48 | "mapa = folium.Map(location=[45.372, -121.6972], zoom_start=12,\n",
49 | " tiles='Stamen Terrain')\n",
50 | "\n",
51 | "p0 = folium.Popup(\"Let's try quotes\")\n",
52 | "p1 = folium.Popup('and try \"quotes\"')\n",
53 | "p2 = folium.Popup(u\"Ça c'est chouette\")\n",
54 | "p3 = folium.Popup(\"Do scape sequences \\n Work?\") # Nope and \\r breaks the map!\n",
55 | "\n",
56 | "text = u\"\"\"Can we do multiline?\n",
57 | "\n",
58 | "Nope :-(\"\"\"\n",
59 | "p4 = folium.Popup(text)\n",
60 | "\n",
61 | "dy = 0.01\n",
62 | "folium.Marker([45.372, -121.6972-2*dy], popup=p0).add_to(mapa)\n",
63 | "folium.Marker([45.372, -121.6972-dy], popup=p1).add_to(mapa)\n",
64 | "folium.Marker([45.372, -121.6972], popup=p2).add_to(mapa)\n",
65 | "folium.Marker([45.372, -121.6972+dy], popup=p3).add_to(mapa)\n",
66 | "folium.Marker([45.372, -121.6972+2*dy], popup=p4).add_to(mapa)\n",
67 | "\n",
68 | "mapa"
69 | ]
70 | },
71 | {
72 | "cell_type": "markdown",
73 | "metadata": {},
74 | "source": [
75 | "# For anything fancier than simple text you need to use an IFrame"
76 | ]
77 | },
78 | {
79 | "cell_type": "code",
80 | "execution_count": 3,
81 | "metadata": {
82 | "collapsed": false
83 | },
84 | "outputs": [
85 | {
86 | "data": {
87 | "text/html": [
88 | ""
89 | ],
90 | "text/plain": [
91 | ""
92 | ]
93 | },
94 | "execution_count": 3,
95 | "metadata": {},
96 | "output_type": "execute_result"
97 | }
98 | ],
99 | "source": [
100 | "from folium.element import IFrame\n",
101 | "\n",
102 | "mapa = folium.Map(location=[45.372, -121.6972], zoom_start=12,\n",
103 | " tiles='Stamen Terrain')\n",
104 | "\n",
105 | "\n",
106 | "text = u\"\"\"\n",
107 | "Let's try quotes
\n",
108 | "and try \"quotes\"
\n",
109 | "\"Ça c'est chouette
\n",
110 | "\"\"\"\n",
111 | "# It is kind of anoying to set width and height for simple HTML text.\n",
112 | "p = folium.Popup(IFrame(text, width=180, height=80))\n",
113 | "\n",
114 | "folium.Marker([45.372, -121.6972], popup=p).add_to(mapa)\n",
115 | "\n",
116 | "mapa"
117 | ]
118 | }
119 | ],
120 | "metadata": {
121 | "gist_id": "154a9ded80cc11b7e57b",
122 | "kernelspec": {
123 | "display_name": "Iris (Python 2)",
124 | "language": "python",
125 | "name": "iris_python2"
126 | },
127 | "language_info": {
128 | "codemirror_mode": {
129 | "name": "ipython",
130 | "version": 2
131 | },
132 | "file_extension": ".py",
133 | "mimetype": "text/x-python",
134 | "name": "python",
135 | "nbconvert_exporter": "python",
136 | "pygments_lexer": "ipython2",
137 | "version": "2.7.8"
138 | }
139 | },
140 | "nbformat": 4,
141 | "nbformat_minor": 0
142 | }
143 |
--------------------------------------------------------------------------------
/test_vincent_popup_width.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [
33 | {
34 | "ename": "AttributeError",
35 | "evalue": "'Element' object has no attribute 'html'",
36 | "output_type": "error",
37 | "traceback": [
38 | "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
39 | "\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
40 | "\u001b[1;32m/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/IPython/core/formatters.pyc\u001b[0m in \u001b[0;36m__call__\u001b[1;34m(self, obj)\u001b[0m\n\u001b[0;32m 341\u001b[0m \u001b[0mmethod\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0m_safe_get_formatter_method\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mprint_method\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 342\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mmethod\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 343\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 344\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 345\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
41 | "\u001b[1;32m/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/map.py\u001b[0m in \u001b[0;36m_repr_html_\u001b[1;34m(self, **kwargs)\u001b[0m\n\u001b[0;32m 177\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 178\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 179\u001b[1;33m \u001b[0mout\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_repr_html_\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 180\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mout\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 181\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
42 | "\u001b[1;32m/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/element.py\u001b[0m in \u001b[0;36m_repr_html_\u001b[1;34m(self, **kwargs)\u001b[0m\n\u001b[0;32m 367\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 368\u001b[0m \"\"\"\n\u001b[1;32m--> 369\u001b[1;33m \u001b[0mhtml\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrender\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 370\u001b[0m \u001b[0mhtml\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m\"data:text/html;base64,\"\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0mbase64\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mb64encode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mhtml\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mencode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'utf8'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'utf8'\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m# noqa\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 371\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
43 | "\u001b[1;32m/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/element.py\u001b[0m in \u001b[0;36mrender\u001b[1;34m(self, **kwargs)\u001b[0m\n\u001b[0;32m 357\u001b[0m \u001b[1;34m\"\"\"Renders the HTML representation of the element.\"\"\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 358\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mchild\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_children\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 359\u001b[1;33m \u001b[0mchild\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrender\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 360\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_template\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrender\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mthis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 361\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
44 | "\u001b[1;32m/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/element.py\u001b[0m in \u001b[0;36mrender\u001b[1;34m(self, **kwargs)\u001b[0m\n\u001b[0;32m 665\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 666\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0melement\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_children\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 667\u001b[1;33m \u001b[0melement\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrender\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
45 | "\u001b[1;32m/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/element.py\u001b[0m in \u001b[0;36mrender\u001b[1;34m(self, **kwargs)\u001b[0m\n\u001b[0;32m 665\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 666\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0melement\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_children\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 667\u001b[1;33m \u001b[0melement\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrender\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
46 | "\u001b[1;32m/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/map.py\u001b[0m in \u001b[0;36mrender\u001b[1;34m(self, **kwargs)\u001b[0m\n\u001b[0;32m 546\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 547\u001b[0m figure.script.add_children(Element(\n\u001b[1;32m--> 548\u001b[1;33m self._template.render(this=self, kwargs=kwargs)),\n\u001b[0m\u001b[0;32m 549\u001b[0m name=self.get_name())\n\u001b[0;32m 550\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
47 | "\u001b[1;32m/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/jinja2/environment.pyc\u001b[0m in \u001b[0;36mrender\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 987\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mException\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 988\u001b[0m \u001b[0mexc_info\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0msys\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mexc_info\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 989\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0menvironment\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mhandle_exception\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mexc_info\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 990\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 991\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mstream\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
48 | "\u001b[1;32m/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/jinja2/environment.pyc\u001b[0m in \u001b[0;36mhandle_exception\u001b[1;34m(self, exc_info, rendered, source_hint)\u001b[0m\n\u001b[0;32m 752\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mexception_handler\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtraceback\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 753\u001b[0m \u001b[0mexc_type\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mexc_value\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtb\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtraceback\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mstandard_exc_info\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 754\u001b[1;33m \u001b[0mreraise\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mexc_type\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mexc_value\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtb\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 755\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 756\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mjoin_path\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtemplate\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mparent\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
49 | "\u001b[1;32m\u001b[0m in \u001b[0;36mtop-level template code\u001b[1;34m()\u001b[0m\n",
50 | "\u001b[1;32m/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/features.py\u001b[0m in \u001b[0;36mrender\u001b[1;34m(self, **kwargs)\u001b[0m\n\u001b[0;32m 214\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjson\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mjson\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdumps\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 215\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 216\u001b[1;33m self._parent.html.add_children(Element(Template(\"\"\"\n\u001b[0m\u001b[0;32m 217\u001b[0m \u001b[1;33m<\u001b[0m\u001b[0mdiv\u001b[0m \u001b[0mid\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"{{this.get_name()}}\"\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;33m<\u001b[0m\u001b[1;33m/\u001b[0m\u001b[0mdiv\u001b[0m\u001b[1;33m>\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 218\u001b[0m \"\"\").render(this=self, kwargs=kwargs)), name=self.get_name())\n",
51 | "\u001b[1;31mAttributeError\u001b[0m: 'Element' object has no attribute 'html'"
52 | ]
53 | },
54 | {
55 | "data": {
56 | "text/plain": [
57 | ""
58 | ]
59 | },
60 | "execution_count": 2,
61 | "metadata": {},
62 | "output_type": "execute_result"
63 | }
64 | ],
65 | "source": [
66 | "import json\n",
67 | "\n",
68 | "import folium\n",
69 | "import vincent\n",
70 | "import numpy as np\n",
71 | "import pandas as pd\n",
72 | "\n",
73 | "\n",
74 | "sales = folium.Map(location=[51.5, 0], zoom_start=7, tiles='stamentoner')\n",
75 | "\n",
76 | "\n",
77 | "def make_hex_color(mn, mx, value):\n",
78 | " \"\"\"Make a black -> red hex colour.\"\"\"\n",
79 | " assert mn <= value\n",
80 | " assert value <= mx\n",
81 | " percent = (1/(mx-mn)) * (value-mn)\n",
82 | " red_in_hex_range = int(255 * percent)\n",
83 | " color = \"#{:02x}0000\".format(red_in_hex_range)\n",
84 | " return color\n",
85 | "\n",
86 | "\n",
87 | "prices = np.random.uniform(low=100000, high=10000000, size=12).astype(np.int_)\n",
88 | "df = pd.DataFrame({'price': prices})\n",
89 | "\n",
90 | "bar = vincent.Line(df['price'], width=200, height=150)\n",
91 | "bar.axis_titles(x='Month', y='')\n",
92 | "\n",
93 | " \n",
94 | "vega = folium.Vega(json.loads(bar.to_json()))\n",
95 | "popup = folium.Popup(vega, max_width=300)\n",
96 | "\n",
97 | "circle = folium.CircleMarker(location=[51.521282, -0.115279],\n",
98 | " radius=5000,\n",
99 | " color='#ff0000',\n",
100 | " fill_color=make_hex_color(0, 1000000, 1000000),\n",
101 | " popup=popup)\n",
102 | "\n",
103 | "sales.add_children(circle)\n",
104 | "sales"
105 | ]
106 | }
107 | ],
108 | "metadata": {
109 | "kernelspec": {
110 | "display_name": "Iris (Python 2)",
111 | "language": "python",
112 | "name": "iris_python2"
113 | },
114 | "language_info": {
115 | "codemirror_mode": {
116 | "name": "ipython",
117 | "version": 2
118 | },
119 | "file_extension": ".py",
120 | "mimetype": "text/x-python",
121 | "name": "python",
122 | "nbconvert_exporter": "python",
123 | "pygments_lexer": "ipython2",
124 | "version": "2.7.8"
125 | }
126 | },
127 | "nbformat": 4,
128 | "nbformat_minor": 0
129 | }
130 |
--------------------------------------------------------------------------------
/test_zoom.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "code",
5 | "execution_count": 1,
6 | "metadata": {
7 | "collapsed": false
8 | },
9 | "outputs": [
10 | {
11 | "name": "stdout",
12 | "output_type": "stream",
13 | "text": [
14 | "/home/filipe/.virtualenvs/iris/lib/python2.7/site-packages/folium/__init__.py\n",
15 | "0.2.0\n"
16 | ]
17 | }
18 | ],
19 | "source": [
20 | "import folium\n",
21 | "\n",
22 | "print(folium.__file__)\n",
23 | "print(folium.__version__)"
24 | ]
25 | },
26 | {
27 | "cell_type": "code",
28 | "execution_count": 2,
29 | "metadata": {
30 | "collapsed": false
31 | },
32 | "outputs": [
33 | {
34 | "data": {
35 | "text/html": [
36 | ""
37 | ],
38 | "text/plain": [
39 | ""
40 | ]
41 | },
42 | "execution_count": 2,
43 | "metadata": {},
44 | "output_type": "execute_result"
45 | }
46 | ],
47 | "source": [
48 | "lon = -(41 + 20/60. + 17/60/60.)\n",
49 | "lat = -(20 + 59/60. + 35/60/60.)\n",
50 | "\n",
51 | "min_lon, max_lon = -45, -35\n",
52 | "min_lat, max_lat = -25, -15\n",
53 | "\n",
54 | "mapa = folium.Map(location=[lat, lon], zoom_start=6,\n",
55 | " min_lat=min_lat, max_lat=max_lat,\n",
56 | " min_lon=min_lon, max_lon=max_lon)\n",
57 | "\n",
58 | "\n",
59 | "kw = dict(radius=5e4, fill_color='green', fill_opacity=1)\n",
60 | "\n",
61 | "popup = '{}'.format('Upper Left Corner')\n",
62 | "c0 = folium.CircleMarker(location=[max_lat, min_lon], popup=popup, **kw)\n",
63 | "\n",
64 | "\n",
65 | "popup = '{}'.format('Lower Left Corner')\n",
66 | "c1 = folium.CircleMarker(location=[min_lat, min_lon], popup=popup, **kw)\n",
67 | "\n",
68 | "popup = '{}'.format('Lower Right Corner')\n",
69 | "c2 = folium.CircleMarker(location=[min_lat, max_lon], popup=popup, **kw)\n",
70 | "\n",
71 | "popup = '{}'.format('Upper Right Corner')\n",
72 | "c3 = folium.CircleMarker(location=[max_lat, max_lon], popup=popup, **kw)\n",
73 | "\n",
74 | "for c in [c0, c1, c2, c3]:\n",
75 | " mapa.add_children(c)\n",
76 | "\n",
77 | "mapa"
78 | ]
79 | }
80 | ],
81 | "metadata": {
82 | "kernelspec": {
83 | "display_name": "Iris (Python 2)",
84 | "language": "python",
85 | "name": "iris_python2"
86 | },
87 | "language_info": {
88 | "codemirror_mode": {
89 | "name": "ipython",
90 | "version": 2
91 | },
92 | "file_extension": ".py",
93 | "mimetype": "text/x-python",
94 | "name": "python",
95 | "nbconvert_exporter": "python",
96 | "pygments_lexer": "ipython2",
97 | "version": "2.7.8"
98 | }
99 | },
100 | "nbformat": 4,
101 | "nbformat_minor": 0
102 | }
103 |
--------------------------------------------------------------------------------