Skip to content

Commit

Permalink
docs: load continent
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau committed Aug 14, 2023
1 parent 3941f22 commit 7a33075
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 14 deletions.
24 changes: 10 additions & 14 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,18 @@ It's possible to request all countries from one single continent using one of th
- Oceania
- Africa

.. code-block:: python
.. jupyter-execute::

import pygadm
from ipyleaflet import GeoJSON, Map, basemaps

gdf = pygadm.get_items(name="europe")
gdf = pygadm.get_items(name="south america")

# display it in a map
m = Map(basemap=basemaps.Esri.WorldImagery, zoom=5, center=[-20.30, -59.32])
m.add(GeoJSON(data=gdf.__geo_interface__, style={"color": "red", "fillOpacity": .4}))

m

.. note::

Expand Down Expand Up @@ -149,14 +156,12 @@ Google Earth engine
Transform gdf into ``ee.FeatureCollection``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If you want to use this lib with GEE, install the "earthengine-api" package in your environment and then run the following code:
If you want to use this lib with GEE, install the "earthengine-api" package in your environment and then run the following code and transform the ``GeoDataFrame`` into a ``ee.FeatureCollection`` as follow:

.. code-block:: python
import pygadm
import geemap
import ee
from ipyleaflet import basemaps, ZoomControl
ee.Initialize()
Expand All @@ -165,15 +170,6 @@ If you want to use this lib with GEE, install the "earthengine-api" package in y
# transform into an ee.FeatureCollection
fc = ee.FeatureCollection(gdf.__geo_interface__)
# in this example we use geemap to display the geometry on the map
# the map is customized to have the same look & feel as the rest of the documentation
m = geemap.Map(scroll_wheel_zoom=False, center=[41.86, 8.97], zoom=8, basemap=basemaps.Esri.WorldImagery)
m.clear_controls()
m.add(ZoomControl())
m.addLayer(fc, {"color": "red"}, "FRA")
m
Simplify geometry
^^^^^^^^^^^^^^^^^

Expand Down
71 changes: 71 additions & 0 deletions test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pygadm\n",
"from ipyleaflet import GeoJSON, Map, basemaps\n",
"\n",
"m = Map()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m.center"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m.center"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 7a33075

Please sign in to comment.