I'm inside a bash script trying to import a GeoJSON file into a SQLite DB.
I tried both …
SPATIALITE_SECURITY=relaxed sqlite3 'db.sqlite' "SELECT load_extension('mod_spatialite')" "SELECT ImportGeoJSON('file.geojson', 'osmgeojson')"
… and …
export SPATIALITE_SECURITY=relaxed
sqlite3 'db.sqlite' "SELECT load_extension('mod_spatialite')" "SELECT ImportGeoJSON('file.geojson', 'osmgeojson')"
… but either way I get this error:
Error: no such function: ImportGeoJSON
Note that in both cases I did set SPATIALITE_SECURITY=relaxed as the docs said ( http://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html ).
I'm sure that SpatiaLite is loaded correctly, as it throws no error and this command …
SPATIALITE_SECURITY=relaxed sqlite3 'db.sqlite' "SELECT load_extension('mod_spatialite')" "SELECT spatialite_version()"
… returns …
4.3.0a
What could be causing this error?
Best Answer
Looking at Spatialite's timeline I realised that ImportGeoJSON() was introduced after 5.0.0-beta0 so obviously it wasn't supported by the 4.3.0a I had on my system.
I have updated Spatialite to 5.0.1 (actually I had to upgrade Ubuntu 20.04 to 21.04 to do that without compiling it) and now the function is recognised.