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
12450d49
Commit
12450d49
authored
May 15, 2019
by
David Youssefi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BUG: Remove SQLite files
parent
f9af702f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
10 deletions
+21
-10
ogr_io.py
ogr_io.py
+1
-0
step4_filter_shapefile.ipynb
step4_filter_shapefile.ipynb
+20
-10
No files found.
ogr_io.py
View file @
12450d49
...
...
@@ -2,6 +2,7 @@
Read/Write OGR functions
"""
from
osgeo
import
ogr
import
sys
def
openToRead
(
shapefile
):
driver
=
ogr
.
GetDriverByName
(
"SQLite"
)
...
...
step4_filter_shapefile.ipynb
View file @
12450d49
...
...
@@ -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": {
...
...
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