问题记录:
postgis 安装后不能执行以下语句,查询入库的 tif 文件
SELECT ST_AsGDALRaster(rast, 'GTiff') As rastjpg FROM radar_data_xx WHERE rid=1;
解决办法:
1. 确认是否安装 GDAL ,否则安装GDAL https://www.cnblogs.com/luochunxi/p/16981351.html
apt-get install gdal-bin ogrinfo --version apt-get install libgdal-dev gdal-config --version
2. 添加环境变量,让 postgis 能找到 https://www.osgeo.cn/postgis-manual/postgis_administration.html#raster_configuration
vim /etc/profile # 添加变量 POSTGIS_ENABLE_OUTDB_RASTERS=1 POSTGIS_GDAL_ENABLED_DRIVERS=ENABLE_ALL GDAL_DATA=/usr/share/gdal source /etc/profile 如果是容器的话,从新在进入后环境变量没了 https://blog.csdn.net/tianyi520jx/article/details/127112668 vim /root/.bashrc # 添加 source /etc/profile source /root/.bashrc
3 如还是不行,重新启动容器,在命令上添加环境变量
docker run -t --name postgisxx --restart always -e POSTGIS_GDAL_ENABLED_DRIVERS='ENABLE_ALL' -e POSTGIS_ENABLE_OUTDB_RASTERS=1 -e GDAL_DATA='/usr/share/gdal' -e POSTGRES_USER='nb_db' -e POSTGRES_PASSWORD='htht@2022' -e ALLOW_IP_RANGE=0.0.0.0/0 -p 8431:5432 -v /home/postgisxx:/var/lib/postgresql/data -d postgisxx1:latest
标签:rt,raster,ENABLE,--,Could,postgis,GDAL,POSTGIS,gdal From: https://www.cnblogs.com/luochunxi/p/16984593.html