Gdal 1.11.0 添加 Postgresql 9.1 sqlite3 支持

时间:2021-12-12 05:46:29

OS环境Ubuntu12.04 32bit

因为公司一个功能要用到gdal 的ogr2ogr命令转换shp数据,需要能往postgis和sqlite 中插入数据。

用gdal1.11.0的源码默认安装,postgresql 和sqlite都没能支持

后来在机器上装了postgresql 9.1也不行,最终发现是少了一个包libpq-dev(发现查 ./configure的日志是多么的重要)

PostgreSQL support: yes
MySQL support: no
Ingres support: no

今天在机器上又装了sqlite3,也没能成功支持, 执行下面安装后

sudo apt-get install libsqlite3-dev libgeos-dev

./configure --with-spatialite=yes --with-sqlite3=yes --with-pg=/usr/bin/pg_config

显示支持为yes了

SQLite support: yes
PCRE support: no
SpatiaLite support: no

sqlite显示为make install 后,还是没有发现sqlite的选项

估计是 SpatiaLite support: no 的问题

在网上瞎找发现了这个包libspatialite-dev

https://launchpad.net/ubuntu/+source/spatialite

再执行上面的configure语句 ,状态已为yes

SQLite support: yes
PCRE support: no
SpatiaLite support: yes

执行一遍make clean,make,make install 后

ogr2ogr --long-usage  支持的format_name 里已经有PostgreSQL,SQLite了。

-f format_name: output file format name, possible values are:
-f "ESRI Shapefile"
-f "MapInfo File"
-f "TIGER"
-f "S57"
-f "DGN"
-f "Memory"
-f "BNA"
-f "CSV"
-f "GML"
-f "GPX"
-f "KML"
-f "GeoJSON"
-f "GMT"
-f "GPKG"
-f "SQLite"
-f "WAsP"
-f "PostgreSQL"
-f "PCIDSK"
-f "DXF"
-f "Geoconcept"
-f "GeoRSS"
-f "GPSTrackMaker"
-f "PGDump"
-f "GPSBabel"
-f "PDF"

ogr2ogr sqlite 调用

ogr2ogr.exe -f sqlite -lco FORMAT=WKT "D:\Downloads\GeoData\King County\trail_SHP\trail.db"
"D:\Downloads\GeoData\King County\trail_SHP\trail.shp" -t_srs EPSG:4326

...ing中

文章先这么写着,有空再整理整理

参考资料

http://lists.osgeo.org/pipermail/gdal-dev/2012-January/031546.html

http://askubuntu.com/questions/190604/how-to-install-spatialite-3-on-12-04

PostGIS在线安装http://blog.csdn.net/wildghost/article/details/7746204

再推荐大虾的一个贴:http://www.cnblogs.com/yeahgis/archive/2012/04/13/2446305.html