<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>《用shell脚本导入landuse数据到postgis》的评论</title>
	<atom:link href="http://wlx.westgis.ac.cn/232/feed/" rel="self" type="application/rss+xml" />
	<link>http://wlx.westgis.ac.cn/232/</link>
	<description>technology backup/share</description>
	<lastBuildDate>Thu, 24 Nov 2011 13:56:56 +0800</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>作者：GIS RS Linux</title>
		<link>http://wlx.westgis.ac.cn/232/comment-page-1/#comment-2286</link>
		<dc:creator>GIS RS Linux</dc:creator>
		<pubDate>Mon, 04 Sep 2006 13:48:59 +0000</pubDate>
		<guid isPermaLink="false">http://wlxblog.westgis.ac.cn/232/#comment-2286</guid>
		<description>&lt;strong&gt;导入landuse数据的最终脚本...&lt;/strong&gt;

经过漫长的测试（3天的运行），修改后的最终版本可以实现：
保存当前进度
下次运行可以从上次进度运行
可以更新县区代码
可以更新时间
最终的代码如下：
#!/bin/sh
# cd /opt/to_reback/data/landus...</description>
		<content:encoded><![CDATA[<p><strong>导入landuse数据的最终脚本&#8230;</strong></p>
<p>经过漫长的测试（3天的运行），修改后的最终版本可以实现：<br />
保存当前进度<br />
下次运行可以从上次进度运行<br />
可以更新县区代码<br />
可以更新时间<br />
最终的代码如下：<br />
#!/bin/sh<br />
# cd /opt/to_reback/data/landus&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：wlx</title>
		<link>http://wlx.westgis.ac.cn/232/comment-page-1/#comment-2284</link>
		<dc:creator>wlx</dc:creator>
		<pubDate>Mon, 04 Sep 2006 06:06:21 +0000</pubDate>
		<guid isPermaLink="false">http://wlxblog.westgis.ac.cn/232/#comment-2284</guid>
		<description>或许，vacuumdb westdc命令应该插入在每次更新之后？</description>
		<content:encoded><![CDATA[<p>或许，vacuumdb westdc命令应该插入在每次更新之后？</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：wlx</title>
		<link>http://wlx.westgis.ac.cn/232/comment-page-1/#comment-2283</link>
		<dc:creator>wlx</dc:creator>
		<pubDate>Mon, 04 Sep 2006 06:05:13 +0000</pubDate>
		<guid isPermaLink="false">http://wlxblog.westgis.ac.cn/232/#comment-2283</guid>
		<description>太慢了，不知道是什么原因。
再修改一下：
&lt;blockquote&gt;
#!/bin/sh
# cd /opt/to_reback/data/landuse
#set -x
d1=./tmpdata1
d2=./tmpdata2
YEAR=&quot;80年代末 1995年 2000年&quot;
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, 县级区域
        bb=`echo $b &#124; sed &quot;s/\///g&quot;` # 去除/特殊字符，否则sed罢工
        areacode=`echo $c &#124; sed &quot;s/\///g&quot; &#124; sed &quot;s/$bb//g&quot; &#124; sed &quot;s/ld//g&quot;`
        echo $c
        ogr2ogr $d1 $c &amp;&amp; ogr2ogr $d2 $d1/PAL.shp -f &quot;ESRI Shapefile&quot; -select area,perimeter,r_area,ln71,ln72,ln73,ln74,aftln,tm20,tm30,tm40,tm50,tm60,afttm,ph41,ph52,ph53,net &#124;&#124; exit
    shp2pgsql -a -g the_geom -i $d2/PAL.shp landuse &#124; psql -d westdc &#124;&#124; exit
        psql -d westdc -c &quot;update landuse set areacode=&#039;$areacode&#039; where areacode=&#039;&#039;&quot; &#124;&#124; exit
       # exit
      done
     fi
  done
  psql -d westdc -c &quot;update landuse set year=&#039;$a&#039; where year=&#039;&#039;&quot; &#124;&#124; exit
done
#set +x
&lt;/blockquote&gt;
或许，应该再设置一个临时文件，记录已经处理的文件（目录名），然后可以随时中断／继续？</description>
		<content:encoded><![CDATA[<p>太慢了，不知道是什么原因。<br />
再修改一下：</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 />
        ogr2ogr $d1 $c &#038;&#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=&#8217;$areacode&#8217; where areacode=”” || exit<br />
       # exit<br />
      done<br />
     fi<br />
  done<br />
  psql -d westdc -c “update landuse set year=&#8217;$a&#8217; where year=”” || exit<br />
done<br />
#set +x
</p></blockquote>
<p>或许，应该再设置一个临时文件，记录已经处理的文件（目录名），然后可以随时中断／继续？</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：wlx</title>
		<link>http://wlx.westgis.ac.cn/232/comment-page-1/#comment-2278</link>
		<dc:creator>wlx</dc:creator>
		<pubDate>Fri, 01 Sep 2006 13:15:43 +0000</pubDate>
		<guid isPermaLink="false">http://wlxblog.westgis.ac.cn/232/#comment-2278</guid>
		<description>run了一下午，出现错误了。
把脚本重新修改了一下，适应性更强。
&lt;blockquote&gt;
#!/bin/sh
# cd /opt/to_reback/data/landuse
#set -x
d1=./tmpdata1
d2=./tmpdata2
YEAR=&quot;80年代末 1995年 2000年&quot;
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, 县级区域
        bb=`echo $b &#124; sed &quot;s/\///g&quot;` # 去除/特殊字符，否则sed罢工
        areacode=`echo $c &#124; sed &quot;s/\///g&quot; &#124; sed &quot;s/$bb//g&quot; &#124; sed &quot;s/ld//g&quot;`
        echo $c
        ogr2ogr $d1 $c &amp;&amp; ogr2ogr $d2 $d1/PAL.shp -f &quot;ESRI Shapefile&quot; -select area,perimeter,r_area,ln71,ln72,ln73,ln74,aftln,tm20,tm30,tm40,tm50,tm60,afttm,ph41,ph52,ph53,net &#124;&#124; exit
    shp2pgsql -a -g the_geom -i $d2/PAL.shp landuse &#124; psql -d westdc &#124;&#124; exit
        psql -d westdc -c &quot;update landuse set areacode=&#039;$areacode&#039; where areacode=&#039;&#039;&quot; &#124;&#124; exit
        psql -d westdc -c &quot;update landuse set year=&#039;$a&#039; where year=&#039;&#039;&quot; &#124;&#124; exit
       # exit
      done
     fi
  done
done
#set +x

&lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<p>run了一下午，出现错误了。<br />
把脚本重新修改了一下，适应性更强。</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 />
        ogr2ogr $d1 $c &#038;&#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=&#8217;$areacode&#8217; where areacode=”” || exit<br />
        psql -d westdc -c “update landuse set year=&#8217;$a&#8217; where year=”” || exit<br />
       # exit<br />
      done<br />
     fi<br />
  done<br />
done<br />
#set +x</p>
</blockquote>
]]></content:encoded>
	</item>
</channel>
</rss>

