I have a folder with multiple SpatiaLite databases. I'd like to use ogrmerge.py
to merge them into a single database... But if I use the command:
ogrmerge.py -f SQLite -single -o output.sqlite *.sqlite
I receive the error:
- 'VirtualXPath' [XML Path Language - XPath]
Traceback (most recent call last):
File "/usr/bin/ogrmerge.py", line 11, in <module>
sys.exit(main(sys.argv))
File "/usr/lib/python3/dist-packages/osgeo/utils/ogrmerge.py", line 618, in main
return process(argv[1:])
File "/usr/lib/python3/dist-packages/osgeo/utils/ogrmerge.py", line 456, in process
writer.open_element('OGRVRTLayer',
File "/usr/lib/python3/dist-packages/osgeo/utils/ogrmerge.py", line 168, in open_element
xml_attrs = xml_attrs + ' %s=\"%s\"' % (key, _Esc(attrs[key].encode('utf-8')))
UnicodeEncodeError: 'utf-8' codec can't encode characters in position 12-13: surrogates not allowed
What am I missing? When I try merging the same files as Shapefiles with ogrmerge.py -f "ESRI Shapefile" -single *.shp -o output.shp
it works fine. How can I merge SpatiaLite files with ogrmerge.py
?
xml_attrs = xml_attrs + ' %s=\"%s\"' % (key, _Esc(attrs[key].encode('utf-8')))
If you cannot find out the exact encoding, try some common ones, e.g.,windows-1252
ogrmergy.py
can merge input files that are not Shapefiles since the examples that I find are always using Shapefiles as input (gdal.org/programs/ogrmerge.html). My Spatialite files look ok when I open them with QGIS. I'd like to find a solution that doesn't require me to change theogrmerge.py
source code.sqlite db
Q, valid thought but I think it will; may need additional geopackages, e.g.sqlite spatialite
& additionalkeys
in your script. Also, look at:https://gis.stackexchange.com/questions/195160/merge-natural-earth-sqlite-country-polygons-using-ogr2ogr-and-st-union
Installing a complete Sys on Linux was painful. Here are some packages u will need:https://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-$spatialite_version.tar.gz
https://www.sqlite.org/2020/sqlite-autoconf-3320300.tar.gz