Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format the folium example #134

Merged
merged 2 commits into from Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/folium_demo.ipynb

This file was deleted.

81 changes: 81 additions & 0 deletions examples/pyolite - folium.ipynb
@@ -0,0 +1,81 @@
{
"cells": [
{
"cell_type": "markdown",
"source": "# `folium` Interactive Map Demo\n\nSimple demonstration of rendering a map in a `jupyterlite` notebook.\n\nNote that the `folium` package has several dependencies which themselves may have dependencies.\n\nThe following code fragement, run in a fresh Python enviroment into which `folium` has already been installed, identifies the packages that are loaded in when `folium` is loaded:\n\n```python\n#https://stackoverflow.com/a/40381601/454773\nimport sys\nbefore = [str(m) for m in sys.modules]\nimport folium\nafter = [str(m) for m in sys.modules]\nset([m.split('.')[0] for m in after if not m in before and not m.startswith('_')])\n```\n\nThe loaded packages are:\n\n```\n{'branca',\n 'certifi',\n 'chardet',\n 'cmath',\n 'csv',\n 'dateutil',\n 'encodings',\n 'folium',\n 'gzip',\n 'http',\n 'idna',\n 'importlib',\n 'jinja2',\n 'markupsafe',\n 'mmap',\n 'numpy',\n 'pandas',\n 'pkg_resources',\n 'pytz',\n 'requests',\n 'secrets',\n 'stringprep',\n 'urllib3',\n 'zipfile'}\n ```\n ",
"metadata": {
"tags": []
}
},
{
"cell_type": "markdown",
"source": "The following packages seem to need installing in order load `folium`, along with folium itself:\n\n```\nchardet, certifi, idna, branca, urllib3, Jinja2, requests, Markupsafe\n```\n\nUniversal wheels, with filenames of the form `PACKAGE-VERSION-py2.py3-none-any.whl` appearing in the *Download files* area of a PyPi package page ([example](https://pypi.org/project/requests/#files)] are required in order to install the package.\n\nOne required package, [`Markupsafe`](https://pypi.org/project/Markupsafe/#files)) *did not* have a universal wheel available, so a wheel was manually built elsewhere (by hacking the [`setup.py` file](https://github.com/pallets/markupsafe/blob/main/setup.py) to force it not to build the wheel in a platfrom and speedup free way) and pushed to a downloadable location in an *ad hoc* wheelhouse](https://opencomputinglab.github.io/vce-wheelhouse/).",
"metadata": {}
},
{
"cell_type": "code",
"source": "# Install folium requirements\nimport micropip\nawait micropip.install(\"https://opencomputinglab.github.io/vce-wheelhouse/wheelhouse/MarkupSafe-2.0.1-py2.py3-none-any.whl\")\nawait micropip.install('https://files.pythonhosted.org/packages/19/c7/fa589626997dd07bd87d9269342ccb74b1720384a4d739a1872bd84fbe68/chardet-4.0.0-py2.py3-none-any.whl')\nawait micropip.install('https://files.pythonhosted.org/packages/05/1b/0a0dece0e8aa492a6ec9e4ad2fe366b511558cdc73fd3abc82ba7348e875/certifi-2021.5.30-py2.py3-none-any.whl')\nawait micropip.install('https://files.pythonhosted.org/packages/d7/77/ff688d1504cdc4db2a938e2b7b9adee5dd52e34efbd2431051efc9984de9/idna-3.2-py3-none-any.whl')\nawait micropip.install(\"https://files.pythonhosted.org/packages/61/1f/570b0615c452265d57e4114e633231d6cd9b9d275256778a675681e4f711/branca-0.4.2-py3-none-any.whl\")\nawait micropip.install('https://files.pythonhosted.org/packages/0c/cd/1e2ec680ec7b09846dc6e605f5a7709dfb9d7128e51a026e7154e18a234e/urllib3-1.26.5-py2.py3-none-any.whl')\nawait micropip.install('https://files.pythonhosted.org/packages/80/21/ae597efc7ed8caaa43fb35062288baaf99a7d43ff0cf66452ddf47604ee6/Jinja2-3.0.1-py3-none-any.whl')\nawait micropip.install('https://files.pythonhosted.org/packages/29/c1/24814557f1d22c56d50280771a17307e6bf87b70727d975fd6b2ce6b014a/requests-2.25.1-py2.py3-none-any.whl')\n\n# Install folium \nawait micropip.install(\"https://files.pythonhosted.org/packages/c3/83/e8cb37afc2f016a1cf4caab8d22caf7fe4156c4c15230d8abc9c83547e0c/folium-0.12.1-py2.py3-none-any.whl\")",
"metadata": {
"trusted": true
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": "## Demo of `folium` Map\n\nLoad in the `folium` package:",
"metadata": {}
},
{
"cell_type": "code",
"source": "import folium",
"metadata": {
"trusted": true
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": "And render a demo map:",
"metadata": {}
},
{
"cell_type": "code",
"source": "m = folium.Map(location=[50.693848, -1.304734], zoom_start=11)\nm",
"metadata": {
"trusted": true
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": "",
"metadata": {},
"execution_count": null,
"outputs": []
}
],
"metadata": {
"language_info": {
"codemirror_mode": {
"name": "python",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8"
},
"kernelspec": {
"name": "python",
"display_name": "Pyolite",
"language": "python"
}
},
"nbformat": 4,
"nbformat_minor": 4
}