diff --git a/README.md b/README.md index a3dad46..3f06dfa 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,44 @@ # import_to_gee -UI to load files to earthengine + +## About +This module is a 2 step wrapper to upload AOI to Google Earth Engine + +![results](./doc/img/full_input.png) + +## usage + +### Step 1 (optional) + +If your file is not yet available in your SEAPL folders, you can upload it using the first menu. + +![import](./doc/img/import.png) + +### step 2 + +Select a methode to define your AOI between : + +- `draw a shape`: manually draw a shape on the map +- `Upload file` : Use a shapefile as an asset +- `Use point file` : Use a `.csv` file as an aoi asset. Point file need to have at least 3 columns (id, lattitude and longitude) but you can use any custom names. + +Once you have selected your aoi, click the btn and your AOI will be updated as an asset and available for the others SEPAL modules. + +> the file created in step 1 may not appear in the file selector. refresh the list by opening a folder + +If the process is successful, your AOI will be displayed in green on the map. + +![image](./doc/img/results.png) + +## contribute +to install the project on your SEPAL account +``` +$ git clone https://github.com/openforis/import_to_ee.git +``` + +please retreive the develop branch where all our developments live +``` +$ git checkout --track origin/develop +``` + +please follow the contributing [guidelines](CONTRIBUTING.md). + diff --git a/about_ui.ipynb b/about_ui.ipynb index 8b1cff3..3e94e26 100644 --- a/about_ui.ipynb +++ b/about_ui.ipynb @@ -9,7 +9,7 @@ "from sepal_ui import sepalwidgets as sw\n", "\n", "#create the Html body of your about section \n", - "ig_about = sw.TileAbout('README.md')\n", + "ig_about = sw.TileAbout('utils/about.md')\n", "\n", "#create a disclaimer\n", "ig_disclaimer = sw.TileDisclaimer()" diff --git a/doc/img/full_input.png b/doc/img/full_input.png new file mode 100644 index 0000000..301db57 Binary files /dev/null and b/doc/img/full_input.png differ diff --git a/doc/img/import.png b/doc/img/import.png new file mode 100644 index 0000000..b8bb948 Binary files /dev/null and b/doc/img/import.png differ diff --git a/doc/img/results.png b/doc/img/results.png new file mode 100644 index 0000000..7b16ca8 Binary files /dev/null and b/doc/img/results.png differ diff --git a/download_ui.ipynb b/download_ui.ipynb new file mode 100644 index 0000000..616cb11 --- /dev/null +++ b/download_ui.ipynb @@ -0,0 +1,125 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from sepal_ui import sepalwidgets as sw\n", + "from functools import partial\n", + "from ipyvuetify.extra import FileInput\n", + "import ipyvuetify as v\n", + "from pathlib import Path\n", + "import unidecode" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# output \n", + "import_output = sw.Alert().add_msg('import your file')\n", + "\n", + "# btn \n", + "import_btn = sw.Btn('import', icon = 'mdi-check', class_='mt-4')\n", + "\n", + "# create the input \n", + "input_file = FileInput(\n", + " multiple = False, \n", + " accept = \"image/png, image/jpeg, image/bmp\"\n", + ")\n", + "\n", + "# create a file selector \n", + "id_ = 'aoi_widget'\n", + "title = \"Import a file\"\n", + "\n", + "ig_import = sw.Tile(\n", + " id_,\n", + " title,\n", + " btn=import_btn, \n", + " inputs=[input_file],\n", + " output=import_output\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def import_on_click(widget, data, event, output):\n", + " \n", + " # toggle the btn\n", + " widget.toggle_loading()\n", + " \n", + " output.add_msg('start the downlaod')\n", + " \n", + " # load the files\n", + " myfiles = input_file.get_files()\n", + " \n", + " # test the selection\n", + " if not len(myfiles):\n", + " output.add_msg('No file selected', 'error')\n", + " return widget.toggle_loading()\n", + " \n", + " # create the path \n", + " path = Path('~/downloads').expanduser().joinpath(unidecode.unidecode(myfiles[0]['name']))\n", + " if path.is_file():\n", + " output.add_msg('File already exists', 'error')\n", + " return widget.toggle_loading()\n", + " \n", + " src = myfiles[0]['file_obj'] \n", + " with path.open('wb') as dst:\n", + " content = bytes(src.read())\n", + " dst.write(content)\n", + " \n", + " output.add_msg(f'Download complete in {path}', 'success')\n", + " \n", + " return widget.toggle_loading()\n", + "\n", + "import_btn.on_event('click', partial(import_on_click, output = import_output))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ig_import" + ] + }, + { + "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.6.9" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/ui.ipynb b/ui.ipynb index 03db33e..b9d5831 100644 --- a/ui.ipynb +++ b/ui.ipynb @@ -41,16 +41,6 @@ "ig_appBar = sw.AppBar('Import to Google Earth Engine')" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#create a footer \n", - "ig_footer = sw.Footer()" - ] - }, { "cell_type": "code", "execution_count": null, @@ -58,10 +48,12 @@ "outputs": [], "source": [ "#add tiles \n", + "%run 'download_ui.ipynb'\n", "%run 'aoi_selector_ui.ipynb'\n", "%run 'about_ui.ipynb'\n", "\n", "ig_content = [\n", + " ig_import,\n", " ig_aoi,\n", " ig_about,\n", " ig_disclaimer\n", @@ -100,7 +92,6 @@ "ig_app = sw.App(\n", " tiles=ig_content, \n", " appBar=ig_appBar, \n", - " footer=ig_footer, \n", " navDrawer=ig_drawer\n", ").show_tile('aoi_widget')" ] diff --git a/utils/about.md b/utils/about.md new file mode 100644 index 0000000..c2e9dcc --- /dev/null +++ b/utils/about.md @@ -0,0 +1,26 @@ +This module is a 2 step wrapper to upload AOI to Google Earth Engine + +## usage + +### Step 1 (optional) + +If your file is not yet available in your SEAPL folders, you can upload it using the first menu. + +![import](https://raw.githubusercontent.com/openforis/import_to_gee/master/doc/img/import.png) + +### step 2 + +Select a methode to define your AOI between : + +- `draw a shape`: manually draw a shape on the map +- `Upload file` : Use a shapefile as an asset +- `Use point file` : Use a `.csv` file as an aoi asset. Point file need to have at least 3 columns (id, lattitude and longitude) but you can use any custom names. + +Once you have selected your aoi, click the btn and your AOI will be updated as an asset and available for the others SEPAL modules. + +> the file created in step 1 may not appear in the file selector. refresh the list by opening a folder + +If the process is successful, your AOI will be display in green on the map. + +![image](https://raw.githubusercontent.com/openforis/import_to_gee/master/doc/img/results.png) +