<?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>iphone and gis development notes &#187; postgres</title>
	<atom:link href="http:///wordpress/category/postgres/feed/" rel="self" type="application/rss+xml" />
	<link>/wordpress</link>
	<description>By Rupert</description>
	<lastBuildDate>Sun, 29 Aug 2010 22:44:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Postgres PostGIS CheatSheet v2</title>
		<link>/wordpress/2008/08/postgres-postgis-cheatsheet-v2/</link>
		<comments>/wordpress/2008/08/postgres-postgis-cheatsheet-v2/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 05:10:32 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=229</guid>
		<description><![CDATA[This is a quick-command list of Postres. If you want detailed instructions, please visit the Postgres Manual. How do I Show all databases? 1. Using &#8220;psql -l&#8221; 2. Using postgres=# \l List of databases Name &#124; Owner &#124; Encoding ------------------+----------+---------- postgis &#124; postgres &#124; UTF8 postgres &#124; postgres &#124; UTF8 template0 &#124; postgres &#124; UTF8]]></description>
			<content:encoded><![CDATA[<p>This is a quick-command list of Postres. If you want detailed instructions, please visit the Postgres Manual.</p>
<p><strong>How do I Show all databases? </strong><br />
1. Using &#8220;psql -l&#8221;</p>
<p>2. Using</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">postgres</span>=<span style="color: #666666; font-style: italic;"># \l</span>
List of databases
Name       <span style="color: #000000; font-weight: bold;">|</span>  Owner   <span style="color: #000000; font-weight: bold;">|</span> Encoding
------------------+----------+----------
postgis          <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
postgres         <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
template0        <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
template1        <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
template_postgis <span style="color: #000000; font-weight: bold;">|</span> postgres <span style="color: #000000; font-weight: bold;">|</span> UTF8
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">5</span> rows<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Note: Do not drop template databases if not necessary.</p>
<p><strong>How do I run a script from the prompt?</strong><br />
<code>psql -d cybersoftbj -u user -f myfile.sql</code></p>
<p>Its very useful in reloading user-defined functions.</p>
<p><strong>How do I create a user/role?</strong><br />
<code><br />
CREATE ROLE lbs WITH LOGIN PASSWORD 'mypassword' SUPERUSER INHERIT CREATEDB CREATEROLE;<br />
</code></p>
<p><strong>How do I change the password for a user/role?</strong><br />
<code><br />
ALTER ROLE lbs PASSWORD 'mynewpassword';<br />
</code></p>
<p><strong>How to provide/restrict access privileges to tables?</strong><br />
<code><br />
GRANT SELECT ON TABLE table TO user;<br />
REVOKE SELECT ON TABLE table FROM user;<br />
</code></p>
<p><strong>How to dump database in a text file?</strong><br />
<code><br />
pg_dump -U lbs -d cybersoftbjv1 -h 127.0.0.1 -W &gt; cybersoftbjv1.sql<br />
</code></p>
<p><strong>How to dump database cleanly?</strong><br />
<code><br />
pg_dump -c  -d -E UTF8 -h 127.0.0.1 -U lbs -W platform_v1 &gt; platform_v1.sql<br />
</code></p>
<p><strong>How to rename a database?</strong><br />
<code><br />
ALTER DATABASE beijing_app RENAME TO beijing_app_20080801;<br />
</code></p>
<p><strong>How to update using two tables?</strong><br />
<code><br />
UPDATE road_for_update u<br />
SET the_geom = r.the_geom<br />
FROM roads r<br />
WHERE r.rd_id = u.rd_id;<br />
</code></p>
<p><strong>How to change a column type with Cast?</strong><br />
<code><br />
ALTER TABLE roads ALTER COLUMN class_new TYPE integer USING class_new::integer;<br />
</code></p>
<p><strong>How to add a geometry column to a table?</strong><br />
EXAMPLE: SELECT AddGeometryColumn(&#8216;public&#8217;, &#8216;poi&#8217;, &#8216;the_geom&#8217;, 4326, &#8216;POINT&#8217;, 2)</p>
<p><strong>Changing column names with spaces?</strong><br />
<code>ALTER TABLE class_aroundme RENAME "level 1" TO level_1;</code> </p>
<p><strong>Setting kernel shmmax for postgres</strong><br />
<code>sysctl -w kernel.shmmax=134217728</code><br />
Note: For permanent changes see /etc/sysctl.cfg<strong>11. How to backup table(s) from pg_dump?</strong><br />
pg_dump poi_beijing -t class -t poi_class -f $BACKUPDIR/test_$MYDATE.sql</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/08/postgres-postgis-cheatsheet-v2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Postgres Clients Update: Navicat and EMS</title>
		<link>/wordpress/2008/07/postgres-clients-update-navicat/</link>
		<comments>/wordpress/2008/07/postgres-clients-update-navicat/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 16:37:42 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[mac]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[leopard]]></category>

		<guid isPermaLink="false">/wordpress/?p=199</guid>
		<description><![CDATA[Navicat already produced some lite (free) versions for Postgres both for Windows and Mac. Browse over the feature matrix to find out which version works for you. Note that all versions allow you to edit the record which I can&#8217;t do in pgadmin3. A quick look at EMS on Windows (VMWare) is also a note]]></description>
			<content:encoded><![CDATA[<p><img src="/wordpress/wp-content/uploads/2008/07/picture-4.png" alt="Picture 4.png" border="0" width="300" height="214" /></p>
<p>Navicat already produced some lite (free) versions for Postgres both for Windows and Mac. Browse over the <a href="http://pgsql.navicat.com/feature.html">feature matrix</a> to find out which <a href="http://pgsql.navicat.com/download.html">version</a> works for you. Note that all versions allow you to edit the record which I can&#8217;t do in pgadmin3. </p>
<p><img src="/wordpress/wp-content/uploads/2008/07/picture-3.png" alt="Picture 3.png" border="0" width="600" height="338" /></p>
<p>A quick look at EMS on Windows (VMWare) is also a note worthy client. Though the MDI interface is a bit complex, one good feature is to able to see your spatial geometry as <em>text</em> and the corresponding SRID immediately&#8230;</p>
<p><img src="/wordpress/wp-content/uploads/2008/07/picture-1.png" alt="Picture 1.png" border="0" width="427" height="253" /></p>
<p><img src="/wordpress/wp-content/uploads/2008/07/picture-2.png" alt="Picture 2.png" border="0" width="600" height="186" /></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/07/postgres-clients-update-navicat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Postgres PostGis PostInstall</title>
		<link>/wordpress/2008/06/postgres-postgis-postinstall/</link>
		<comments>/wordpress/2008/06/postgres-postgis-postinstall/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 23:34:36 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/index.php/2008/06/07/postgres-postgis-postinstall/</guid>
		<description><![CDATA[1. Edit pg_hba.conf # &#34;local&#34; is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/32 md5 host all all 192.168.1.0 255.255.255.0 md5 # IPv6 local connections: #host all all ::1/128 trust 2. Edit postgres.conf 55 56 listen_addresses = '*' # what IP address(es) to listen on;]]></description>
			<content:encoded><![CDATA[<p>1. Edit pg_hba.conf</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># &quot;local&quot; is for Unix domain socket connections only</span>
<span style="color: #7a0874; font-weight: bold;">local</span>   all         all                               trust
<span style="color: #666666; font-style: italic;"># IPv4 local connections:</span>
host    all         all         127.0.0.1<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">32</span>          md5
host    all         all         192.168.1.0 255.255.255.0       md5
<span style="color: #666666; font-style: italic;"># IPv6 local connections:</span>
<span style="color: #666666; font-style: italic;">#host    all         all         ::1/128               trust</span></pre></div></div>

<p>2. Edit postgres.conf</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">55</span>
<span style="color: #000000;">56</span> listen_addresses = <span style="color: #ff0000;">'*'</span> <span style="color: #666666; font-style: italic;"># what IP address(es) to listen on;</span>
<span style="color: #000000;">57</span> <span style="color: #666666; font-style: italic;"># comma-separated list of addresses;</span>
<span style="color: #000000;">58</span> <span style="color: #666666; font-style: italic;"># defaults to 'localhost', '*' = all</span>
<span style="color: #000000;">59</span> <span style="color: #666666; font-style: italic;"># (change requires restart)</span></pre></div></div>

<p>4. For CentOS5.1, create symbolic links:<br />
  ln -s /usr/local/lib/libproj.so.0 /usr/lib/libproj.so.0<br />
  ln -s /usr/local/lib/libgeos_c.so.1 /usr/lib/libgeos_c.so.1<br />
  ldconfig<br />
  /etc/init.d/postgresql stop<br />
  /etc/init.d/postgresql start</p>
<p>3. Postgis Post Install</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">createdb <span style="color: #660033;">-E</span> utf8 template_routing
createlang plpgsql template_routing
psql <span style="color: #660033;">-d</span> template_routing <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgresql-<span style="color: #000000;">8.3</span>-postgis<span style="color: #000000; font-weight: bold;">/</span>lwpostgis.sql 
psql <span style="color: #660033;">-d</span> template_routing <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgresql-<span style="color: #000000;">8.3</span>-postgis<span style="color: #000000; font-weight: bold;">/</span>spatial_ref_sys.sql 
psql <span style="color: #660033;">-d</span> template_routing <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postlbs<span style="color: #000000; font-weight: bold;">/</span>routing_core.sql 
psql <span style="color: #660033;">-d</span> template_routing <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postlbs<span style="color: #000000; font-weight: bold;">/</span>routing_core_wrappers.sql</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/06/postgres-postgis-postinstall/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Postgresql, Postgis, pgRouting on Debian</title>
		<link>/wordpress/2008/05/installing-postgresql-postgis-pgrouting-on-debian/</link>
		<comments>/wordpress/2008/05/installing-postgresql-postgis-pgrouting-on-debian/#comments</comments>
		<pubDate>Sun, 25 May 2008 03:55:57 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[routing]]></category>
		<category><![CDATA[pgRouting]]></category>

		<guid isPermaLink="false">/wordpress/index.php/2008/05/25/installing-postgresql-postgis-pgrouting-on-debian/</guid>
		<description><![CDATA[Operating System: Debian sid Versions: postgres 8.3.1 postgis 1.3.3 pgRouting1.02 1. Install base system and ssh #vi /etc/apt/sources.list to include deb http://debian.cn99.com/debian etch main deb-src http://debian.cn99.com/debian etch main #apt-get update #apt-get upgrade libc6 2. Install the required packages for postgres8.3 and postgis1.3.3 #apt-get install sudo nmap telnet #apt-get install python2.5 python2.5-dev python-setuptools #apt-get install g++]]></description>
			<content:encoded><![CDATA[<p>Operating System: Debian sid</p>
<p>Versions:</p>
<ul>
<li>postgres 8.3.1</li>
<li>postgis 1.3.3</li>
<li>pgRouting1.02</li>
</ul>
<p>1. Install base system and ssh</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#vi /etc/apt/sources.list to include</span>
deb http:<span style="color: #000000; font-weight: bold;">//</span>debian.cn99.com<span style="color: #000000; font-weight: bold;">/</span>debian etch main
deb-src http:<span style="color: #000000; font-weight: bold;">//</span>debian.cn99.com<span style="color: #000000; font-weight: bold;">/</span>debian etch main
<span style="color: #666666; font-style: italic;">#apt-get update</span>
<span style="color: #666666; font-style: italic;">#apt-get upgrade libc6</span></pre></div></div>

<p>2. Install the required packages for postgres8.3 and postgis1.3.3</p>
<pre lang="bash" xml:lang="bash">
#apt-get install sudo nmap telnet
#apt-get install python2.5 python2.5-dev python-setuptools
#apt-get install g++
#apt-get install build-essential cmake ibboost-graph-dev
#apt-get install libreadline5 libreadline5-dev
#apt-get install zlib-bin zlib1g-dev
#apt-get install libkrb5-dev
#apt-get install libcurl3
#apt-get install libssl-dev
#apt-get install postgresql-8.3
#apt-get install postgresql-8.3-postgis
#apt-get install postgresql-server-dev-8.3
</pre>
<p>3. Installing pgRouting</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># tar -zxvf pgRouting-1.02.tgz</span>
<span style="color: #666666; font-style: italic;"># cmake .</span>
<span style="color: #666666; font-style: italic;"># make </span>
<span style="color: #666666; font-style: italic;"># make install</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/05/installing-postgresql-postgis-pgrouting-on-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Migrating data from Postgres8.2 to Postgres8.3</title>
		<link>/wordpress/2008/05/migrating-data-from-postgres82-to-postgres83/</link>
		<comments>/wordpress/2008/05/migrating-data-from-postgres82-to-postgres83/#comments</comments>
		<pubDate>Wed, 07 May 2008 00:56:28 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=182</guid>
		<description><![CDATA[One of my hurdles recently is migrating data from my Debian Lenny Desktop Box (Postgres8.2.7/Postgis1.3.1) to my new MacBookPro Leopard(Postgres8.3.1/Postgis1.3.3). I found it out the hard way by inspecting the dump files manually. Here are the results: 1. I strongly suggest if you have a big dump file (mine is 500MB) to split the schema]]></description>
			<content:encoded><![CDATA[<p>One of my hurdles recently is migrating data from my Debian Lenny Desktop Box (Postgres8.2.7/Postgis1.3.1) to my new MacBookPro Leopard(Postgres8.3.1/Postgis1.3.3). I found it out the hard way by inspecting the dump files manually. Here are the results:</p>
<p>1. I strongly suggest if you have a big dump file (mine is 500MB) to split the schema from the data.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pg_dump <span style="color: #660033;">-C</span> <span style="color: #660033;">-s</span> <span style="color: #660033;">-h</span> 127.0.0.1 <span style="color: #660033;">-U</span> lbs <span style="color: #660033;">-W</span> beijing <span style="color: #000000; font-weight: bold;">&gt;</span> beijing_20080507_schema.sql
pg_dump <span style="color: #660033;">-a</span> <span style="color: #660033;">-d</span> <span style="color: #660033;">-h</span> 127.0.0.1 <span style="color: #660033;">-U</span> lbs <span style="color: #660033;">-W</span> beijing <span style="color: #000000; font-weight: bold;">&gt;</span> beijing_20080507_schema.sql</pre></div></div>

<p>2. pg_dump from an 8.2 would have statically linked liblwgeom to /usr/lib/postgresql/8.2/liblwgeom. You should change that to whereever your liblwgeom resides, mine is on /usr/local/pgsql/lib/liblwgeom. Just do a simple search and replace using vim on your file_schema.sql</p>
<p>3. After editing the schema, we can now restore the structure of the database. Check for errors and manually update the schema if needs be.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">psql <span style="color: #660033;">-h</span> 127.0.0.1 <span style="color: #660033;">-U</span> beijing_4326 <span style="color: #000000; font-weight: bold;">&lt;</span> beijing_20080507_schema.sql</pre></div></div>

<p>4. Ok, so now we have the structure ready, we can also check this from pgAdmin3. Have a good look on the functions and table structures if they are fully restored. </p>
<p>5. Let&#8217;s load the data.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">psql <span style="color: #660033;">-h</span> 127.0.0.1 <span style="color: #660033;">-U</span> beijing_4326 <span style="color: #000000; font-weight: bold;">&lt;</span> beijing_20080507_data.sql</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/05/migrating-data-from-postgres82-to-postgres83/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing PostGres8.3 and Postgis1.3.2 on Windows</title>
		<link>/wordpress/2008/03/installing-postgres83-and-postgis-on-windows/</link>
		<comments>/wordpress/2008/03/installing-postgres83-and-postgis-on-windows/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 00:15:05 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/index.php/2008/03/04/installing-postgres83-and-postgis-on-windows/</guid>
		<description><![CDATA[It seems very nice for the new PostGres8.3 installer to bundle up third party libraries installation with the new admin pack feature. Using this feature, you can install PostGis, nPgsql, etc. The installation was painless and smooth this time. I have to backup all my data though using pg_dump. To lessen the learning curve on]]></description>
			<content:encoded><![CDATA[<p>It seems very nice for the new PostGres8.3 installer to bundle up third party libraries installation with the new <em>admin pack</em> feature. Using this feature, you can install PostGis, nPgsql, etc. The installation was painless and smooth this time. I have to backup all my data though using pg_dump.</p>
<p>To lessen the learning curve on installing PostGres + PostGis together, I made a <a href="http://www.gisnotes.com/wordpress/training/postgres-tut1.html" title="postgres-tut1.html">short flash movie</a> here.  There is no audio in the tutorial. The idea was to introduce PostGres to my Chinese staff.  I have to remove PostGreSQL 8.2 first before installing 8.3.</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2008/03/installing-postgres83-and-postgis-on-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing R on Windows and Debian</title>
		<link>/wordpress/2007/11/installing-r-on-windows-and-debian/</link>
		<comments>/wordpress/2007/11/installing-r-on-windows-and-debian/#comments</comments>
		<pubDate>Fri, 16 Nov 2007 01:15:59 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=121</guid>
		<description><![CDATA[&#8216;R&#8217; is a statistical package. For an overview, please go to www.r-project.org My intention was to remove the point outliers from a given set of point geometries. I just recently installed R both on my Windows XP and Debian. Regina&#8217;s www.bostongis.com is an excellent tutorial in getting involved with R. I do suggest you head]]></description>
			<content:encoded><![CDATA[<p><strong>&#8216;R&#8217;</strong> is a statistical package. For an overview, please go to <a href="www.r-project.org">www.r-project.org</a><br />
My intention was to remove the point outliers from a given set of point geometries.</p>
<p>I just recently installed R both on my Windows XP and Debian.  Regina&#8217;s <a href="www.bostongis.com">www.bostongis.com </a> is an excellent tutorial in getting involved with <strong>R</strong>. I do suggest you head first to  <a href="http://www.bostongis.com/PrinterFriendly.aspx?content_name=postgresql_plr_tut01">PLR Part 1: Up and Running with PL/R (PLR) in PostgreSQL: An almost Idiot&#8217;s Guide </a> to get you started.</p>
<p>The install instructions for Windows works flawlessly. I have to hold back to R-2.5 though as I plan to use RPy (Python for R), see details below. To install <strong>&#8216;R&#8217;</strong> in Debian, there&#8217;s a couple of settings that we need to take care of&#8230;</p>
<p>1. Install r-base<br />
<code>sudo apt-get install r-base</code></p>
<p>2. Install plr on postgres<br />
<code>sudo apt-get install postgresql-8.2-plr</code></p>
<p>3. Using R in a database<br />
<code>psql -d beijing -U lbs -h 127.0.0.1 &lt; /usr/share/postgresql/8.2/plr.sql</code></p>
<p>4. Set the R_HOME environment variable<br />
<code>/etc/postgresql/8.2/main/environment</code><br />
<code>R_HOME='/usr/lib/R'</code></p>
<p>5. Restart Debian.</p>
<p><strong>RPy</strong>, R for Python, is another alternative to use R in Python. I installed it both in Windows and Debian. Note that I reverted to R-2.5 on Windows to be compatible with RPy. For Debian, Im currently using R-2.6.</p>
<p>For the Windows Binary Installation,</p>
<p>1. Read the <a href="http://rpy.sourceforge.net/rpy/README">RPy Main Site</a></p>
<p>2. Install prerequisites:</p>
<p>- <a href="http://jaist.dl.sourceforge.net/sourceforge/numpy/numpy-1.0.4.win32-py2.5.msi">NumPy</a><br />
- <a href="http://sourceforge.net/project/showfiles.php?group_id=78018">Win32 Extensions Download</a></p>
<p>3. Afterwards, install the main package, <a href="http://nchc.dl.sourceforge.net/sourceforge/rpy/rpy-1.0-RC3.win32-R2.0.0-R-2.5.1-py2.5.exe">RPy Download</a></p>
<p>In Debian, its a straight forward&#8230;<code>sudo apt-get install python-rpy</code></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/11/installing-r-on-windows-and-debian/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Switching Back and Forth in MySQL and PostGres</title>
		<link>/wordpress/2007/11/switching-back-and-forth-in-mysql-and-postgres/</link>
		<comments>/wordpress/2007/11/switching-back-and-forth-in-mysql-and-postgres/#comments</comments>
		<pubDate>Fri, 02 Nov 2007 09:12:53 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=113</guid>
		<description><![CDATA[There is no way I could accomplish better data manipulation between MySQL and PostGres without Navicat. Just to be clear, I do not work for Navicat. These tools were able to help me export data out of MySQL and import it to PostGres. It is just one of those products that really deserve credit. Take]]></description>
			<content:encoded><![CDATA[<p>There is no way I could accomplish better data manipulation between MySQL and PostGres without Navicat. Just to be clear, I do not work for Navicat.  These tools were able to help me export data out of MySQL and import it to PostGres. It is just one of those products that really deserve credit.</p>
<p><a href='/wordpress/wp-content/uploads/2007/11/navicat.jpg' title='Navicat'><img src='/wordpress/wp-content/uploads/2007/11/navicat.jpg' alt='Navicat' /></a></p>
<p>Take note though that you can not see the <em>&#8220;messages&#8221;</em> displayed by the <em>&#8220;raise command&#8221;</em> in PL/PGSQL when using Navicat 8 for PostGres. I have to switch back to using pgAdmin III or my standard command line.</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/11/switching-back-and-forth-in-mysql-and-postgres/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exporting from Postgres to Mapinfo</title>
		<link>/wordpress/2007/08/exporting-from-postgres-to-mapinfo/</link>
		<comments>/wordpress/2007/08/exporting-from-postgres-to-mapinfo/#comments</comments>
		<pubDate>Mon, 27 Aug 2007 12:00:36 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[mapinfo]]></category>
		<category><![CDATA[ogr2ogr]]></category>

		<guid isPermaLink="false">/wordpress/?p=108</guid>
		<description><![CDATA[I had a problem when using ogr2ogr and converting a postgres table to a road table. My postgres table containa a utf-8 road name which is all in chinese. The mapinfo road table created by ogr2ogr seems to contain the correct geometry and other fields that is in utf-8. However, all my chinese characters is]]></description>
			<content:encoded><![CDATA[<p>I had a problem when using ogr2ogr and converting a postgres table to a road table. My postgres table containa a utf-8 road name which is all in chinese. The mapinfo road table created by ogr2ogr seems to contain the correct geometry and other fields that is in utf-8. However, all my chinese characters is all messed up. So, I have to export the file and open it to mapinfo.</p>
<p>1. In Postgres, to export to a file..<br />
<code><br />
cybersoftbjv1=# set client_encoding = gbk;<br />
SET<br />
cybersoftbjv1=# \o road.txt;<br />
cybersoftbjv1=# select rd_id, cn_name from roads where cn_name &lt;&gt; '';<br />
cybersoftbjv1=# \q<br />
</code></p>
<p>2. Open the file in vim, and do a &#8220;%s/ //g&#8221;. This would replace all &#8221; &#8221; to &#8220;&#8221;.<br />
Note: This is reasonable for chinese since chinese dont have spaces. However english prases and sentences differ.</p>
<p>3. Open the file in mapinfo and replace the other columns using Table -&gt; Update.</p>
<p>If anybody has any other way to specify the client encoding in ogr2ogr that would be perfect&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/08/exporting-from-postgres-to-mapinfo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Road Topology</title>
		<link>/wordpress/2007/08/creating-road-topology/</link>
		<comments>/wordpress/2007/08/creating-road-topology/#comments</comments>
		<pubDate>Wed, 22 Aug 2007 12:40:35 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[routing]]></category>

		<guid isPermaLink="false">/wordpress/?p=104</guid>
		<description><![CDATA[Im trying out ways to create a topology of edges and vertices for a road network. Currently, there are three ways I know of: 1. Using ArcGIS build coverage line. &#8211; This includes the use of ArcGIS. Exporting the feature into tics, arcs and nodes, then afterwards assembling them all together. Its functional but have]]></description>
			<content:encoded><![CDATA[<p>Im trying out ways to create a topology of edges and vertices for a road network. Currently, there are three ways I know of:<br />
<strong><br />
1. Using ArcGIS build coverage line.</strong><br />
&#8211; This includes the use of ArcGIS. Exporting the feature into tics, arcs and nodes, then afterwards assembling them all together. Its functional but have not fully tested the quality of the road topology. Also, assembling them back together through the spatial objects comparison will take some time. It would be better <strong>*If*</strong> ArcGIS could create the nodes wrt to the base table.</p>
<p><strong>2. Using PostGres, postlbs functions.</strong><br />
&#8211; Use of SELECT ASSIGN_VERTEX_ID(&#8216;table_name&#8217;, double_precision_distance. So far this bails on me on my first test on my win-xp laptop. We can test this on Linux if the response is the same.</p>
<p><strong>3. Using Mapinfo Basic Scripts provided by J.</strong><br />
&#8211; Haven&#8217;t gone indepth with these for now, but looking forward to it.</p>
<p><strong>4. Using Grass</strong><br />
&#8211; As documented in <a href="pgrouting.postlbs.org">pgrouting.postlbs.org</a> site&#8217;s <a href="http://pgrouting.postlbs.org/wiki/TopologyCreation">Topology Creation</a></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/08/creating-road-topology/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CF-Postgres ODBC Connection</title>
		<link>/wordpress/2007/07/cf-postgres-odbc-connection/</link>
		<comments>/wordpress/2007/07/cf-postgres-odbc-connection/#comments</comments>
		<pubDate>Thu, 12 Jul 2007 15:04:26 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=75</guid>
		<description><![CDATA[Note: You need the postgresql-8.2-504.jdbc3.jar. Technote From Adobe]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gisnotes.com/wordpress/wp-content/uploads/2007/07/cf_postgres.png" title="CF-Postgres ODBC"><img src="http://www.gisnotes.com/wordpress/wp-content/uploads/2007/07/cf_postgres.png" alt="CF-Postgres ODBC" /></a></p>
<p>Note: You need the postgresql-8.2-504.jdbc3.jar.</p>
<p><a href="http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_18338&amp;sliceId=1">Technote From Adobe</a></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/07/cf-postgres-odbc-connection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buffering points</title>
		<link>/wordpress/2007/07/buffering-points/</link>
		<comments>/wordpress/2007/07/buffering-points/#comments</comments>
		<pubDate>Sat, 07 Jul 2007 16:52:43 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=71</guid>
		<description><![CDATA[Here is a post in buffering points and combining them using GeomUnion. Works in GEOS3.0.0, so note that your POSTGIS installation in windows contains a lower version of GEOS. DROP FUNCTION combineGeometry&#40;&#41;; &#160; CREATE FUNCTION combineGeometry&#40;&#41; RETURNS Void AS' DECLARE --define datatypes here updateCount integer DEFAULT 0; geom_record RECORD; geom_current RECORD; geom_final RECORD; mytotal integer]]></description>
			<content:encoded><![CDATA[<p>Here is a post in buffering points and combining them using GeomUnion. Works in GEOS3.0.0, so note that your POSTGIS installation in windows contains a lower version of GEOS.</p>
<p><a href="http://www.gisnotes.com/wordpress/wp-content/uploads/2007/07/buffer_points.png" title="Buffered Points"><img src="http://www.gisnotes.com/wordpress/wp-content/uploads/2007/07/buffer_points.thumbnail.png" alt="Buffered Points" /></a></p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> combineGeometry<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> combineGeometry<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> RETURNS Void <span style="color: #993333; font-weight: bold;">AS</span><span style="color: #ff0000;">'
DECLARE
	--define datatypes here
	updateCount integer DEFAULT 0;
	geom_record RECORD;
	geom_current RECORD;
	geom_final RECORD;
	mytotal integer DEFAULT 0;
&nbsp;
BEGIN
&nbsp;
	--get the total
	SELECT count(*) as mycount FROM busstopv1_buffer_20_temp INTO mytotal;
&nbsp;
	-- 1,2,3,4,5
	FOR geom_record IN SELECT * FROM busstopv1_buffer_20 LOOP
&nbsp;
		--get the current geom of the record
		SELECT *
		FROM 		busstopv1_buffer_20_temp b
		WHERE 		b.gid = geom_record.gid INTO geom_current;
&nbsp;
		RAISE INFO '</span><span style="color: #ff0000;">'RECORD GID: %'</span><span style="color: #ff0000;">', geom_record.gid;
		RAISE INFO '</span><span style="color: #ff0000;">'===========TOTAL COUNT: %=============='</span><span style="color: #ff0000;">', mytotal;
&nbsp;
		--find the intersection of the current geom with other spatial entities
		--and loop through that. For each loop, update the geom.
&nbsp;
		IF geom_current IS NULL THEN
			CONTINUE;
		END IF;
		FOR geom_final IN
			SELECT GeomUnion(b0.the_geom, geom_current.the_geom ) AS geom_current_union, b0.gid
			FROM busstopv1_buffer_20_temp b0
			WHERE b0.gid &amp;lt;&amp;gt; geom_current.gid
			AND Intersects(b0.the_geom, geom_current.the_geom) = '</span><span style="color: #ff0000;">'t'</span><span style="color: #ff0000;">'
			ORDER BY gid ASC LOOP
&nbsp;
			--geom_current.gid = geom_record.gid
			UPDATE busstopv1_buffer_20_temp
			SET the_geom = GeomUnion( the_geom, geom_final.geom_current_union )
			WHERE gid = geom_current.gid;
			RAISE INFO '</span><span style="color: #ff0000;">'UPDATED GID:%'</span><span style="color: #ff0000;">', geom_current.gid;
&nbsp;
			DELETE FROM busstopv1_buffer_20_temp WHERE gid = geom_final.gid;
			RAISE INFO '</span><span style="color: #ff0000;">'DELETED GID:%'</span><span style="color: #ff0000;">', geom_final.gid;
&nbsp;
			mytotal = mytotal - 1;
&nbsp;
		END LOOP;
&nbsp;
	END LOOP;
END;'</span>
<span style="color: #993333; font-weight: bold;">LANGUAGE</span> plpgsql;
&nbsp;
<span style="color: #993333; font-weight: bold;">SELECT</span> combineGeometry<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Next step.. trying out <a href="http://www.cgal.org/">CGAL.</a></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/07/buffering-points/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PostgresSQL / PostGIS CheatSheat</title>
		<link>/wordpress/2007/07/postgressql-commands/</link>
		<comments>/wordpress/2007/07/postgressql-commands/#comments</comments>
		<pubDate>Sun, 01 Jul 2007 14:05:58 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">/wordpress/?p=66</guid>
		<description><![CDATA[This is a quick-command list of Postres. If you want detailed instructions, please visit the Postgres Manual. 1. How do I Show all databases? postgres=# \l List of databases Name &#124; Owner &#124; Encoding ------------------+----------+---------- postgis &#124; postgres &#124; UTF8 postgres &#124; postgres &#124; UTF8 template0 &#124; postgres &#124; UTF8 template1 &#124; postgres &#124; UTF8]]></description>
			<content:encoded><![CDATA[<p>This is a quick-command list of Postres. If you want detailed instructions, please visit the Postgres Manual.</p>
<p><strong>1. How do I Show all databases? </strong><br />
<code><br />
postgres=# \l<br />
List of databases<br />
Name       |  Owner   | Encoding<br />
------------------+----------+----------<br />
postgis          | postgres | UTF8<br />
postgres         | postgres | UTF8<br />
template0        | postgres | UTF8<br />
template1        | postgres | UTF8<br />
template_postgis | postgres | UTF8<br />
(5 rows)<br />
</code></p>
<p>Note: Do not drop template databases if not necessary.</p>
<p><strong>2. How do I run a script from the prompt?</strong><br />
<code>\i <sqlfile></sqlfile></code><br />
OR<br />
<code>psql -d cybersoftbj -u user &lt; myfile.sql</code></p>
<p>Its very usuful in reloading user-defined functions.</p>
<p><strong>3. How do I create a user?</strong><br />
<code><br />
CREATE ROLE lbs WITH LOGIN PASSWORD 'tracking' SUPERUSER INHERIT CREATEDB CREATEROLE;<br />
</code></p>
<p><strong>4. How to dump database in a text file?</strong><br />
<code><br />
pg_dump -U lbs -d cybersoftbjv1 -h 127.0.0.1 -W &gt; cybersoftbjv1.sql<br />
</code></p>
<p><strong>4. How to dump database cleanly?</strong><br />
<code><br />
pg_dump -c  -d -E UTF8 -h 127.0.0.1 -U lbs -W platform_v1 &gt; platform_v1.sql<br />
</code></p>
<p><strong>5. How to update using two tables?</strong><br />
<code><br />
UPDATE road_for_update u<br />
SET the_geom = r.the_geom<br />
FROM roads r<br />
WHERE r.rd_id = u.rd_id;<br />
</code></p>
<p><strong>6. How to change a column type with Cast?</strong><br />
<code><br />
ALTER TABLE roads ALTER COLUMN class_new TYPE integer USING class_new::integer;<br />
</code></p>
<p><strong>7. How to provide/restrict access privileges to tables?</strong><br />
<code><br />
GRANT SELECT ON TABLE table TO user;<br />
REVOKE SELECT ON TABLE table FROM user;<br />
</code></p>
<p><strong>8. How to add a geometry column to a table?</strong><br />
<code><br />
SYNTAX: AddGeometryColumn(</code></p>
<table_name>,<br />
<column_name>, <srid>, <type>, <dimension>)<br />
EXAMPLE: SELECT AddGeometryColumn(&#8216;public&#8217;, &#8216;poi&#8217;, &#8216;the_geom&#8217;, 4326, &#8216;POINT&#8217;, 2)<br />
</dimension></type></srid></column_name></table_name><strong>9. Changing column names with spaces?</strong><br />
<code>ALTER TABLE class_aroundme RENAME "level 1" TO level_1;</code> <strong>10. Setting kernel shmmax for postgres</strong><br />
<code>sysctl -w kernel.shmmax=134217728</code><br />
Note: For permanent changes see /etc/sysctl.cfg<strong>11. How to backup table(s) from pg_dump?</strong><br />
pg_dump poi_beijing -t class -t poi_class -f $BACKUPDIR/test_$MYDATE.sql</p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/07/postgressql-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preparing routing data for pgRouting</title>
		<link>/wordpress/2007/04/preparing-routing-data-for-pgrouting/</link>
		<comments>/wordpress/2007/04/preparing-routing-data-for-pgrouting/#comments</comments>
		<pubDate>Tue, 10 Apr 2007 09:23:35 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[mapinfo]]></category>
		<category><![CDATA[pgRouting]]></category>
		<category><![CDATA[routing]]></category>

		<guid isPermaLink="false">/wordpress/?p=49</guid>
		<description><![CDATA[1. It is important that you already have postgres, postgis, pgRouting installed in your machine. A. The schema. Below is the sample schema that is a derivative of the kanagawa sample data from pgRouting. Take note of the source and target nodes, as well as the length and the node coordinates (x1,y1; x2,y2) of the]]></description>
			<content:encoded><![CDATA[<p>1. It is important that you already have <a href="/wordpress/?p=45">postgres, postgis, pgRouting installed in your machine.</a></p>
<p>A. The schema. Below is the sample schema that is a derivative of the <a href="http://www.postlbs.org/postlbs-cms/files/downloads/pgRouting-sampleapp.tar.bz">kanagawa sample data from pgRouting</a>. Take note of the <em>source and target nodes</em>, as well as the length and the node coordinates (x1,y1; x2,y2) of the line.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">cybersoftbj<span style="color: #66cc66;">=</span><span style="color: #808080; font-style: italic;"># \dt</span>
List of relations
 Schema <span style="color: #66cc66;">|</span>       Name       <span style="color: #66cc66;">|</span> Type  <span style="color: #66cc66;">|</span>  Owner
<span style="color: #808080; font-style: italic;">--------+------------------+-------+----------</span>
 public <span style="color: #66cc66;">|</span> geometry_columns <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #66cc66;">|</span> postgres
 public <span style="color: #66cc66;">|</span> roads            <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #66cc66;">|</span> postgres
 public <span style="color: #66cc66;">|</span> spatial_ref_sys  <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #66cc66;">|</span> postgres
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span> rows<span style="color: #66cc66;">&#41;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">cybersoftbj<span style="color: #66cc66;">=</span><span style="color: #808080; font-style: italic;"># \d roads</span>
<span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">&quot;public.roads&quot;</span>
<span style="color: #993333; font-weight: bold;">COLUMN</span>   <span style="color: #66cc66;">|</span>          Type          <span style="color: #66cc66;">|</span>                      Modifiers
<span style="color: #808080; font-style: italic;">------------+------------------------+-----------------------------------------------------</span>
gid        <span style="color: #66cc66;">|</span> integer                <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NEXTVAL</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'roads_gid_seq'</span>::regclass<span style="color: #66cc66;">&#41;</span>
rd_id      <span style="color: #66cc66;">|</span> bigint
yutu_id    <span style="color: #66cc66;">|</span> integer
block_id   <span style="color: #66cc66;">|</span> bigint
heirarchy  <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>
cn_name    <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">75</span><span style="color: #66cc66;">&#41;</span>
py_name    <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>
source     <span style="color: #66cc66;">|</span> bigint
target     <span style="color: #66cc66;">|</span> bigint
x1         <span style="color: #66cc66;">|</span> numeric
y1         <span style="color: #66cc66;">|</span> numeric
x2         <span style="color: #66cc66;">|</span> numeric
y2         <span style="color: #66cc66;">|</span> numeric
costlength <span style="color: #66cc66;">|</span> numeric
the_geom   <span style="color: #66cc66;">|</span> geometry</pre></div></div>

<p>A. Extracting the coordinates of the line segments from Mapinfo.</p>
<p>1. I have to format the data structure as follows&#8230;</p>
<p>&#8230;here is the roads table after weeding out some unnecessary columns&#8230;<br />
<img src="/wordpress/images/routing_mapinfo_1.png" /></p>
<p>&#8230; adding the source,target,x1,y1,x2,y2,costlength&#8230;<br />
<img src="/wordpress/images/routing_mapinfo_2.png" /></p>
<p>2. Using ObjectGeography. <a href="http://reference.mapinfo.com/software/mapbasic/english/8.5/MB_Ref.pdf">Download the MapBasic Reference</a></p>
<p>ObjectGeography( object, attribute )</p>
<p>ObjectGeography( object, &#8220;1&#8243; ) &lt;&#8211; gives you the beginning x coord of the point</p>
<p><img src="/wordpress/images/routing_mapinfo_3.png" /></p>
<p>3. Export the tab file to a shape file for ArchMap.</p>
<p><img src="/wordpress/images/routing_mapinfo_4.png" /></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/04/preparing-routing-data-for-pgrouting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loading Mapinfo table to PostGis</title>
		<link>/wordpress/2007/04/loading-mapinfo-table-to-postgis/</link>
		<comments>/wordpress/2007/04/loading-mapinfo-table-to-postgis/#comments</comments>
		<pubDate>Wed, 04 Apr 2007 21:25:06 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[GDAL/OGR]]></category>
		<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[mapinfo]]></category>
		<category><![CDATA[ogr2ogr]]></category>

		<guid isPermaLink="false">/wordpress/?p=47</guid>
		<description><![CDATA[AFAIK, there are only two ways to load data to PostGIS: 1. Using Insert statements 2. Using Utilities. Utilities include shp2pgsql which is found in &#8220;C:\Program Files\PostgreSQL\8.2\bin\&#8221; or &#8220;/usr/local/pgsql/bin&#8221;. To load Mapinfo table, I have used the OGR utilities from FWTools for Windows. and used gdal1.3.2 (since it contains ogr) for Unix. OGR2OGR CheatSheet should]]></description>
			<content:encoded><![CDATA[<p>AFAIK, there are only two ways to load data to PostGIS:<br />
1. Using Insert statements<br />
2. Using Utilities.</p>
<p>Utilities include shp2pgsql which is found in &#8220;C:\Program Files\PostgreSQL\8.2\bin\&#8221; or &#8220;/usr/local/pgsql/bin&#8221;. To load Mapinfo table, I have used the OGR utilities from <a href="http://fwtools.maptools.org/">FWTools for Windows.</a> and used <a href="www.gdal.org">gdal1.3.2</a> (since it contains ogr) for Unix.</p>
<p><a href="http://www.bostongis.com/?content_name=ogr_cheatsheet">OGR2OGR CheatSheet</a> should be a good kickstart for basic understanding. For the impatient..</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ogr2ogr <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;PostGreSQL&quot;</span> <span style="color: #660033;">-nlt</span> LINESTRING -a_srs <span style="color: #ff0000;">&quot;EPSG:4326&quot;</span> PG:<span style="color: #ff0000;">&quot;host=localhost user=username password=mypassword dbname=mydb mytab.TAB -select columnName</span></pre></div></div>

<p>or</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ogr2ogr <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;PostgreSQL&quot;</span> PG:<span style="color: #ff0000;">&quot;host=myhost user=myloginname dbname=mydbname password=mypassword&quot;</span> mytabfile.tab <span style="color: #660033;">-nln</span> newtablename <span style="color: #660033;">-select</span> columnName</pre></div></div>

<p>Bear in mind that you should select out the columns from your mapfile (mine is chinese) especially if you have a diffent encoding in your column which matches your database (postgres). You might get a &#8220;Terminating translation prematurely after failed translation of layer [layername]&#8221; error.  Since Mapinfo stores the text to ASCII, my workaround is to export the tabfile to a UTF-8 textfile then upload it to PostGres. Hoping the primary ids would match to make the necessary updates&#8230;</p>
<p>An alternative to load Chinese text from Mapinfo to PostGIS is the ff:<br />
1. In Mapinfo use the Universal Translator to export the table into a shape file.<br />
2. Once you have the shape file, you can directly use the <strong>shp2pgsql</strong><em>.</em></p>
<p><em>shp2pgsql -W &#8220;gbk&#8221; -s 4326 lbjrdnt_small_polyline roads &gt; roads.sql</em></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/04/loading-mapinfo-table-to-postgis/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating a Spatial Table in PostGIS</title>
		<link>/wordpress/2007/04/creating-a-spatial-table/</link>
		<comments>/wordpress/2007/04/creating-a-spatial-table/#comments</comments>
		<pubDate>Wed, 04 Apr 2007 20:06:43 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[centos]]></category>

		<guid isPermaLink="false">/wordpress/?p=46</guid>
		<description><![CDATA[Creating the spatial table from scratch&#8230; &#91;postgres@rupert-linux ~&#93;$ su - postgres &#91;postgres@rupert-linux ~&#93;$ createdb _E UTF-8 template_postgis CREATE DATABASE &#91;postgres@rupert-linux ~&#93;$ createlang plpgsql template_postgis &#91;postgres@rupert-linux ~&#93;$ psql -f /usr/local/pgsql/share/lwpostgis.sql -d template_postgis CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION COMMIT postgres@rupert-linux ~&#93;$ psql -f /usr/local/pgsql/share/spatial_ref_sys.sql -d template_postgis &#91;postgres@rupert-linux ~&#93;$ psql Alternatively you could]]></description>
			<content:encoded><![CDATA[<p>Creating the spatial table from scratch&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>postgres<span style="color: #000000; font-weight: bold;">@</span>rupert-linux ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #c20cb9; font-weight: bold;">su</span> - postgres
<span style="color: #7a0874; font-weight: bold;">&#91;</span>postgres<span style="color: #000000; font-weight: bold;">@</span>rupert-linux ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ createdb _E UTF-<span style="color: #000000;">8</span> template_postgis
CREATE DATABASE
<span style="color: #7a0874; font-weight: bold;">&#91;</span>postgres<span style="color: #000000; font-weight: bold;">@</span>rupert-linux ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ createlang plpgsql template_postgis
<span style="color: #7a0874; font-weight: bold;">&#91;</span>postgres<span style="color: #000000; font-weight: bold;">@</span>rupert-linux ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ psql <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>lwpostgis.sql <span style="color: #660033;">-d</span> template_postgis
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
COMMIT
postgres<span style="color: #000000; font-weight: bold;">@</span>rupert-linux ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ psql <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>spatial_ref_sys.sql <span style="color: #660033;">-d</span> template_postgis
<span style="color: #7a0874; font-weight: bold;">&#91;</span>postgres<span style="color: #000000; font-weight: bold;">@</span>rupert-linux ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ psql</pre></div></div>

<p>Alternatively you could also create your spatial table from a template&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">     <span style="color: #000000;">14</span> <span style="color: #007800;">postgres</span>=<span style="color: #666666; font-style: italic;"># CREATE DATABASE gistest TEMPLATE=template_postgis;</span>
     <span style="color: #000000;">15</span> CREATE DATABASE</pre></div></div>

<p>I have also added the routing functions using routing.sql and routing_postgis.sql</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>postgres<span style="color: #000000; font-weight: bold;">@</span>rupert-linux ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ psql <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>routing.sql <span style="color: #660033;">-d</span> template_postgis
<span style="color: #7a0874; font-weight: bold;">&#91;</span>postgres<span style="color: #000000; font-weight: bold;">@</span>rupert-linux ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ psql <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>routing_postgis.sql <span style="color: #660033;">-d</span> template_postgis</pre></div></div>

<p>FYI&#8230;</p>
<p>The <strong>spatial_ref_sys</strong> table contains the ESPG codes and projections. Currently it has 3162 records.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">gistest<span style="color: #66cc66;">=</span><span style="color: #808080; font-style: italic;"># \d spatial_ref_sys;</span>
 srid      <span style="color: #66cc66;">|</span> integer                 <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
 auth_name <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span>  <span style="color: #66cc66;">|</span>
 auth_srid <span style="color: #66cc66;">|</span> integer                 <span style="color: #66cc66;">|</span>
 srtext    <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2048</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span>
 proj4text <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2048</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span></pre></div></div>

<p>The <strong>geometry_columns</strong> contains the geometry type of the table you just created..</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">gistest<span style="color: #66cc66;">=</span><span style="color: #808080; font-style: italic;"># \d geometry_columns;</span>
 f_table_catalog   <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
 f_table_schema    <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
 f_table_name      <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
 f_geometry_column <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
 coord_dimension   <span style="color: #66cc66;">|</span> integer                <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
 srid              <span style="color: #66cc66;">|</span> integer                <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>
 type              <span style="color: #66cc66;">|</span> character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">30</span><span style="color: #66cc66;">&#41;</span>  <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/04/creating-a-spatial-table/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Installing PostGres, PostGIS, pgRouting in Linux</title>
		<link>/wordpress/2007/04/installing-postgres-and-postgis-in-linux/</link>
		<comments>/wordpress/2007/04/installing-postgres-and-postgis-in-linux/#comments</comments>
		<pubDate>Tue, 03 Apr 2007 15:05:09 +0000</pubDate>
		<dc:creator>rupert</dc:creator>
				<category><![CDATA[postgis]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[prRouting]]></category>
		<category><![CDATA[routing]]></category>

		<guid isPermaLink="false">/wordpress/?p=45</guid>
		<description><![CDATA[A. Installing PostGres A.1. Download and install the source: postgresql-8.2.3.tar.gz &#91;root@rupert-linux routing&#93;tar -xvzf postgresql-8.1.2.tar.gz &#91;root@rupert-linux routing&#93;LDFLAGS=-lstdc++ &#91;root@rupert-linux routing&#93;./configure --prefix=/usr/local/pgsql --with-perl --with-python --with-krb5 --with-openssl &#91;root@rupert-linux routing&#93;make &#91;root@rupert-linux routing&#93;make install &#160; A.2. Post Compile Operations: &#160; &#91;root@rupert-linux routing&#93;/usr/sbin/adduser postgres &#160; &#91;root@rupert-linux routing&#93;mkdir /usr/local/pgsql/data &#160; &#91;root@rupert-linux routing&#93;chown postgres /usr/local/pgsql/data/ &#160; &#91;root@rupert-linux routing&#93;su - postgres &#160; &#91;root@rupert-linux routing&#93;/usr/local/pgsql/bin/initdb -D]]></description>
			<content:encoded><![CDATA[<p><strong>A. Installing PostGres</strong></p>
<p>A.1. Download and install the source: <a href="http://wwwmaster.postgresql.org/download/mirrors-ftp?file=%2Fsource%2Fv8.2.3%2Fpostgresql-8.2.3.tar.gz">postgresql-8.2.3.tar.gz</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvzf</span> postgresql-8.1.2.tar.gz
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #007800;">LDFLAGS</span>=-lstdc++
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span>.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql <span style="color: #660033;">--with-perl</span> <span style="color: #660033;">--with-python</span> <span style="color: #660033;">--with-krb5</span> <span style="color: #660033;">--with-openssl</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
&nbsp;
A.2. Post Compile Operations:
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>adduser postgres
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>data
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #c20cb9; font-weight: bold;">chown</span> postgres <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #c20cb9; font-weight: bold;">su</span> - postgres
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>initdb <span style="color: #660033;">-D</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Note: If youre default locale is not EN, say chinese, then you would get:</p>
<blockquote><p> The files belonging to this database system will be owned by user &#8220;postgres&#8221;.<br />
This user must also own the server process.</p>
<p>The database cluster will be initialized with locale zh_CN.GB18030.<br />
initdb: could not find suitable encoding for locale &#8220;zh_CN.GB18030&#8243;</p></blockquote>
<p>A.3. Edit environment variables. Add the ff to your .bash_profile</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>.bash_profile
<span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$JAVA_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PGLIB</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>lib
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PGDATA</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>data
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PGPORT</span>=<span style="color: #000000;">5432</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PGOPTS</span>=<span style="color: #ff0000;">&quot;-i&quot;</span></pre></div></div>

<p>A.4. Start PostGres Automatically on Startup. <a href="/wordpress/wp-content/uploads/2007/06/postgresql.txt">Postgres Startup Script</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>postgresql
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>postgresql</pre></div></div>

<p>PostGres Startup Script</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;"># postgresql    This is the init script for starting up the PostgreSQL</span>
<span style="color: #666666; font-style: italic;">#               server</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># chkconfig: - 85 15</span>
<span style="color: #666666; font-style: italic;"># description: Starts and stops the PostgreSQL backend daemon that handles all database requests.</span>
<span style="color: #666666; font-style: italic;"># processname: postmaster</span>
<span style="color: #666666; font-style: italic;"># pidfile: /usr/local/pgsql/data/postmaster.pid</span>
<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Source function library.</span>
. <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.d<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>functions
&nbsp;
<span style="color: #666666; font-style: italic;"># Get config.</span>
. <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>sysconfig<span style="color: #000000; font-weight: bold;">/</span>network
&nbsp;
<span style="color: #666666; font-style: italic;"># Check that networking is up.</span>
<span style="color: #666666; font-style: italic;"># Pretty much need it for postmaster.</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${NETWORKING}</span> = <span style="color: #ff0000;">&quot;no&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>postmaster <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># See how we were called.</span>
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">pid</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">pidof</span> postmaster<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$pid</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Postmaster already running.&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Starting postgresql service: &quot;</span>
<span style="color: #c20cb9; font-weight: bold;">su</span> <span style="color: #660033;">-l</span> postgres <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'/usr/local/pgsql/bin/pg_ctl -o -i -D /usr/local/pgsql/data/ -l /usr/local/pgsql/data/logfile start'</span>
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">echo</span>
<span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Stopping postgresql service: &quot;</span>
killproc postmaster
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">2</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>data<span style="color: #000000; font-weight: bold;">/</span>postmaster.pid
<span style="color: #7a0874; font-weight: bold;">echo</span>
<span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
$<span style="color: #000000;">0</span> stop
$<span style="color: #000000;">0</span> start
<span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: postgresql {start|stop|restart}&quot;</span>
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p>A.5. PostGres Testing</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># su - postgres</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>postgres<span style="color: #000000; font-weight: bold;">@</span>rupert-linux ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>createdb <span style="color: #7a0874; font-weight: bold;">test</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>postgres<span style="color: #000000; font-weight: bold;">@</span>rupert-linux ~<span style="color: #7a0874; font-weight: bold;">&#93;</span>$ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>psql <span style="color: #7a0874; font-weight: bold;">test</span></pre></div></div>

<p><strong>B. Installing PostGIS.</strong></p>
<p>B.1. Download <a href="http://geos.refractions.net/">Geos</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># bzip2 -d geos-3.0.0rc4.tar.bz2</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># tar -xvf geos-3.0.0rc4.tar</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./configure</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># make</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># make install</span></pre></div></div>

<p>B.2. Download <a href="http://www.postgis.org/download/">PostGIS.</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># cp postgis-1.2.1.tar.gz /home/installers/postgresql-8.2.3/contrib/</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># tar -zxvf postgis-1.2.1.tar.gz</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># cd /home/installers/postgresql-8.2.3/contrib/postgis-1.2.1/</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./configure --with-pgsql=/usr/local/pgsql/bin/pg_config</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># make</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># make install</span></pre></div></div>

<p>B.3 Reload ldconfig</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># vi /etc/ld.so.conf</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>include
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ldconfig</span></pre></div></div>

<p>B.4. Testing PostGIS</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">su</span> - postgres
$ createlang plpgsql <span style="color: #7a0874; font-weight: bold;">test</span>
$ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>psql <span style="color: #660033;">-d</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>lwpostgis.sql
BEGIN
psql:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>postgresql<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>lwpostgis.sql:<span style="color: #000000;">39</span> NOTICE:  <span style="color: #7a0874; font-weight: bold;">type</span> <span style="color: #ff0000;">&quot;histogram2d&quot;</span> is not yet defined
DETAIL:  Creating a shell <span style="color: #7a0874; font-weight: bold;">type</span> definition.
.
.
.
COMMIT
$ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>psql <span style="color: #660033;">-d</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>pgsql<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>spatial_ref_sys.sql
BEGIN
INSERT <span style="color: #000000;">0</span> <span style="color: #000000;">1</span>
INSERT <span style="color: #000000;">0</span> <span style="color: #000000;">1</span>
.
.
.
VACUUM</pre></div></div>

<p><strong>C. Installing pgRouting.</strong></p>
<p>C.1 Install Boost Library if you don&#8217;t have it. Download <a href="http://sourceforge.net/project/showfiles.php?group_id=7586">boost</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># tar -jxvf boost_1_33_1.tar.bz2</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./configure</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># make</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># make install</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># cd /usr/local/include/boost1.3.3</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux <span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># cp -Rf boost /usr/local/include/</span></pre></div></div>

<p>C.2 Download and install <a href="http://www.cgal.org/download/">CGAL</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux installers<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># tar zxvf CGAL-3.2.1.tar.gz</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux installers<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># cd CGAL-3.2.1</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux CGAL-3.2.1<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./install_cgal --prefix=/usr/local/cgal --with-boost=n --without-autofind -ni /usr/bin/g++</span>
Copy libCGAL.so to the pgsql<span style="color: #000000; font-weight: bold;">/</span>lib directory...
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux CGAL-3.2.1<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;">#  cp -Rf /usr/local/cgal/lib/i686_Linux-2.6_g++-3.4.3/libCGAL.so /usr/local/pgsql/lib/</span></pre></div></div>

<p>C.3 Download and install <a href="http://sourceforge.net/projects/gaul/">GAUL</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux installers<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># tar zxvf gaul-devel-0.1849.tar.gz</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux gaul-devel-<span style="color: #000000;">0.1849</span>-<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./configure -prefix=/usr/local/gaul</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux gaul-devel-<span style="color: #000000;">0.1849</span>-<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># make</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux gaul-devel-<span style="color: #000000;">0.1849</span>-<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># make install</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux gaul-devel-<span style="color: #000000;">0.1849</span>-<span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># cd /usr/local/gaul (Note: Copy gaul includes and libraries to standard directories...)</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux gaul<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># cp -Rf include/* /usr/include/</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux gaul<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># cp -Rf lib/* /usr/local/lib/</span></pre></div></div>

<p>C.4 Download and install <a href="http://www.postlbs.org/postlbs-cms/files/downloads/pgRouting-0.9.9.tgz">pgRouting</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux installers<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># tar -jxvf pgRouting-0.9.9.tgz</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># vi configure</span>
<span style="color: #666666; font-style: italic;">##########################################</span>
Edit line 3036...
<span style="color: #007800;">CGAL_MKF</span>=<span style="color: #ff0000;">'find /usr/local/cgal/include/CGAL.....'</span>
<span style="color: #666666; font-style: italic;">##########################################</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># ./configure --with-cgal=/usr/local/cgal --with-gaul=/usr/local/gaul --with boost=/usr/local --pg-sql=/usr/local/pgsql</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># make</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>rupert-linux routing<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># make install</span></pre></div></div>

<p><ins datetime="2007-06-07T01:28:02+00:00"></ins></p>
]]></content:encoded>
			<wfw:commentRss>/wordpress/2007/04/installing-postgres-and-postgis-in-linux/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
