Path: blob/master/examples/python/earthengine_py_to_ipynb.py
2313 views
"""The example shows you how to convert all Earth Engine Python scripts in a GitHub repo to Jupyter notebooks."""12import os3from geemap.conversion import *45import subprocess67try:8from git import Repo9except ImportError:10print("gitpython package is not installed. Installing ...")11subprocess.check_call(["python", "-m", "pip", "install", "gitpython"])12from git import Repo131415git_url = "https://github.com/giswqs/qgis-earthengine-examples"16out_repo_name = "earthengine-py-notebooks"1718# Create a temporary working directory19work_dir = os.path.join(os.path.expanduser("~"), "geemap")20if not os.path.exists(work_dir):21os.makedirs(work_dir)2223out_dir = os.path.join(work_dir, out_repo_name)2425repo_name = git_url.split("/")[-1]26repo_dir = os.path.join(work_dir, repo_name)2728if not os.path.exists(repo_dir):29Repo.clone_from(git_url, repo_dir)3031# # Convert all Earth Engine Python scripts in a folder recursively to Jupyter notebooks.32nb_template = get_nb_template() # Get the notebook template from the package folder.33py_to_ipynb_dir(34repo_dir,35nb_template,36out_dir,37github_username="giswqs",38github_repo=out_repo_name,39)4041# execute_notebook_dir(out_dir)424344