gdal介绍
gdal的一个用c++语言编写的库,用于处理地理信息相关的数据包括转换,识别数据,格式化数据以及解析
同时提供第三方语言的SDK包括python,java上述需要编译后使用 java是需要使用jni接口调用实现方法在window平台是DLL文件,在linux平台是so文件,最后需要使用和初始化服务。
gdal命令使用
1、ogrinfo
orginfo –version
ogrinfo –help
2、ogr2ogr
- ogr2ogr postgis转shp 并执行SQL
ogr2ogr -f “ESRI Shapefile” file1.shp PG:”host=’192.168.7.11’ port=’5432’ dbname=’postgres’ user=’postgres’ password=’1111’” -sql “select * from like_fff_xztc” -dialect PostgreSQL
- ogr2ogr postgis转化为shp文件且指定SQL执行
ogr2ogr -f “ESRI Shapefile” /app/tmp/result_like_fff_xztc/result_like_fff_xztc.shp PG:”host=’192.168.7.11’ port=’5432’ dbname=’postgres’ user=’postgres’ password=’1111’” -sql “select fid,objectid,bsm,dlmc,qsdwmc,zldwmc,f_xzqhmc,f_year,f_month,partitionno,se_anno_cad_data,tbdlmj,ysdm,dlbm,qsxz,qsdwdm,zldwdm,xzgdlx,zldj,f_xzqhdm,f_diccode,f_fileid,tbbh,shape_length,shape_area,st_transForm(geom,4490) as geom from like_fff_xztc where ST_Intersects(geom,st_transform(st_geomFromText(‘MULTIPOLYGON(((112.973570327973 30.634569982416,112.973501343979 30.6344597898424,112.973423613701 30.6344687491655)))’,4490),4490))” -dialect PostgreSQL –config SHAPE_ENCODING ‘UTF-8’
- ogr2ogr shp导入shp 命令
ogr2ogr -f “PostgreSQL” PG:”host=’192.168.7.11’ port=’5432’ dbname=’test’ user=’postgres’ password=’1111’” C:\Users\Administrator\Desktop\ceshi\old\Water_region.shp -progress -nlt PROMOTE_TO_MULTI -lco GEOMETRY_NAME=geom -lco FID=fid -overwrite -nln ‘like_test_update’ -unsetFieldWidth –config SHAPE_ENCODING ‘utf-8’
- ogr2ogr mdb导入shp命令
ogr2ogr -f “PostgreSQL” PG:”host=’192.168.7.11’ port=’5432’ dbname=’test_new_app’ user=’postgres’ password=’1111’” /app/laohekou.mdb -progress -nlt PROMOTE_TO_MULTI -lco GEOMETRY_NAME=geom -lco FID=fid -overwrite -nln ‘test_mdb_001’
- ogr2ogr shp转入postgis
ogr2ogr -f “PostgreSQL” PG:”host=xxx user=xxx password=xxx dbname=cxxxhina” -nlt GEOMETRY 省级行政区.shp
3、
官方gdal的dockerfile简介
gdal/docker at master · OSGeo/gdal
Alpine based
Alpine version:
- 3.15 for 3.5
- 3.16 for GDAL 3.6dev
Small:
osgeo/gdal:alpine-small-latest
- Image size: ~ 59 MB
- Raster drivers: ultrasmall + built-in + SQLite-based ones + network-based ones
- Vector drivers: ultrasmall + built-in + most XML-based ones + network-based ones + PostgreSQL
- Using internal libtiff and libgeotiff
- External libraries enabled: ultrasmall + libexpat, libpq, libssl
- No GDAL Python
- Base PROJ grid package (http://download.osgeo.org/proj/proj-datumgrid-1.8.zip)
- Overall licensing terms of the GDAL build: permissive (MIT, BSD style, Apache, etc..)
Normal:
osgeo/gdal:alpine-normal-latest
- Image size: ~ 277 MB
- Raster drivers: small + netCDF, HDF5, BAG
- Vector drivers: small + Spatialite, XLS
- Using internal libtiff and libgeotiff
- External libraries enabled: small + libgeos, libhdf5, libhdf5, libkea, libnetcdf, libfreexl, libspatialite, libxml2, libpoppler, openexr, libheif, libdeflate, libparquet
- GDAL Python
- Base PROJ grid package (http://download.osgeo.org/proj/proj-datumgrid-1.8.zip)
- Overall licensing terms of the GDAL build: copy-left (GPL) + LGPL + permissive
Ubuntu based
Ubuntu version:
- 20.04 for GDAL 3.4 and 3.5
- 22.04 for GDAL 3.6dev
Small:
osgeo/gdal:ubuntu-small-latest
- Image size: ~ 385 MB
- Raster drivers: all built-in + JPEG + PNG + JP2OpenJPEG + WEBP +SQLite-based ones + network-based ones
- Vector drivers: all built-in + XML based ones + SQLite-based ones + network-based ones + PostgreSQL
- Using internal libtiff and libgeotiff
- External libraries enabled: libsqlite3, libproj, libcurl, libjpeg, libpng, libwebp, libzstd, libexpat, libxerces-c, libpq, libssl, libgeos, libspatialite
- GDAL Python (Python 3.8 for Ubuntu 20.04, Python 3.10 for Ubuntu 22.04)
- Base PROJ grid package (http://download.osgeo.org/proj/proj-datumgrid-1.8.zip)
- Overall licensing terms of the GDAL build: LGPL + permissive (MIT, BSD style, Apache, etc..)
Full:
osgeo/gdal:ubuntu-full-latest
(aliased toosgeo/gdal
)
- Image size: ~ 1.48 GB
- Raster drivers: all based on almost all possible free and open-source dependencies
- Vector drivers: all based on almost all possible free and open-source dependencies
- Using internal libtiff and libgeotiff
- External libraries enabled: small + libnetcdf, libhdf4, libhdf5, libtiledb, libkea, mongocxx 3.4, libspatialite, unixodbc, libxml2, libcfitsio, libmysqlclient, libkml, libpoppler, pdfium, openexr, libheif, libdeflate, libparquet
- GDAL Python (Python 3.8 for Ubuntu 20.04, Python 3.10 for Ubuntu 22.04)
- All PROJ grid packages (equivalent of latest of proj-data-X.zip from http://download.osgeo.org/proj/ at time of generation, > 500 MB)
- Overall licensing terms of the GDAL build: copy-left (GPL) + LGPL + permissive
点击进入后可以看到介绍,目前分别在两个linux发行版本上进行镜像文件创建,分别是Ubuntu,和alpine
alpine是精简的服务目前不包括第三方的拓展目前在linux上不支持pgeo(改数据源可以读取mdb和其他格式数据的支持)
ubuntu是完整版是提供全量的服务,支持pgeo
介绍
linux下面读取微软的软件word,Excel,PPT是有平台和驱动,但是像access这种个人数据库需要ODBC这个开源平台来读取这类数据,gdal在linux平台通过ODBC接口来读取access个人数据库,同时对数据解析,我们需要利用这个解析工具来读取数据被我们java读取,或者通过ogr2ogr命令来转换数据
ODBC
是linux平台的数据的解析
ogrinfo 能识别
odbcinst -j 表示odbc正确安装
方法一osgeo/gdal:ubuntu-full基础上安装(unixODBC,mdbtools)
1 |
|