Commit 12450d49 authored by David Youssefi's avatar David Youssefi

BUG: Remove SQLite files

parent f9af702f
......@@ -2,6 +2,7 @@
Read/Write OGR functions
"""
from osgeo import ogr
import sys
def openToRead(shapefile):
driver = ogr.GetDriverByName("SQLite")
......
......@@ -31,6 +31,7 @@
"source": [
"import os\n",
"import subprocess\n",
"from osgeo import ogr, osr\n",
"\n",
"import ogr_io\n",
"\n",
......@@ -41,12 +42,23 @@
"OUTPUT_DIR = \"output\"\n",
"\n",
"# Input / Output filenames\n",
"envelope_fname = os.path.join(DATA_DIR, \"morbihan.sqlite\")\n",
"ndwi_thres_fname = os.path.join(OUTPUT_DIR, \"ndwi_threshold30.tif\")\n",
"watermask_fname = os.path.join(OUTPUT_DIR, \"watermask.sqlite\")\n",
"envelope_fname = os.path.join(OUTPUT_DIR, \"morbihan.sqlite\")\n",
"results_fname = os.path.join(OUTPUT_DIR, \"results.sqlite\")\n",
"geojson_fname = os.path.join(OUTPUT_DIR, \"geojson.json\")\n",
"\n",
"# Get SQLite driver\n",
"outDriver = ogr.GetDriverByName(\"SQLite\")\n",
"\n",
"# Remove results if it already exists\n",
"if os.path.exists(results_fname):\n",
" outDriver.DeleteDataSource(results_fname)\n",
" \n",
"# Remove watermask if it already exists\n",
"if os.path.exists(watermask_fname):\n",
" outDriver.DeleteDataSource(watermask_fname)\n",
"\n",
"# Convert the TIF file in a shapefile with polygons\n",
"try:\n",
" subprocess.call([\"gdal_polygonize.py\", ndwi_thres_fname,\"-f\", \"SQLite\", watermask_fname])\n",
......@@ -82,15 +94,6 @@
"metadata": {},
"outputs": [],
"source": [
"from osgeo import ogr, osr\n",
"\n",
"# Save extent to a new Shapefile\n",
"outDriver = ogr.GetDriverByName(\"SQLite\")\n",
"\n",
"# Remove output shapefile if it already exists\n",
"if os.path.exists(results_fname):\n",
" outDriver.DeleteDataSource(results_fname)\n",
"\n",
"# create the spatial reference, WGS84\n",
"srs = osr.SpatialReference()\n",
"srs.ImportFromEPSG(32630)\n",
......@@ -163,6 +166,13 @@
"m, dc = display_api.rasters_on_map([raster], OUTPUT_DIR, [DATE], geojson_data=fc)\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
......
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