raster导入postgres Windows命令

来源:互联网 发布:python ide eclipse 编辑:程序博客网 时间:2024/06/03 19:59

cmd命令行

raster2pgsql -s 4326 -I -C -M C:\Users\tt\Downloads\tmean_19_tif\*.tif -F -t 256x256 tmean_19 | psql -h localhost -p 5432 -U postgres -d raster -W

之后输入数据库密码

导入后数据表中的raster字段不显示数据,通过读取方式可测试

# -*- coding: utf-8 -*-import psycopg2# Connect to an existing databaseconn = psycopg2.connect('host=localhost port=5432 user=postgres password=123 dbname=raster')# Open a cursor to perform database operationscur = conn.cursor()# Execute SQL query# cur.execute("SELECT ST_AsTIFF(rast, 'LZW') AS rasttiff FROM staging.wsiearth WHERE rid=1;")cur.execute("SELECT ST_AsTIFF(ST_Union(rast), 'LZW') AS rasttiff FROM public.tmean_19 WHERE filename='tmean10_19.tif';")# Fetch data as Python objectsrasttiff = cur.fetchone()# Write data to fileif rasttiff is not None:    open('D:/mapnik/mapnik-v2.2.0/shp/mapnik/tmean1.tif', 'wb').write(str(rasttiff[0]))# Close communication with the databasecur.close()conn.close()

用python的pip工具下载安装包

C:\Python27\Scripts\pip.exe

http://blog.csdn.net/theonegis/article/details/55100365
http://blog.csdn.net/theonegis/article/details/55050943

0 0
原创粉丝点击