I'm using ogr2ogr to pull features out of Oracle and put them into a File GeoDatabase. The FGDB is being used by an active ArcGIS Server map service. This is all done for performance / reducing DB load. The DB data is refreshed nightly and then the ogr2ogr process runs so I don't worry about stale FGDB records.
The data can both grow and shrink overnight during the update so I need my FGDB refresh to both remove and add features.
I know this is possible if I use ogr2ogr's -overwrite
option, e.g.
ogr2ogr --config FGDB_BULK_LOAD YES -f "FileGDB" .gdb OCI:user/pass@SID -overwrite -nlt LINESTRING -a_srs EPSG:4326 -nln layer_name -sql "select * from src_table"
But -overwrite
fails if I don't first stop the ArcGIS Server map service.
I can use -update -append
to update FGDB records while the service is running but this is 'additive' - records are added but nothing is removed.
ogr2ogr --config FGDB_BULK_LOAD YES -f "FileGDB" .gdb OCI:user/pass@SID -update -append -nlt POINT -a_srs EPSG:4326 -nln layer_name -sql "select * from src_table"
I'm looking for a way to either
- Truncate the FGDB layer without removing it prior to an
-update -append
or - Change my ogr2ogr command to remove features not pulled from Oracle
I also saw this post this page on programmatically stopping / starting AGS map services but option 1 or 2 is my preference as I want an approach that doesn't require authentication / tokens over HTTP. If necessary I can bring in Python and perhaps the arcpy module.
Any input on GDAL / ogr2ogr parameters I haven't seen yet that might help would be much appreciated (or alternative approaches of course).
Answer
It is possible to issue SQL statements to the FileGDB driver, e.g.:
ogrinfo -dialect FileGDB -sql "delete from
See the "SQL support" note on the FGDB driver page: http://gdal.org/ogr/drv_filegdb.html
No comments:
Post a Comment