Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
giswqs
GitHub Repository: giswqs/geemap
Path: blob/master/examples/python/earthengine_py_to_ipynb.py
2313 views
1
"""The example shows you how to convert all Earth Engine Python scripts in a GitHub repo to Jupyter notebooks."""
2
3
import os
4
from geemap.conversion import *
5
6
import subprocess
7
8
try:
9
from git import Repo
10
except ImportError:
11
print("gitpython package is not installed. Installing ...")
12
subprocess.check_call(["python", "-m", "pip", "install", "gitpython"])
13
from git import Repo
14
15
16
git_url = "https://github.com/giswqs/qgis-earthengine-examples"
17
out_repo_name = "earthengine-py-notebooks"
18
19
# Create a temporary working directory
20
work_dir = os.path.join(os.path.expanduser("~"), "geemap")
21
if not os.path.exists(work_dir):
22
os.makedirs(work_dir)
23
24
out_dir = os.path.join(work_dir, out_repo_name)
25
26
repo_name = git_url.split("/")[-1]
27
repo_dir = os.path.join(work_dir, repo_name)
28
29
if not os.path.exists(repo_dir):
30
Repo.clone_from(git_url, repo_dir)
31
32
# # Convert all Earth Engine Python scripts in a folder recursively to Jupyter notebooks.
33
nb_template = get_nb_template() # Get the notebook template from the package folder.
34
py_to_ipynb_dir(
35
repo_dir,
36
nb_template,
37
out_dir,
38
github_username="giswqs",
39
github_repo=out_repo_name,
40
)
41
42
# execute_notebook_dir(out_dir)
43
44