Commit 4e83bd1d authored by David Youssefi's avatar David Youssefi

BUG: fix links + rasterio version bug

parent a62a2317
......@@ -161,7 +161,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Go to the [Step 2](./step2_compute_watermask.ipynb)"
"### Go to the [Step 2](./step2_compute_watermask_without_otb_pipeline.ipynb)"
]
}
],
......
......@@ -131,7 +131,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Go to the [Step 3](./step3_segment_watermask_threshold_NDWI.ipynb)"
"### Go to the [Step 3](./step3_compute_watermask_with_otb_pipeline.ipynb)"
]
}
],
......
......@@ -38,12 +38,15 @@
"# Date list\n",
"DATE_LIST = [\"20180711\", \"20180701\", \"20180621\"]\n",
"\n",
"# Watermask\n",
"watermask = os.path.join(OUTPUT_DIR, \"WATERMASK.tif\")\n",
"\n",
"import time\n",
"import os\n",
"from glob import glob\n",
"\n",
"import otbApplication\n",
"\n",
"# Watermask\n",
"watermask = os.path.join(OUTPUT_DIR, \"WATERMASK.tif\")\n",
"\n",
"def compute_ndwi(date):\n",
" im = glob(os.path.join(DATA_DIR, \"*{}*.tif\".format(date)))[0]\n",
" ndwi = os.path.join(OUTPUT_DIR, \"NDWI_{}.tif\".format(date))\n",
......@@ -101,11 +104,15 @@
"\n",
"# Convert Watermask to geojson collection\n",
"watermask = os.path.join(OUTPUT_DIR, \"WATERMASK.tif\")\n",
"\n",
"with rasterio.drivers():\n",
" with rasterio.open(watermask) as src:\n",
" image = src.read(1).astype(np.uint8) \n",
" results = ({'type':'Feature', 'properties': {}, 'geometry': s} for i, (s, __) in enumerate(features.shapes(image, mask=image, transform=src.affine)))\n",
"with rasterio.open(watermask) as src:\n",
" image = src.read(1).astype(np.uint8)\n",
"try:\n",
" transform = src.affine\n",
"# depend on rasterio version\n",
"except AttributeError:\n",
" transform = src.transform\n",
"\n",
"results = ({'type':'Feature', 'properties': {}, 'geometry': s} for i, (s, __) in enumerate(features.shapes(image, mask=image, transform=transform))) \n",
"\n",
"# Filter geojson\n",
"collection = {'type': 'FeatureCollection', 'features': list()}\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment