raster导入postgres Windows命令

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 database
conn = psycopg2.connect('host=localhost port=5432 user=postgres password=123 dbname=raster')

# Open a cursor to perform database operations
cur = 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 objects
rasttiff = cur.fetchone()

# Write data to file
if rasttiff is not None:
    open('D:/mapnik/mapnik-v2.2.0/shp/mapnik/tmean1.tif', 'wb').write(str(rasttiff[0]))

# Close communication with the database
cur.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
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值