-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from openforis/master
add a file downloader
- Loading branch information
Showing
8 changed files
with
197 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
|