Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OTB Guided Tour
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
David Youssefi
OTB Guided Tour
Commits
0c1e01b3
Commit
0c1e01b3
authored
May 15, 2019
by
David Youssefi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: steps 1,2 completed
parent
6f64ad65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
22 deletions
+48
-22
step1_compute_radiometric_indices.ipynb
step1_compute_radiometric_indices.ipynb
+13
-9
step2_compute_watermask.ipynb
step2_compute_watermask.ipynb
+35
-13
No files found.
step1_compute_radiometric_indices.ipynb
View file @
0c1e01b3
...
...
@@ -136,7 +136,7 @@
"# Compute radiometric indices (NDVI & NDWI2) on a stack of images\n",
"ndwi_filenames_list = compute_ndwi(utils.list_images(DATA_DIR,\"_RVBPIR.tif\"), OUTPUT_DIR)\n",
"if ndwi_filenames_list is not None:\n",
" print (ndwi_filenames_list)\n",
" print (ndwi_filenames_list)
http://localhost:8888/notebooks/step1_compute_radiometric_indices.ipynb#
\n",
"else:\n",
" print (\"TODO: fill the compute_ndwi_function\")"
]
...
...
@@ -147,14 +147,18 @@
"metadata": {},
"outputs": [],
"source": [
"if ndwi_filenames_list is not None:\n",
" # Display on a map\n",
" rasters = list(map(rasterio.open, ndwi_filenames_list))\n",
" overnames = list(map(os.path.basename, ndwi_filenames_list))\n",
" m, dc = display_api.rasters_on_map(rasters, OUTPUT_DIR, overnames)\n",
" m\n",
"else:\n",
" print (\"TODO: fill the compute_ndwi_function\")"
"# Display on a map\n",
"rasters = list(map(rasterio.open, ndwi_filenames_list))\n",
"overnames = list(map(os.path.basename, ndwi_filenames_list))\n",
"m, dc = display_api.rasters_on_map(rasters, OUTPUT_DIR, overnames)\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Go to the [Step 2](./step2_compute_watermask.ipynb)"
]
}
],
...
...
step2_compute_watermask.ipynb
View file @
0c1e01b3
...
...
@@ -14,7 +14,7 @@
"<b> Press <span style=\"color:black;background:yellow\">SHIFT+ENTER</span> to execute the notebook interactively cell by cell </b></div>\n",
"\n",
"\n",
"## Step 2 : \n",
"## Step 2 :
Compute Watermask
\n",
"\n",
"The aim of this second exercise is to combine NDWI2 values to create a water mask\n",
"- what kind of function do we need to implement ?\n",
...
...
@@ -53,7 +53,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"
**Compute the NDWI2**
\n",
"
### Compute the NDWI2
\n",
"\n",
"Do we need to adapt the formula to deal with invalid pixels ? \n",
"\n",
...
...
@@ -66,7 +66,7 @@
"metadata": {},
"outputs": [],
"source": [
"def app_radiometricindices(images):\n",
"def app_radiometricindices(images
, out_dir
):\n",
" index = 0\n",
" for im in images:\n",
" # Here we create an application\n",
...
...
@@ -94,7 +94,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"
**Compute watermask from a list of NDWI2 images**
\n",
"
### Compute watermask from a list of NDWI2 images
\n",
"\n",
"We are going to use a list of images to compute a watermask (0 for land, 1 for water) : \n",
"- the inputs must be set in a list with app.AddImageToParameterInputImageList\n",
...
...
@@ -107,25 +107,38 @@
"metadata": {},
"outputs": [],
"source": [
"def compute_watermask(list_app):\n",
" if index==1:\n",
" exp = exp+\"im\"+str(index)+\"b1\"\n",
" else:\n",
" exp = exp+\", \"+\"im\"+str(index)+\"b1\"\n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def compute_watermask(list_app,outputfilename):\n",
" app = otbApplication.Registry.CreateApplication(\"BandMath\")\n",
"\n",
" index = 1\n",
" input_list = []\n",
" exp = \"?????\"\n",
" for appli in list_app:\n",
" app.AddImageToParameterInputImageList(\"il\",appli.GetParameterOutputImage(\"out\"))\n",
" if index==1:\n",
" exp = exp # + \"some function that involves im1b1\"\n",
" else:\n",
" exp = exp # +\", \"+\"im\"+str(index)+\"b1\"\n",
" exp = exp # +\", \"+\"im\"+str(index)+\"b1\"
def compute_watermask(list_app,outputfilename):
\n",
" index += 1\n",
"\n",
"\n",
" print(exp)\n",
"\n",
" \n",
" app.SetParameterString(\"out\",NDWI_synthesis)\n",
" app.SetParameterString(\"out\",outputfilename)\n",
" app.SetParameterString(\"exp\",exp)\n",
" app.ExecuteAndWriteOutput()
\n
"
" app.ExecuteAndWriteOutput()"
]
},
{
...
...
@@ -136,7 +149,7 @@
"source": [
"# Compute radiometric indices (NDVI & NDWI2) on a stack of images\n",
"list_app = app_radiometricindices(utils.list_images(DATA_DIR,\"_RVBPIR.tif\"), OUTPUT_DIR)\n",
"compute_watermask(
os.path.join(OUTPUT_DIR, NDWI_synthesis), list_app)\n
"
"compute_watermask(
list_app, NDWI_synthesis)
"
]
},
{
...
...
@@ -144,14 +157,23 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"import rasterio\n",
"import display_api\n",
"\n",
"raster = rasterio.open(NDWI_synthesis)\n",
"m, dc = display_api.rasters_on_map([raster], OUTPUT_DIR, [\"NDWI synthesis\"])\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"### Go to the [Step 3](./step3_segment_watermask_threshold_NDWI.ipynb)"
]
}
],
"metadata": {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment