<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LiangXu Wang &#187; PostGIS</title>
	<atom:link href="http://wlx.westgis.ac.cn/tag/postgis/feed/" rel="self" type="application/rss+xml" />
	<link>http://wlx.westgis.ac.cn</link>
	<description>research of gis, rs, opensource.</description>
	<lastBuildDate>Wed, 28 Jul 2010 17:08:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>导入landuse数据的最终脚本</title>
		<link>http://wlx.westgis.ac.cn/243/</link>
		<comments>http://wlx.westgis.ac.cn/243/#comments</comments>
		<pubDate>Mon, 04 Sep 2006 13:48:44 +0000</pubDate>
		<dc:creator>wlx</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PostGIS]]></category>

		<guid isPermaLink="false">http://wlxblog.westgis.ac.cn/243/</guid>
		<description><![CDATA[经过漫长的测试（3天的运行），修改后的最终版本可以实现：
保存当前进度
下次运行可以从上次进度运行
可以更新县区代码
可以更新时间
最终的代码如下：
#!/bin/sh
# cd /opt/to_reback/data/landuse
#set -x
d1=./tmpdata1
d2=./tmpdata2
YEAR="80年代末 1995年 2000年"
for a in $YEAR; do
  for b in $a/*; do #province, 目录判断
    if [ -d $b ]; then
      rm -fdr $d1
      rm -fdr $d2
      for c in $b/ld*; do # areacode, [...]]]></description>
			<content:encoded><![CDATA[<p>经过漫长的测试（3天的运行），修改后的最终版本可以实现：</p>
<blockquote><p>保存当前进度<br />
下次运行可以从上次进度运行<br />
可以更新县区代码<br />
可以更新时间</p></blockquote>
<p>最终的代码如下：</p>
<blockquote><p>#!/bin/sh<br />
# cd /opt/to_reback/data/landuse<br />
#set -x<br />
d1=./tmpdata1<br />
d2=./tmpdata2<br />
YEAR="80年代末 1995年 2000年"<br />
for a in $YEAR; do<br />
  for b in $a/*; do #province, 目录判断<br />
    if [ -d $b ]; then<br />
      rm -fdr $d1<br />
      rm -fdr $d2<br />
      for c in $b/ld*; do # areacode, 县级区域<br />
        bb=`echo $b | sed "s/\///g"` # 去除/特殊字符，否则sed罢工<br />
        areacode=`echo $c | sed "s/\///g" | sed "s/$bb//g" | sed "s/ld//g"`<br />
        #echo $c<br />
        if [ `cat work.log | grep "$c"` ]; then<br />
          echo $c<br />
          echo "already done!"<br />
       else<br />
        ogr2ogr $d1 $c &#038;& ogr2ogr $d2 $d1/PAL.shp -f "ESRI Shapefile" -select area,perimeter,r_area,ln71,ln72,ln73,ln74,aftln,tm20,tm30,tm40,tm50,tm60,afttm,ph41,ph52,ph53,net || exit<br />
    shp2pgsql -a -g the_geom -i $d2/PAL.shp landuse | psql -d westdc || exit<br />
        psql -d westdc -c "update landuse set areacode='$areacode' where areacode=''" || exit<br />
      echo $c >> work.log<br />
     #  echo "here not done"<br />
       echo $c<br />
        #exit<br />
       fi<br />
      done<br />
      #vacuumdb westdc<br />
     fi<br />
  done<br />
  psql -d westdc -c "update landuse set year='$a' where year=''" || exit<br />
done<br />
#set +x
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://wlx.westgis.ac.cn/243/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用shell脚本导入landuse数据到postgis</title>
		<link>http://wlx.westgis.ac.cn/232/</link>
		<comments>http://wlx.westgis.ac.cn/232/#comments</comments>
		<pubDate>Fri, 01 Sep 2006 08:18:02 +0000</pubDate>
		<dc:creator>wlx</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PostGIS]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://wlxblog.westgis.ac.cn/232/</guid>
		<description><![CDATA[全国的土地利用数据，80年代末,1995和2000年3期数据，ARCINFO COVERAGE格式，打算直接转入POSTGIS库中。
写了一个shell文件，花费了2天时间。主要是shell的东西是边看边写的，特别是变量处理，还真是麻烦。
运行shell文件要先进入到landuse目录，postgis里应该已经有westdc库，并且已经
进行了POSTGIS初始化，导入过landuse表，并且已经增加了areacode和year字段，不能为NULL，且默认为空值。
从avcbin格式到postgis库，因为数据表的关系，作了两次转换。提出了ARCINFO中的cov#和cov-id字段。

#!/bin/sh
# cd /opt/to_reback/data/landuse
tmpdata=./tmpdata
YEAR="80年代末 1995年 2000年"
for a in $YEAR; do
  for b in $a/*; do #province, 目录判断
    if [ -d $b ]; then
      rm -fdr $tmpdata
      for c in $b/ld*; do # areacode, 县级区域
        [...]]]></description>
			<content:encoded><![CDATA[<p>全国的土地利用数据，80年代末,1995和2000年3期数据，ARCINFO COVERAGE格式，打算直接转入POSTGIS库中。<br />
写了一个shell文件，花费了2天时间。主要是shell的东西是边看边写的，特别是变量处理，还真是麻烦。<br />
运行shell文件要先进入到landuse目录，postgis里应该已经有westdc库，并且已经<br />
进行了POSTGIS初始化，导入过landuse表，并且已经增加了areacode和year字段，不能为NULL，且默认为空值。<br />
从avcbin格式到postgis库，因为数据表的关系，作了两次转换。提出了ARCINFO中的cov#和cov-id字段。</p>
<blockquote><p>
#!/bin/sh<br />
# cd /opt/to_reback/data/landuse<br />
tmpdata=./tmpdata<br />
YEAR="80年代末 1995年 2000年"<br />
for a in $YEAR; do<br />
  for b in $a/*; do #province, 目录判断<br />
    if [ -d $b ]; then<br />
      rm -fdr $tmpdata<br />
      for c in $b/ld*; do # areacode, 县级区域<br />
        bb=`echo $b | sed "s/\///g"` # 去除/特殊字符，否则sed罢工<br />
        areacode=`echo $c | sed "s/\///g" | sed "s/$bb//g" | sed "s/ld//g"` #主要时间都花费在这儿了<br />
        ogr2ogr $tmpdata $c<br />
        ogr2ogr $tmpdata/poly.shp $tmpdata/PAL.shp -select area,perimeter,r_area,ln71,ln72,ln73,ln74,aftln,tm20,tm30,tm40,tm50,tm60,afttm,ph41,ph52,ph53,net<br />
    shp2pgsql -a -g the_geom -i $tmpdata/poly.shp landuse | psql -d westdc<br />
        psql -d westdc -c "update landuse set areacode='$areacode' where areacode=''"<br />
        psql -d westdc -c "update landuse set year='$a' where year=''"<br />
       # exit<br />
      done<br />
     fi<br />
  done<br />
done</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://wlx.westgis.ac.cn/232/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>install and use postgis in debian/ubuntu</title>
		<link>http://wlx.westgis.ac.cn/214/</link>
		<comments>http://wlx.westgis.ac.cn/214/#comments</comments>
		<pubDate>Thu, 10 Aug 2006 08:22:27 +0000</pubDate>
		<dc:creator>wlx</dc:creator>
				<category><![CDATA[PostGIS]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://wlxblog.westgis.ac.cn/214/</guid>
		<description><![CDATA[因为postgis已经进入debian的库了，就把原来用source安钻的postgresql和postgis都删除掉，然后从库中安装。
aptitude install postgresql-8.1-postgis
然后再创建数据库，并作相应的初始化工作：
createlang plpgsql yourdatabase
psql -f `locate lwpostgis.sql` -d yourdatabase
psql -f `locate spatial_ref_sys.sql` -d yourdatabase
最后再添加一个超级用户：
create user xxx with password 'passwd' createuser createdb
]]></description>
			<content:encoded><![CDATA[<p>因为postgis已经进入debian的库了，就把原来用source安钻的postgresql和postgis都删除掉，然后从库中安装。<br />
aptitude install postgresql-8.1-postgis<br />
然后再创建数据库，并作相应的初始化工作：<br />
createlang plpgsql yourdatabase<br />
psql -f `locate lwpostgis.sql` -d yourdatabase<br />
psql -f `locate spatial_ref_sys.sql` -d yourdatabase</p>
<p>最后再添加一个超级用户：<br />
create user xxx with password 'passwd' createuser createdb</p>
]]></content:encoded>
			<wfw:commentRss>http://wlx.westgis.ac.cn/214/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>传统的postgis安装方法@dapper</title>
		<link>http://wlx.westgis.ac.cn/197/</link>
		<comments>http://wlx.westgis.ac.cn/197/#comments</comments>
		<pubDate>Sun, 14 May 2006 17:08:22 +0000</pubDate>
		<dc:creator>wlx</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PostGIS]]></category>
		<category><![CDATA[dapper]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.mygis.org/197/</guid>
		<description><![CDATA[首先下载postgis source code，然后解开：
运行传统的安装方法：
./configure
make
注意若提示缺少相关的lib，如pam,krb5等库，可从库中安装。
然后：
checkinstall -D
sudo dpkg -i
若不想用deb安装，也可以直接：
make install
]]></description>
			<content:encoded><![CDATA[<p>首先下载postgis source code，然后解开：<br />
运行传统的安装方法：<br />
./configure<br />
make<br />
注意若提示缺少相关的lib，如pam,krb5等库，可从库中安装。<br />
然后：<br />
checkinstall -D<br />
sudo dpkg -i<br />
若不想用deb安装，也可以直接：<br />
make install</p>
]]></content:encoded>
			<wfw:commentRss>http://wlx.westgis.ac.cn/197/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>转移POSTGIS数据</title>
		<link>http://wlx.westgis.ac.cn/103/</link>
		<comments>http://wlx.westgis.ac.cn/103/#comments</comments>
		<pubDate>Tue, 02 Aug 2005 13:34:36 +0000</pubDate>
		<dc:creator>wlx</dc:creator>
				<category><![CDATA[PostGIS]]></category>

		<guid isPermaLink="false">http://blog.mygis.org/103/</guid>
		<description><![CDATA[从postgresql 8.01+ postgis 1.0 的数据拷贝到postgresql 7.4.7+ postgis 1.0上，
使用POSTGIS提供的pl程序不成功，后来试验最初的版本，虽然提示有些错误，但还是成功转移了数据。

pg_dump -f dumpfile.sql yourdatabase
	dropdb yourdatabase
	createdb yourdatabase
	createlang plpgsql yourdatabase
	psql -f lwpostgis.sql -d yourdatabase
	psql -f dumpfile.sql -d yourdatabase
	vacuumdb -z yourdatabase
]]></description>
			<content:encoded><![CDATA[<p>从postgresql 8.01+ postgis 1.0 的数据拷贝到postgresql 7.4.7+ postgis 1.0上，<br />
使用POSTGIS提供的pl程序不成功，后来试验最初的版本，虽然提示有些错误，但还是成功转移了数据。</p>
<blockquote><p>
pg_dump -f dumpfile.sql yourdatabase<br />
	dropdb yourdatabase<br />
	createdb yourdatabase<br />
	createlang plpgsql yourdatabase<br />
	psql -f lwpostgis.sql -d yourdatabase<br />
	psql -f dumpfile.sql -d yourdatabase<br />
	vacuumdb -z yourdatabase</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://wlx.westgis.ac.cn/103/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>pgadmin3 ubuntu 5.04 can not connect</title>
		<link>http://wlx.westgis.ac.cn/84/</link>
		<comments>http://wlx.westgis.ac.cn/84/#comments</comments>
		<pubDate>Fri, 20 May 2005 10:12:59 +0000</pubDate>
		<dc:creator>wlx</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PostGIS]]></category>
		<category><![CDATA[pgadmin]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.mygis.org/84/</guid>
		<description><![CDATA[默认安装的postgresql是认证所有用户的，全部都是ident sameuser，但是在pgadmin3怎么也无法进入。
最后只好修改postgresql的pg_hba文件了。
把来自localhost的全部改为trust。
（这样好像有点安全问题，但若本机只有自己能用，安全性也还过得去吧）
]]></description>
			<content:encoded><![CDATA[<p>默认安装的postgresql是认证所有用户的，全部都是ident sameuser，但是在pgadmin3怎么也无法进入。<br />
最后只好修改postgresql的pg_hba文件了。<br />
把来自localhost的全部改为trust。</p>
<p>（这样好像有点安全问题，但若本机只有自己能用，安全性也还过得去吧）</p>
]]></content:encoded>
			<wfw:commentRss>http://wlx.westgis.ac.cn/84/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>postgis在windows下的应用</title>
		<link>http://wlx.westgis.ac.cn/68/</link>
		<comments>http://wlx.westgis.ac.cn/68/#comments</comments>
		<pubDate>Tue, 05 Apr 2005 09:59:52 +0000</pubDate>
		<dc:creator>wlx</dc:creator>
				<category><![CDATA[PostGIS]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://blog.mygis.org/68/</guid>
		<description><![CDATA[目前，windows下的版本，postgresql官方已经开始支持，目前是8.0.1版本。POSTGIS目前官方尚不支持windows版本，但有支援者在进行同步维护windows版本，目前是1.0-rc6版本，估计很快就是1.0版本了。

1、安装
安装很简单，首先要安装postgresql，注意其有两个帐号，一是系统帐号，二是数据库管理帐号。安装程序可以新建用户，要提到一点，目前的postgresql数据库不支持远程安装，就是说，不能通过远程桌面进行安装（这个限制，不爽）。windows版本还包括了pgadmin3，图形化的管理界面。
然后安装postgis，需要前面安装postgresql的管理员帐号，同时其还要安装一个postgis数据库。
默认情况下，可执行文件都安装到postgresql的bin目录，几个SQL文件安装在postgresql的share/contrib目录下。

2、使用
对于中文用户来讲，首先要考虑数据库的编码问题，可以使用unicode,utf8,euc_cn等编码，默认的是unicode编码。
第一次使用unicode编码时移植linux下的应用，遇到了很多非常奇怪的问题。改用euc_cn编码，问题就少多了。
建库：
createdb -U postgres -E EUC_CN db
（linux环境下本机默认都不需要认证密码，但在windows系统下，默认是需要验证密码的）
alter database db set client_encode="EUC_CN"
（这个要进入到psql环境中才能运行的，不确定是否必须，在linux环境下不需要）
搭建postgis环境：
creatlang -U postgres   plpgsql db
(这个在windows下默认好象是不需要处理的）
引入postgis支持：
psql -U postgres -d db -f lwpostgis.sql
psql -U postgres -d db -f spatial_ref_sys.sql
生成矢量数据的sql文件：
shp2pgsql xx.shp xx_table > xx.sql
导入到数据库：
psql -U postgres -d db -f xx.sql

3、开始应用
到此，您的基本的postgis数据库就已经搭建好了，剩下的工作就是看您怎么去最大的压榨postgis的功能了。
]]></description>
			<content:encoded><![CDATA[<p>目前，windows下的版本，postgresql官方已经开始支持，目前是8.0.1版本。POSTGIS目前官方尚不支持windows版本，但有支援者在进行同步维护windows版本，目前是1.0-rc6版本，估计很快就是1.0版本了。</p>
<ul>
1、安装</ul>
<p>安装很简单，首先要安装postgresql，注意其有两个帐号，一是系统帐号，二是数据库管理帐号。安装程序可以新建用户，要提到一点，目前的postgresql数据库不支持远程安装，就是说，不能通过远程桌面进行安装（这个限制，不爽）。windows版本还包括了pgadmin3，图形化的管理界面。<br />
然后安装postgis，需要前面安装postgresql的管理员帐号，同时其还要安装一个postgis数据库。<br />
默认情况下，可执行文件都安装到postgresql的bin目录，几个SQL文件安装在postgresql的share/contrib目录下。</p>
<ul>
2、使用</ul>
<p>对于中文用户来讲，首先要考虑数据库的编码问题，可以使用unicode,utf8,euc_cn等编码，默认的是unicode编码。<br />
第一次使用unicode编码时移植linux下的应用，遇到了很多非常奇怪的问题。改用euc_cn编码，问题就少多了。</p>
<p>建库：<br />
createdb -U postgres -E EUC_CN db<br />
（linux环境下本机默认都不需要认证密码，但在windows系统下，默认是需要验证密码的）<br />
alter database db set client_encode="EUC_CN"<br />
（这个要进入到psql环境中才能运行的，不确定是否必须，在linux环境下不需要）<br />
搭建postgis环境：<br />
creatlang -U postgres   plpgsql db<br />
(这个在windows下默认好象是不需要处理的）<br />
引入postgis支持：<br />
psql -U postgres -d db -f lwpostgis.sql<br />
psql -U postgres -d db -f spatial_ref_sys.sql<br />
生成矢量数据的sql文件：<br />
shp2pgsql xx.shp xx_table > xx.sql<br />
导入到数据库：<br />
psql -U postgres -d db -f xx.sql</p>
<ul>
3、开始应用</ul>
<p>到此，您的基本的postgis数据库就已经搭建好了，剩下的工作就是看您怎么去最大的压榨postgis的功能了。</p>
]]></content:encoded>
			<wfw:commentRss>http://wlx.westgis.ac.cn/68/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The xpsql Project</title>
		<link>http://wlx.westgis.ac.cn/59/</link>
		<comments>http://wlx.westgis.ac.cn/59/#comments</comments>
		<pubDate>Wed, 23 Mar 2005 07:48:23 +0000</pubDate>
		<dc:creator>wlx</dc:creator>
				<category><![CDATA[PostGIS]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xpsql]]></category>

		<guid isPermaLink="false">http://blog.mygis.org/59/</guid>
		<description><![CDATA[在POSTGRESQL基础上实现了XML的关系数据库管理

http://gborg.postgresql.org/project/xpsql/
]]></description>
			<content:encoded><![CDATA[<p>在POSTGRESQL基础上实现了XML的关系数据库管理<br />
<img src="http://gborg.postgresql.org/images/projects/xpsql/screenshots/arche.png" alt="xml data relation struction" /><br />
<a href="http://gborg.postgresql.org/project/xpsql/">http://gborg.postgresql.org/project/xpsql/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wlx.westgis.ac.cn/59/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>postgis数据库初始化</title>
		<link>http://wlx.westgis.ac.cn/56/</link>
		<comments>http://wlx.westgis.ac.cn/56/#comments</comments>
		<pubDate>Mon, 14 Mar 2005 07:51:50 +0000</pubDate>
		<dc:creator>wlx</dc:creator>
				<category><![CDATA[PostGIS]]></category>
		<category><![CDATA[init]]></category>

		<guid isPermaLink="false">http://blog.mygis.org/56/</guid>
		<description><![CDATA[createlang plpgsql yourdatabase
psql -f lwpostgis.sql -d yourdatabase
psql -f spatial_ref_sys.sql -d yourdatabase
]]></description>
			<content:encoded><![CDATA[<p>createlang plpgsql yourdatabase<br />
psql -f lwpostgis.sql -d yourdatabase<br />
psql -f spatial_ref_sys.sql -d yourdatabase</p>
]]></content:encoded>
			<wfw:commentRss>http://wlx.westgis.ac.cn/56/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>postgis中OID的问题</title>
		<link>http://wlx.westgis.ac.cn/12/</link>
		<comments>http://wlx.westgis.ac.cn/12/#comments</comments>
		<pubDate>Tue, 23 Nov 2004 14:38:49 +0000</pubDate>
		<dc:creator>wlx</dc:creator>
				<category><![CDATA[GIS]]></category>
		<category><![CDATA[MapServer]]></category>
		<category><![CDATA[oid]]></category>
		<category><![CDATA[PostGIS]]></category>
		<category><![CDATA[qgis]]></category>

		<guid isPermaLink="false">http://blog.mygis.org/index.php?p=12</guid>
		<description><![CDATA[好象是postgis目前的一个BUG。
postgis-0.9,postgresql-8.0.0beta4,mapserver4.4beta2
目前的新版本的postgresql，建库时若不指定则默认无OID，但若无OID，则此空间表则不能被其他程序所访问。
包括MAPSERVER、QGIS等。
]]></description>
			<content:encoded><![CDATA[<p>好象是postgis目前的一个BUG。<br />
postgis-0.9,postgresql-8.0.0beta4,mapserver4.4beta2<br />
目前的新版本的postgresql，建库时若不指定则默认无OID，但若无OID，则此空间表则不能被其他程序所访问。<br />
包括MAPSERVER、QGIS等。</p>
]]></content:encoded>
			<wfw:commentRss>http://wlx.westgis.ac.cn/12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
