1. 现在安装包:
https://www.gisinternals.com/release.php
找到最新版本:
然后找到core:
下载,双击安装。
2. 配置环境变量:
setx GDAL_DATA "C:\Program Files\GDAL\gdal-data"
setx GDAL_DRIVER_PATH "C:\Program Files\GDAL\gdalplugins"
setx PROJ_LIB "C:\Program Files\GDAL\projlib"
setx PYTHONPATH "C:\Program Files\GDAL\" --这个可以先不配置
3. 执行命令
gdal的命令解释官网:ogr2ogr — GDAL documentation.
ogr2ogr -f "PostgreSQL" PG:"host=localhost user=postgres dbname=geojson password=postgres" G:\all_vector_data\yuanyuzhou-gbk\vega.geojson -s_srs EPSG:4326 -t_srs EPSG:4326 -nln road -lco GEOMETRY_NAME=the_geom -lco FID=gid
说明:
A. 该命令是用于给没有表的时候的。如果有表,默认会按照追加的方式给表中新增记录,执行时截图:
B. 如果想要显示的来执行替换,则加上"-overwrite"即可:
ogr2ogr -f "PostgreSQL" PG:"host=localhost user=postgres dbname=geojson password=postgres" G:\all_vector_data\yuanyuzhou-gbk\vega.geojson -s_srs EPSG:4326 -t_srs EPSG:4326 -nln road -lco GEOMETRY_NAME=the_geom -lco FID=gid -overwrite
4. 完成