Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
giswqs
GitHub Repository: giswqs/geemap
Path: blob/master/examples/python/earthengine_js_to_ipynb.py
2313 views
1
import os
2
from geemap.conversion import *
3
4
# Create a temporary working directory
5
work_dir = os.path.join(os.path.expanduser("~"), "geemap")
6
# Get Earth Engine JavaScript examples. There are five examples in the geemap package folder.
7
# Change js_dir to your own folder containing your Earth Engine JavaScripts, such as js_dir = '/path/to/your/js/folder'
8
js_dir = get_js_examples(out_dir=work_dir)
9
10
# Convert all Earth Engine JavaScripts in a folder recursively to Python scripts.
11
js_to_python_dir(in_dir=js_dir, out_dir=js_dir, use_qgis=True)
12
print("Python scripts saved at: {}".format(js_dir))
13
14
# Convert all Earth Engine Python scripts in a folder recursively to Jupyter notebooks.
15
nb_template = get_nb_template() # Get the notebook template from the package folder.
16
py_to_ipynb_dir(js_dir, nb_template)
17
18
# Execute all Jupyter notebooks in a folder recursively and save the output cells.
19
execute_notebook_dir(in_dir=js_dir)
20
21