<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>GIS4Freedom Blog</title>
	<atom:link href="http://gis4free.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://gis4free.wordpress.com</link>
	<description>Add &#34;where&#34; to your life</description>
	<lastBuildDate>Sat, 11 May 2013 09:27:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='gis4free.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>GIS4Freedom Blog</title>
		<link>http://gis4free.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://gis4free.wordpress.com/osd.xml" title="GIS4Freedom Blog" />
	<atom:link rel='hub' href='http://gis4free.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Updating GDAL PostGIS Raster driver</title>
		<link>http://gis4free.wordpress.com/2012/08/25/updating-gdal-postgis-raster-driver/</link>
		<comments>http://gis4free.wordpress.com/2012/08/25/updating-gdal-postgis-raster-driver/#comments</comments>
		<pubDate>Sat, 25 Aug 2012 14:25:31 +0000</pubDate>
		<dc:creator>Jorge Arévalo</dc:creator>
				<category><![CDATA[GDAL]]></category>
		<category><![CDATA[PostGIS Raster]]></category>

		<guid isPermaLink="false">http://gis4free.wordpress.com/?p=511</guid>
		<description><![CDATA[NOTE: Please, update your feeds. This blog has been moved to http://www.libregis.org Those past days, I’ve been working on the GDAL PostGIS Raster driver. I commited a version with relevant changes some days ago. It works with irregular blocking (tiles of different size), different pixel sizes in tiles and is pretty much faster than the [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=511&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<h3><strong>NOTE: Please, update your feeds. This blog has been moved to <a href="http://www.libregis.org">http://www.libregis.org</a></strong></h3>
<p>Those past days, I’ve been working on the GDAL PostGIS Raster driver. I commited a version with relevant changes some days ago. It works with irregular blocking (tiles of different size), different pixel sizes in tiles and is pretty much faster than the previous version. Currently, I’m debugging to solve some errors, but I plan to have a stable version for next week. Of course, any feedback is welcome.</p>
<p>So, you can download the last GDAL <a title="nightly snapshot" href="http://trac.osgeo.org/gdal/wiki/DownloadSource#NightlySnapshots">nightly snapshot</a> or <a title="checkout the code from svn repository" href="http://trac.osgeo.org/gdal/wiki/DownloadSource#Subversion">checkout the code from svn repository</a>. Also, I keep a <a title="github repository" href="https://github.com/jorgeas80/gdal_postgis_raster_driver">github repository</a> just for the driver’s code. Feel free to clone it, comment, collaborate or just say “Hi”</p>
<p>Apart from that, as this blog is now part of the <a title="OSGeo planet" href="http://planet.osgeo.org/">OSGeo Planet</a>, I’m going to update it way more frequently. For the time being, I can commit with one post per month. Probably more.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gis4free.wordpress.com/511/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gis4free.wordpress.com/511/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=511&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gis4free.wordpress.com/2012/08/25/updating-gdal-postgis-raster-driver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>40.599072 -3.712258</georss:point>
		<geo:lat>40.599072</geo:lat>
		<geo:long>-3.712258</geo:long>
		<media:content url="http://0.gravatar.com/avatar/30cf35ac4c992fff8298cdbd2f887025?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gis4free</media:title>
		</media:content>
	</item>
		<item>
		<title>I&#8217;m moving to www.libregis.org</title>
		<link>http://gis4free.wordpress.com/2011/11/26/im-moving-to-www-libregis-org/</link>
		<comments>http://gis4free.wordpress.com/2011/11/26/im-moving-to-www-libregis-org/#comments</comments>
		<pubDate>Sat, 26 Nov 2011 10:12:47 +0000</pubDate>
		<dc:creator>Jorge Arévalo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gis4free.wordpress.com/?p=507</guid>
		<description><![CDATA[I&#8217;ve migrated all the blog content to a new domain: http://www.libregis.org So, you can update your markers if needed. I will keep this blog alive for some time.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=507&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve migrated all the blog content to a new domain:</p>
<h3><strong><a href="http://www.libregis.org">http://www.libregis.org</a></strong></h3>
<p>So, you can update your markers if needed. I will keep this blog alive for some time.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gis4free.wordpress.com/507/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gis4free.wordpress.com/507/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=507&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gis4free.wordpress.com/2011/11/26/im-moving-to-www-libregis-org/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/30cf35ac4c992fff8298cdbd2f887025?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gis4free</media:title>
		</media:content>
	</item>
		<item>
		<title>Web-based PostGIS geometry/raster viewers</title>
		<link>http://gis4free.wordpress.com/2011/08/27/web-based-postgis-geometryraster-viewers/</link>
		<comments>http://gis4free.wordpress.com/2011/08/27/web-based-postgis-geometryraster-viewers/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 10:21:43 +0000</pubDate>
		<dc:creator>Jorge Arévalo</dc:creator>
				<category><![CDATA[GIS Software]]></category>
		<category><![CDATA[PostGIS Raster]]></category>

		<guid isPermaLink="false">http://gis4free.wordpress.com/?p=491</guid>
		<description><![CDATA[If you want to test PostGIS Raster (included in the next PostGIS 2.0) without installing any software in your computer, take a look at these web-based PostGIS geometry/raster viewers: Web-viewer (ASP.NET) Web viewer (PHP) Thanks to Regina Obe for this, and all the PostGIS team for the excellent work. I&#8217;m working in the GDAL PostGIS [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=491&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>If you want to test PostGIS Raster (included in the next PostGIS 2.0) without installing any software in your computer, take a look at these web-based PostGIS geometry/raster viewers:</p>
<ul>
<li><a title="Web-viewer (ASP.NET)" href="http://www.bostongis.com/blog/index.php?/archives/174-Minimalist-Web-based-ASP.NET-PostGIS-2.0-Spatial-GeometryRaster-Viewer.html">Web-viewer (ASP.NET)</a></li>
<li><a title="Web viewer (PHP)" href="http://www.bostongis.com/blog/index.php?/archives/175-Minimalist-Web-based-PHP-PostGIS-2.0-Spatial-GeometryRaster-Viewer.html">Web viewer (PHP)</a></li>
</ul>
<div>Thanks to Regina Obe for this, and all the PostGIS team for the excellent work. I&#8217;m working in the GDAL PostGIS Raster driver. So, I hope to have some good news soon.</div>
<p></p>
<div>BTW, if you&#8217;re attending <a title="FOSS4G 2011 in Denver" href="http://2011.foss4g.org/">FOSS4G 2011 in Denver</a>, don&#8217;t miss the talk <a title="PostGIS 2.0, the new stuff" href="http://2011.foss4g.org/sessions/postgis-20-new-stuff">PostGIS 2.0, the new stuff</a></div>
<p></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gis4free.wordpress.com/491/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gis4free.wordpress.com/491/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=491&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gis4free.wordpress.com/2011/08/27/web-based-postgis-geometryraster-viewers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/30cf35ac4c992fff8298cdbd2f887025?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gis4free</media:title>
		</media:content>
	</item>
		<item>
		<title>Free and ready to use anywhere GIS Virtual Machine!</title>
		<link>http://gis4free.wordpress.com/2011/04/07/free-and-ready-to-use-anywhere-gis-virtual-machine/</link>
		<comments>http://gis4free.wordpress.com/2011/04/07/free-and-ready-to-use-anywhere-gis-virtual-machine/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 09:35:25 +0000</pubDate>
		<dc:creator>Jorge Arévalo</dc:creator>
				<category><![CDATA[GIS Software]]></category>
		<category><![CDATA[Virtualization]]></category>

		<guid isPermaLink="false">http://gis4free.wordpress.com/?p=484</guid>
		<description><![CDATA[Ricardo Pinho has announced on postgis-users list the availabilty of a VMWare-powered GIS Virtual Machine, based on Ubuntu 10.10 and with lots of great Open Source GIS stuff. There are 3 versions of this machine: GISVM base: A VM with Ubuntu 10.10 Desktop and ready-to-execute scripts, that allow you to install the GIS software you [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=484&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Ricardo Pinho <a href="http://postgis.refractions.net/pipermail/postgis-users/2011-April/029372.html">has announced on postgis-users list</a> the availabilty of a VMWare-powered GIS Virtual Machine, based on Ubuntu 10.10 and with lots of great Open Source GIS stuff. There are 3 versions of this machine:</p>
<ul>
<li>GISVM base: A VM with Ubuntu 10.10 Desktop and ready-to-execute scripts, that allow you to install the GIS software you need. The lighter version.</li>
<li>GISVM desktop: This VM includes <em>PostgreSQL</em>, <em>PostGIS</em>, <em>GeoServer</em>, <em>Mapserver</em>, <em>FWTools</em>, <em>QGIS</em>, <em>GRASS</em>, <em>gvSIG</em>, <em>uDIG</em>, <em>Kosmo</em> and <em>OpenJump</em> installed. Based on Ubuntu 10.10 Desktop too.</li>
<li>GISVM server: The sever version of the VM includes <em>Linux</em>, <em>Apache</em>, <em>MySQL</em>, <em>Php</em>,<em>Tomcat</em>,<em>PostgreSQL</em>, <em>PostGIS</em>, <em>GeoServer</em>, <em>Mapserver</em>, <em>deegree</em> and <em>Geonetwork</em>. Based on Ubuntu 10.10 server.</li>
</ul>
<p>You can download the machines from <a href="http://gisvm.com/index.html">here</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gis4free.wordpress.com/484/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gis4free.wordpress.com/484/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=484&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gis4free.wordpress.com/2011/04/07/free-and-ready-to-use-anywhere-gis-virtual-machine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/30cf35ac4c992fff8298cdbd2f887025?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gis4free</media:title>
		</media:content>
	</item>
		<item>
		<title>Collaborate with an Open Source project and win 5000$</title>
		<link>http://gis4free.wordpress.com/2011/03/31/collaborate-with-open-source-project-and-win-5000/</link>
		<comments>http://gis4free.wordpress.com/2011/03/31/collaborate-with-open-source-project-and-win-5000/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 22:57:05 +0000</pubDate>
		<dc:creator>Jorge Arévalo</dc:creator>
				<category><![CDATA[GSoC11]]></category>

		<guid isPermaLink="false">http://gis4free.wordpress.com/?p=478</guid>
		<description><![CDATA[I participated in Google Summer of Code 2009, and that was the way I started working on PostGIS and GDAL. Now, I&#8217;ve been selected as mentor in Google Summer of Code 2011. In this page you can see my project and other related ones, with Pierre Racine as proposed mentor. Do you want to collaborate [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=478&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I participated in <a href="http://www.google-melange.com/gsoc/program/home/google/gsoc2009">Google Summer of Code 2009</a>, and that was the way I started working on PostGIS and GDAL. Now, I&#8217;ve been selected as mentor in <a href="http://www.google-melange.com/gsoc/homepage/google/gsoc2011">Google Summer of Code 2011</a>. In <a href="http://trac.osgeo.org/postgis/wiki/WKTRasterGSoC">this page</a> you can see my project and other related ones, with Pierre Racine as proposed mentor.</p>
<p>Do you want to collaborate in an Open Source project? Contact me by e-mail or leave a comment here. This summer could be a great summer of code!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gis4free.wordpress.com/478/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gis4free.wordpress.com/478/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=478&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gis4free.wordpress.com/2011/03/31/collaborate-with-open-source-project-and-win-5000/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/30cf35ac4c992fff8298cdbd2f887025?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gis4free</media:title>
		</media:content>
	</item>
		<item>
		<title>How to install and configure PostGIS Raster on Windows</title>
		<link>http://gis4free.wordpress.com/2011/03/10/how-to-install-and-configure-postgis-raster-on-windows/</link>
		<comments>http://gis4free.wordpress.com/2011/03/10/how-to-install-and-configure-postgis-raster-on-windows/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 18:25:25 +0000</pubDate>
		<dc:creator>Jorge Arévalo</dc:creator>
				<category><![CDATA[GDAL]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[PostGIS Raster]]></category>

		<guid isPermaLink="false">http://gis4free.wordpress.com/?p=438</guid>
		<description><![CDATA[A lot of people ask me about how to use PostGIS Raster and the GDAL PostGIS Raster driver in Windows systems. And most of them are, comprehensibly, using the last stable releases of both libraries (PostGIS and GDAL). The problem is PostGIS Raster and GDAL driver are being developed in these moments. There&#8217;s no stable release, [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=438&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>A lot of people ask me about how to use <a href="http://trac.osgeo.org/postgis/wiki/WKTRaster">PostGIS Raster</a> and the <a href="http://trac.osgeo.org/gdal/wiki/frmts_wtkraster.html">GDAL PostGIS Raster driver</a> in Windows systems. And most of them are, comprehensibly, using the last stable releases of both libraries (PostGIS and GDAL). The problem is PostGIS Raster and GDAL driver are being developed in these moments. There&#8217;s no stable release, so far.</p>
<p>PostGIS Raster was <a href="http://gis4free.wordpress.com/2010/10/01/wkt-raster-is-now-postgis-raster/">included</a> as official part of PostGIS in October 2010. The old version, formerly named WKT Raster has been <strong>abandoned</strong>. So, if you want to use PostGIS Raster, with new functionalities and many bugs fixed, you&#8217;ll have to use the latest PostGIS development snapshot. The use of the old WKT Raster extension is strongly <strong>unrecommended</strong>, and there&#8217;s no support for it.</p>
<p>About GDAL, there was an important change in the driver on October 20st, 2010. A new version was committed, and this is the only version that works with PostGIS Raster. This new driver version was included in the release <strong>1.8.0</strong>, currently the stable release. So, the use of an older release to connect with PostGIS Raster is also <strong>unrecommended</strong>.</p>
<p>With these facts in mind, I understand the Windows users who want to use PostGIS Raster and the GDAL driver are a bit unprotected. I&#8217;m not a Windows user, but I consider it my fault. For this reason, I&#8217;ve decided to create this howto. I&#8217;m going to install and configure PostGIS Raster and GDAL in Windows. And fortunately, you don&#8217;t need to compile anything. Let&#8217;s go for it:</p>
<h3><strong>Enviroment: Windows 7 32 bits</strong></h3>
<h3>Step 1: Installing Python and Numpy</h3>
<p>PostGIS Raster loader uses GDAL Python bindings and numpy. So, we&#8217;ll first install Python and numpy. Several options here:</p>
<ul>
<li><a href="http://www.python.org/download/releases/2.5.4/">Python 2.5</a>, unofficial numpy 1.5.1 (download numpy-1.5.1.win32-py2.5.‌exe from <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/">here</a>)</li>
<li><a href="http://www.python.org/download/releases/2.6.6/">Python 2.6</a>, unofficial numpy 1.5.1 (download numpy-1.5.1.win32-py2.6.‌exe from <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/">here</a>)</li>
<li><a href="http://www.python.org/download/releases/2.7.1/">Python 2.7</a>, unofficial numpy 1.5.1 (download numpy-1.5.1.win32-py2.7.‌exe from <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/">here</a>)</li>
</ul>
<p>I&#8217;m using:</p>
<ul>
<li>Python 2.6.6</li>
<li>Numpy 1.5.1 (numpy-1.5.1.win32-py2.6.‌exe)</li>
</ul>
<h3>Step 2: Installing GDAL</h3>
<p>I think the easiest way to have a complete GDAL installation (library + binaries + Python bindings) working on Windows is using the GDAL binaries mantained by Tamas Szekeres, <a href="http://vbkto.dyndns.org/sdk/">here</a>. Last GDAL versions from trunk are compiled daily with MSVC 2003, MSVC 2005 and MSVC 2008. Pick one. For example, the version compiled with MSVC 2003, <a href="http://vbkto.dyndns.org/sdk/PackageList.aspx?file=release-1310-gdal-1-8-mapserver-5-6.zip">here</a>.</p>
<p>The  faster way now would be to download the <a href="http://vbkto.dyndns.org/sdk/Download.aspx?file=release-1310-gdal-1-8-mapserver-5-6\gdal-18-1310-core.msi">generic installer for the GDAL core components</a>, and choose the complete installation</p>
<div id="attachment_446" class="wp-caption aligncenter" style="width: 509px"><a href="http://gis4free.files.wordpress.com/2011/03/gdal_core_installer_for_windows.png"><img class="size-full wp-image-446" title="GDAL 1.8.0 core installer for Windows" src="http://gis4free.files.wordpress.com/2011/03/gdal_core_installer_for_windows.png?w=600" alt="GDAL 1.8.0 core installer for Windows"   /></a><p class="wp-caption-text">GDAL 1.8.0 core installer for Windows</p></div>
<p>After the installation, you will need to add <em>C:\Program Files\GDAL\</em> to the PATH enviroment var. And create this new var:</p>
<pre>GDAL_DATA=C:\Program Files\GDAL\gdal-data</pre>
<p><strong>UPDATE 2011-10-07</strong>: About the GDAL Python bindings</p>
<p>After installing GDAL core components, you must install the Python bindings separately. You can use<a href="http://vbkto.dyndns.org/sdk/Download.aspx?file=release-1310-gdal-1-8-mapserver-5-6%5CGDAL-1.8.0.win32-py2.7.msi"> this installer</a> (for Python 2.7 and GDAL 1.8.0), or grab one of the executables existent at <a href="http://www.lfd.uci.edu/%7Egohlke/pythonlibs/">http://www.lfd.uci.edu/~gohlke/pythonlibs/</a></p>
<p>Depending on your Python installation, you can choose GDAL-1.8.1.win32-py2.6.‌exe, GDAL-1.8.1.win32-py2.7.‌exe, GDAL-1.8.1.win32-py3.1.‌exe or GDAL-1.8.1.win32-py3.2.‌exe</p>
<p><strong>UPDATE 2011-03-25:</strong> Alicia Duarte, from <a href="http://www.idesf.santafe.gov.ar/idesf/system/index.php">IDESF</a>, told me she was to additionally set the next enviroment vars to make it work:</p>
<pre>GDAL_DRIVER_PATH=C:\Program Files\GDAL\gdalplugins
PROJ_LIB=C:\Program Files\GDAL\projlib</pre>
<p></p>
<p><strong>WARNING</strong>: This directory (GDAL Python bindings location) may not exist in your GDAL installation. In my case, the bindings are in C:\Python27\Lib\site-packages\osgeo, and I didn&#8217;t need to define this variable.</p>
<pre>PYTHONPATH=C:\Program Files\GDAL\python</pre>
<p></p>
<p><del><strong>UPDATE 2011-07-19:</strong>  I think I introduced some confusion in the comments. I apologize for that. Several people are having problems with GDAL Python bindings. I&#8217;ll  try to make it clearer:</del></p>
<ul>
<li><del>On one hand, there&#8217;s a sure thing: you need GDAL library + GDAL Python bindings installed in your system. There&#8217;s an easy way of doing it, by executing the generic installer: <a href="http://vbkto.dyndns.org/sdk/Download.aspx?file=release-1310-gdal-1-8-mapserver-5-6\gdal-18-1310-core.msi">gdal-18-1310-core.msi</a>. This installer includes the Python bindings, and they&#8217;re installed at C:\Program Files\GDAL\python directory by default. This should be enough.</del></li>
<li><del>If you previously have a Python interpreter and a GDAL version installed on your system (check it from a console, executing gdalinfo &#8211;formats), you may want to simply install the proper GDAL Python bindings. Let&#8217;s assume your GDAL version is 1.8 (lower versions won&#8217;t work with PostGIS Raster), and your Python version is 2.7. Then, you simply need to install <a href="http://vbkto.dyndns.org/sdk/Download.aspx?file=release-1310-gdal-1-8-mapserver-5-6\GDAL-1.8.0.win32-py2.7.msi">GDAL-1.8.0.win32-py2.7.msi</a>. This installer will put GDAL Python bindings at C:\Python27\Lib\site-packages by default. This is a different location than above, but at the end, you should have a working version of GDAL Python bindings on your system.</del></li>
<li><del>Finally,  the PostGIS Windows experimental binaries with PostGIS Raster support (step 4) are packed with their own version of GDAL library, used only by the raster2pgsql loader.</del></li>
</ul>
<p>GDAL installed. Now, let&#8217;s go with step 3</p>
<h3>Step 3: Installing PostgreSQL</h3>
<p>I recommend Postgresql 8.4.x or higher. You can download the 1-click-installer from <a href="http://www.enterprisedb.com/products-services-training/pgdownload#windows">here</a>, and install it in the common Windows&#8217; way.</p>
<p>During the installation, you&#8217;ll be asked to install some nice additional stuff using the Application Stack Builder, like PostGIS 1.5.x or PostGIS 1.4.x. Don&#8217;t install anything. The PostGIS versions that can be installed doesn&#8217;t include PostGIS Raster. And you can&#8217;t install it separately, because, remember, now is part of PostGIS. We&#8217;re going to install last PostGIS version by hand. Don&#8217;t be afraid, it&#8217;ll be easy.</p>
<h3>Step 4: Installing PostGIS</h3>
<p>We&#8217;re going to use the <a href="http://postgis.refractions.net/download/windows/experimental.php">PostGIS Windows experimental binaries</a>. We need the binaries compiled for PostgreSQL 8.4, <a href="http://postgis.refractions.net/download/windows/pg84/experimental/postgis/postgis-pg84-binaries-2.0.0svn.zip">these ones</a></p>
<p>Once uncompressed, you can see this</p>
<div id="attachment_441" class="wp-caption aligncenter" style="width: 603px"><img class="size-full wp-image-441" title="Contents of binary package PostGIS 2.0 for Windows" src="http://gis4free.files.wordpress.com/2011/03/postgis_20_for_windows1.png?w=600" alt="postgis20 windows"   /><p class="wp-caption-text">Contents of binary package PostGIS 2.0 for Windows</p></div>
<p>Following the instructions of README.txt file, let&#8217;s edit <em>makepostgisdb.bat</em> to adapt the vars to our enviroment. We may want to change these vars:</p>
<pre>set PGPORT=5432
set PGHOST=localhost
set PGUSER=postgres
set PGPASSWORD=password_of_postgres_user
set THEDB=template_postgis20
set PGBIN=C:\Program Files\PostgreSQL\8.4\bin\
set PGLIB=C:\Program Files\PostgreSQL\8.4\lib\

<span class="Apple-style-span" style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:13px;line-height:19px;white-space:normal;">A</span><span class="Apple-style-span" style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:13px;line-height:19px;white-space:normal;">fter that, we make a backup of our PostgreSQL bin and lib directories (PGBIN and PGLIB). Just in case.</span></pre>
<p>We now execute <em>makepostgisdb.bat</em>. Take into account you may want to execute the script as <strong>administrator</strong>, in case your Windows user doesn&#8217;t have needed privileges (it was my case).</p>
<p><strong>UPDATE 2011-06-08</strong>: For all Windows XP Professional SP2 users:</p>
<p>when you run makepostgisdb.bat from the binaries of POSTGIS SVN2.0, please rename the libiconv-2.dll in bin folder of Postgresql/8.4/bin folder to any other name. Now run the makepostgisdb.bat file. You will not get any error of “operation aborted …. transaction block” (Thanks to <strong>C Patnaik</strong>)</p>
<p>Once executed, we have PostGIS 2.0 + PostGIS Raster installed and configured. A new database called <em>template_postgis20</em> is created, enabled with PostGIS and PostGIS Raster. Easy! Let&#8217;s test it with the next query:</p>
<pre>select postgis_full_version(), postgis_raster_lib_build_date(), postgis_raster_lib_version()</pre>
<p>
And the result:</p>
<div id="attachment_443" class="wp-caption aligncenter" style="width: 710px"><a href="http://gis4free.files.wordpress.com/2011/03/testing_postgis20_windows2.png"><img class="size-full wp-image-443" title="PostGIS version installed" src="http://gis4free.files.wordpress.com/2011/03/testing_postgis20_windows2.png?w=600" alt="PostGIS version installed"   /></a><p class="wp-caption-text">PostGIS version installed</p></div>
<p>Of course, you can create your own database using <em>template_postgis20</em> as template. From the command line:</p>
<pre>createdb -U postgres -T template_postgis20 your_database</pre>
<p>
Or from pgAdmin III:</p>
<div id="attachment_448" class="wp-caption aligncenter" style="width: 356px"><a href="http://gis4free.files.wordpress.com/2011/03/testing_postgis20_windows41.png"><img class="size-full wp-image-448" title="Creating new database from template in pgAdmin III" src="http://gis4free.files.wordpress.com/2011/03/testing_postgis20_windows41.png?w=600" alt="Creating new database from template in pgAdmin III"   /></a><p class="wp-caption-text">Creating new database from template in pgAdmin III</p></div>
<p>If you want to use the SHP2PGSQL GUI, you must copy the <em>postguisgui </em>folder (inside <em>bin </em>folder in the downloaded PostGIS experimental binaries file) into pgAdmin III folder (mine is <em>C:\Program Files\pgAdmin III\1.12</em>) and add the next lines to <em>plugins.ini</em> file, inside pgAdmin III folder too:</p>
<pre>;
;PostGIS shp2pgsql-gui (Windows):
;
Title=PostGIS Shapefile and DBF loader
Command="$$PGBINDIR\postgisgui\shp2pgsql-gui.exe" -h "$$HOSTNAME" -p $$PORT -U "$$USERNAME" -d "$$DATABASE" -W "$$PASSWORD"
Description=Open a PostGIS ESRI Shapefile or Plain dbf loader console to the current database.
KeyFile=$$PGBINDIR\postgisgui\shp2pgsql-gui.exe
Platform=windows
ServerType=postgresql
Database=Yes
SetPassword=Yes</pre>
<p>
After that, you can use the GUI inside pgAdmin III:</p>
<div id="attachment_444" class="wp-caption aligncenter" style="width: 690px"><a href="http://gis4free.files.wordpress.com/2011/03/testing_postgis20_windows3.png"><img class="size-full wp-image-444" title="SHP2PGSQL GUI installed under pgAdmin III" src="http://gis4free.files.wordpress.com/2011/03/testing_postgis20_windows3.png?w=600" alt="SHP2PGSQL GUI installed under pgAdmin III"   /></a><p class="wp-caption-text">SHP2PGSQL GUI installed under pgAdmin III</p></div>
<p>Now you can load raster data into your database in 2 steps. In the first step, you will generate a SQL file. Open a command line and execute this:</p>
<pre>python C:\Program Files\Postgresql\8.4\bin\raster2pgsql.py -r image.tif -t tablename -o image.sql</pre>
<p>
As result of this step, a SQL file named <em>image.sql</em> will be created in the directory where you executed the Python line above.</p>
<p>In the second step, you&#8217;ll need to load the SQL file in your_database, by using your favourite PostgreSQL client. For example, pgAdmin. If your use the psql command line client, the line to execute is:</p>
<pre>psql -h localhost -U postgres -d your_database -f image.sql</pre>
<p>
If you want to translate your raster data from the database to image files at disk again, execute <a href="http://www.gdal.org/gdal_translate.html">gdal_translate</a>.</p>
<pre>gdal_translate PG:"dbname=your_database user=postgres table=your_table mode=2" your_file.tif</pre>
<p>
Basically, this is all what you need to work with PostGIS Raster in Windows. Anyway, take into account the next additional notes:</p>
<h3>Additional notes:</h3>
<p>In step 2, I installed the whole GDAL library, including binaries and Python bindings. In step 4, I installed PostGIS 2.0 with all its pre-requisites. One of them is GDAL. The optimal way would be to use the existent GDAL library, but we&#8217;re working with pre-compiled binaries and DLLs. So, we have 2 copies of GDAL library:</p>
<ul>
<li><em>C:\Program Files\GDAL\gdal18.dll</em>: Installed with generic installer for GDAL, in step 2. Used by gdal_translate, when reading data from database, and in any operation involving GDAL, <strong>except </strong>the raster loading with <em>raster2pgsql.py</em> script</li>
<li><em>C:\Program Files\PostgreSQL\8.4\bin\libgdal.dll</em>: Installed with PostGIS Windows experimental binaries, in step 4. Used by <em>raster2pgsql.py</em> script, to load raster data into PostgreSQL.</li>
</ul>
<p>Both library files were compiled from GDAL 1.8.0 from trunk. But they will be slightly different, for sure. This is a suboptimal solution, of course, but it shouldn&#8217;t cause problems, because <em>libgdal.dll</em> is only used when loading raster data into the database. The rest of operations involving GDAL will be executed linking with <em>gdal18.dll</em></p>
<p>If you want to translate the raster data to any image format different from TIFF, you can use the -of option in gdal_translate. For example:</p>
<pre>gdal_translate -of "PNG" PG:"dbname=your_database user=your_user password=your_password table=your_table mode=2" your_file.png</pre>
<p>To get available raster formats:</p>
<pre>gdalinfo --formats</pre>
<p>UPDATE 2011-06-11: I changed the gdal_translate line. I&#8217;m using the &#8216;postgres&#8217; user and the &#8216;trust&#8217; method to authenticate this user (so, no password is needed), but it&#8217;s only a simplification. In general, you should use a different user and a password-enabled authentication method, like md5. Thanks to <strong>C.Patnaik</strong> again, because <a href="http://gis4free.wordpress.com/2011/03/10/how-to-install-and-configure-postgis-raster-on-windows/#comment-234">his comment</a> remainded me this issue</p>
<p><span class="Apple-style-span" style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:15px;font-weight:bold;line-height:19px;white-space:normal;">Conclussions:</span></p>
<p>It&#8217;s possible to work with the last version of PostGIS Raster and GDAL PostGIS Raster driver in Windows, but assuming that:</p>
<ul>
<li>You&#8217;re using experimental build. Not recommended for production enviroments.</li>
<li>The previous versions of PostGIS Raster (WKT Raster) and GDAL PostGIS Raster driver (before GDAL 1.8.0) are discontinued. Don&#8217;t use them.</li>
<li>It&#8217;s a suboptimal solution, because you install 2 copies of GDAL library. But I think this is the best available solution right now.</li>
</ul>
<p>Do you have problems, something to add, modify or correct? Let me know it in the comments</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gis4free.wordpress.com/438/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gis4free.wordpress.com/438/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=438&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gis4free.wordpress.com/2011/03/10/how-to-install-and-configure-postgis-raster-on-windows/feed/</wfw:commentRss>
		<slash:comments>124</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/30cf35ac4c992fff8298cdbd2f887025?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gis4free</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2011/03/gdal_core_installer_for_windows.png" medium="image">
			<media:title type="html">GDAL 1.8.0 core installer for Windows</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2011/03/postgis_20_for_windows1.png" medium="image">
			<media:title type="html">Contents of binary package PostGIS 2.0 for Windows</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2011/03/testing_postgis20_windows2.png" medium="image">
			<media:title type="html">PostGIS version installed</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2011/03/testing_postgis20_windows41.png" medium="image">
			<media:title type="html">Creating new database from template in pgAdmin III</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2011/03/testing_postgis20_windows3.png" medium="image">
			<media:title type="html">SHP2PGSQL GUI installed under pgAdmin III</media:title>
		</media:content>
	</item>
		<item>
		<title>PostGIS Raster meets Desktop</title>
		<link>http://gis4free.wordpress.com/2010/12/10/postgis-raster-meets-desktop/</link>
		<comments>http://gis4free.wordpress.com/2010/12/10/postgis-raster-meets-desktop/#comments</comments>
		<pubDate>Fri, 10 Dec 2010 12:36:32 +0000</pubDate>
		<dc:creator>Jorge Arévalo</dc:creator>
				<category><![CDATA[PostGIS Raster]]></category>

		<guid isPermaLink="false">http://gis4free.wordpress.com/?p=433</guid>
		<description><![CDATA[As I said in my previous post, there are people working to bring PostGIS Raster to desktop. Specifically: QGIS plugin for PostGIS Raster. Further information here. PostGIS Raster in gvSIG. Presentation in spanish, sorry. Official part of gvSIG from version 1.11. Many thanks! These initiatives help to continue working<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=433&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>As I said in my <a href="http://gis4free.wordpress.com/2010/12/09/gdal-postgis-raster-driver/">previous post</a>, there are people working to bring PostGIS Raster to desktop. Specifically:</p>
<ul>
<li><a href="http://spatialserver.net/pyqgis_1.0/contributed/wktraster.zip">QGIS plugin for PostGIS Raster</a>. Further information <a href="http://pyqgis.org/repo/contributed">here</a>.</li>
<li>PostGIS Raster in gvSIG.<a href="http://www.slideshare.net/nbrodin/postgisrastergvsig"> Presentation</a> in spanish, sorry. Official part of gvSIG from version 1.11.</li>
</ul>
<p>Many thanks! These initiatives help to continue working</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gis4free.wordpress.com/433/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gis4free.wordpress.com/433/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=433&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gis4free.wordpress.com/2010/12/10/postgis-raster-meets-desktop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/30cf35ac4c992fff8298cdbd2f887025?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gis4free</media:title>
		</media:content>
	</item>
		<item>
		<title>GDAL PostGIS Raster Driver</title>
		<link>http://gis4free.wordpress.com/2010/12/09/gdal-postgis-raster-driver/</link>
		<comments>http://gis4free.wordpress.com/2010/12/09/gdal-postgis-raster-driver/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 11:49:45 +0000</pubDate>
		<dc:creator>Jorge Arévalo</dc:creator>
				<category><![CDATA[GDAL]]></category>
		<category><![CDATA[PostGIS Raster]]></category>

		<guid isPermaLink="false">http://gis4free.wordpress.com/?p=424</guid>
		<description><![CDATA[Some people are asking for improvements and bug fixes on GDAL PostGIS Raster driver. Since r20912, there is an improved version of the driver in GDAL trunk. I&#8217;m working on it. And I know there are people making efforts to bring PostGIS Raster to some Desktop viewers by using GDAL. Many thanks! Apart from that, [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=424&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Some people are asking for improvements and bug fixes on <a title="GDAL PostGIS Raster driver" href="http://trac.osgeo.org/gdal/wiki/frmts_wtkraster.html">GDAL PostGIS Raster driver</a>. Since <a title="Release 20912 of GDAL PostGIS Raster driver" href="http://trac.osgeo.org/gdal/changeset/20912">r20912</a>, there is an improved version of the driver in GDAL trunk. I&#8217;m working on it. And I know there are people making efforts to bring PostGIS Raster to some Desktop viewers by using GDAL. Many thanks!</p>
<p>Apart from that, I&#8217;m working on <a title="PostGIS Raster MapAlgebra" href="http://trac.osgeo.org/postgis/wiki/WKTRaster/SpecificationWorking02#Objective2.0.02-Beingabletocreatearasterastheexpressionofanotherraster">PostGIS Raster MapAlgebra</a>. First version before January (I hope&#8230;)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gis4free.wordpress.com/424/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gis4free.wordpress.com/424/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=424&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gis4free.wordpress.com/2010/12/09/gdal-postgis-raster-driver/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/30cf35ac4c992fff8298cdbd2f887025?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gis4free</media:title>
		</media:content>
	</item>
		<item>
		<title>WKT Raster is now PostGIS Raster</title>
		<link>http://gis4free.wordpress.com/2010/10/01/wkt-raster-is-now-postgis-raster/</link>
		<comments>http://gis4free.wordpress.com/2010/10/01/wkt-raster-is-now-postgis-raster/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 15:28:19 +0000</pubDate>
		<dc:creator>Jorge Arévalo</dc:creator>
				<category><![CDATA[PostGIS Raster]]></category>

		<guid isPermaLink="false">http://gis4free.wordpress.com/?p=413</guid>
		<description><![CDATA[The WKT PostGIS raster code is now part of PostGIS trunk. Quick install instructions (from PostGIS sources): ./configure &#8211;with-raster make make rt-all make install make rt-install createdb &#60;your_database&#62; createlang plpgsql &#60;your_database&#62; psql -f postgis/postgis.sql -d &#60;your_database&#62; psql -f spatial_ref_sys.sql -d &#60;your_database&#62; psql -f raster/rt_pg/rtpostgis.sql -d &#60;your_database&#62; UPDATE 1 (2010-10-22): With the last release (r6095) it&#8217;s [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=413&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The <del datetime="2010-10-01T15:19:08+00:00">WKT</del> PostGIS raster code is now part of <a href="http://svn.osgeo.org/postgis/trunk/">PostGIS trunk</a>. Quick install instructions (from PostGIS sources):</p>
<ol>
<li><del>./configure &#8211;with-raster</del></li>
<li><del>make</del></li>
<li><del>make rt-all</del></li>
<li><del>make install</del></li>
<li><del>make rt-install</del></li>
<li><del>createdb &lt;your_database&gt;</del></li>
<li><del>createlang plpgsql &lt;your_database&gt;</del></li>
<li><del>psql -f postgis/postgis.sql -d &lt;your_database&gt;</del></li>
<li><del>psql -f spatial_ref_sys.sql -d &lt;your_database&gt;</del></li>
<li><del>psql -f raster/rt_pg/rtpostgis.sql -d &lt;your_database&gt;</del></li>
</ol>
<p>UPDATE 1 (2010-10-22): With the last release (r6095) it&#8217;s an easier process:</p>
<ol>
<li>./configure &#8211;with-raster</li>
<li>make</li>
<li>make install</li>
<li>createdb &lt;your_database&gt;</li>
<li>createlang plpgsql &lt;your_database&gt;</li>
<li>psql -U &lt;your_user&gt; -f postgis/postgis.sql -d &lt;your_database&gt;</li>
<li>psql -U &lt;your user&gt; -f spatial_ref_sys.sql -d &lt;your_database&gt;</li>
<li>psql -U &lt;your user&gt; -f raster/rt_pg/rtpostgis.sql -d &lt;your_database&gt;</li>
</ol>
<p>In case your user requires a password, add -W as psql flag, and you&#8217;ll be prompted for the password. Further information in <a href="http://svn.osgeo.org/postgis/trunk/README.postgis">README.postgis</a> and <a href="http://svn.osgeo.org/postgis/trunk/README.raster">README.raster</a> files.</p>
<p>And of course, I&#8217;m working on <a href="http://trac.osgeo.org/gdal/wiki/frmts_wtkraster.html">GDAL PostGIS Raster driver</a>. I&#8217;ll add the new specifications ASAP.</p>
<p>UPDATE 2 (2010-10-21): New version of the driver committed to repository.  Now its name is <strong>postgisraster</strong>, instead the old one: <span style="text-decoration:line-through;"><strong>wktraster</strong></span>. Further information in the link above.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gis4free.wordpress.com/413/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gis4free.wordpress.com/413/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=413&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gis4free.wordpress.com/2010/10/01/wkt-raster-is-now-postgis-raster/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/30cf35ac4c992fff8298cdbd2f887025?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gis4free</media:title>
		</media:content>
	</item>
		<item>
		<title>Comparing Oracle GeoRaster with PostGIS WKT Raster (II)</title>
		<link>http://gis4free.wordpress.com/2010/09/01/oracle-georaster-part-ii/</link>
		<comments>http://gis4free.wordpress.com/2010/09/01/oracle-georaster-part-ii/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 23:08:26 +0000</pubDate>
		<dc:creator>Jorge Arévalo</dc:creator>
				<category><![CDATA[PostGIS Raster]]></category>

		<guid isPermaLink="false">http://gis4free.wordpress.com/?p=343</guid>
		<description><![CDATA[In the previous post, I installed and configured Oracle GeoRaster, and did some basic stuff: load a shapefile, load raster data, view these data and export them, using PL/SQL and Java. We compared some points I consider Oracle GeoRaster&#8217;s weak points with PostGIS WKT Raster. Now, I&#8217;d like to reproduce the Pierre Racine&#8217;s tutorial, but [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=343&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>In the <a href="http://gis4free.wordpress.com/2010/07/19/oracle-georaster-part-i/">previous post</a>, I installed and configured Oracle GeoRaster, and did some basic stuff: load a shapefile, load raster data, view these data and export them, using PL/SQL and Java. We compared some points I consider Oracle GeoRaster&#8217;s weak points with PostGIS WKT Raster.</p>
<p>Now, I&#8217;d like to reproduce the <a href="http://trac.osgeo.org/postgis/wiki/WKTRasterTutorial01">Pierre Racine&#8217;s tutorial</a>, but using Oracle GeoRaster. Will it be possible? Let&#8217;s see it&#8230;</p>
<h3>PREVIOUS STEPS</h3>
<p>We&#8217;re going to use <a href="http://www.openjump.org/">OpenJUMP</a>, to see the results of our queries. So, we first install it. Easy task. But now, we need a plugin that allows OpenJUMP to retrieve geographic information from our Oracle Database. The plugin I used was <a href="http://jumpdbqplugin.sourceforge.net/">JUMP DB Query Plugin</a>.</p>
<p>The instructions are pretty clear, so, I only had to:</p>
<ol>
<li>Unzip the plugin files into the OpenJUMP lib/ext folder</li>
<li>Download and unzip the correct Oracle JDBC driver for my Oracle Enterprise Database version (11.1.0.6.0) in the OpenJUMP lib/ext folder.</li>
<li>Run openjump.bat</li>
</ol>
<p>And that&#8217;s all. Ready to start.</p>
<h3>Loading shapefiles (caribou distribution shapefiles)</h3>
<p>I used the cariboupoint table generated in PostGIS, just as described in the tutorial. Using pgsql2shp, I dumped the table data into a shapefile.</p>
<div id="attachment_346" class="wp-caption aligncenter" style="width: 710px"><a href="http://gis4free.files.wordpress.com/2010/08/pgsql2shp.png"><img class="size-full wp-image-346" title="Dumping cariboupoints table" src="http://gis4free.files.wordpress.com/2010/08/pgsql2shp.png?w=600" alt=""   /></a><p class="wp-caption-text">Dumping cariboupoints table</p></div>
<p>Then, using shp2sdo again, I converted my data to SDO format:</p>
<div id="attachment_345" class="wp-caption aligncenter" style="width: 602px"><a href="http://gis4free.files.wordpress.com/2010/08/shp2sdo_2.png"><img class="size-full wp-image-345" title="Transforming cariboupoints SHP to SDO format" src="http://gis4free.files.wordpress.com/2010/08/shp2sdo_2.png?w=600" alt=""   /></a><p class="wp-caption-text">Transforming cariboupoints SHP to SDO format</p></div>
<p>Of course, I could create the data using a PL/SQL procedure, just like Pierre did in his tutorial. But the procedure was created only for providing a shapefile to work with, in case you don&#8217;t have access to real caribou distribution data. We can use the same file.</p>
<h3>Visualizing the caribou point in OpenJUMP</h3>
<p>Now, from OpenJUMP, run the query select geom from cariboupoints. The result, here:</p>
<div id="attachment_347" class="wp-caption aligncenter" style="width: 710px"><a href="http://gis4free.files.wordpress.com/2010/08/openjump_1.png"><img class="size-full wp-image-347" title="Viewing cariboupoints table from Oracle in OpenJUMP" src="http://gis4free.files.wordpress.com/2010/08/openjump_1.png?w=600" alt=""   /></a><p class="wp-caption-text">Viewing cariboupoints table from Oracle in OpenJUMP</p></div>
<h3>Loading raster data</h3>
<p>As we showed in the previous post, we need to insert 4 GeoTIFF files, covering the whole area of Spain. Specifically, 4 SRTM 90m DEM files. There are 2 more files, covering the area of Canary Islands, but they are not continuous with the rest of the data. As Oracle GeoRaster uses a one-georeference-by-layer georeference schema instead of one-georeference-by-raster one, you can&#8217;t store non-continuous raster data in the same raster data table. For the purposes of this tutorial, we only need the 4 files covering Spain area.</p>
<p>So, as we saw in previous post, we first reformat and reblock GeoTIFF images, to ensure they don&#8217;t have BSQ interleaving:</p>
<pre>gdal_translate -of GTiff -a_srs epsg:4326 -anodata -32768 -co “TFW=YES” -co “INTERLEAVE=PIXEL”
-co “TILED=YES” -co "BLOCKXSIZE=50" -co "BLOCKYSIZE=50" image.tif image_new.tif</pre>
<p>&nbsp;<br />
Options used:</p>
<ul>
<li>-of Gtiff: The output format for the reformatted files. GeoTIFF again.</li>
<li>-a_srs epsg:4326: This is the srid for the data. The same than input files.</li>
<li>-anodata -32768: This is the NODATA value for bands. We can get this value using gdalinfo over the original files.</li>
<li>-co &#8220;TFW=YES&#8221;: This forces gdal_translate to create an output tfw file, with georeference data.</li>
<li>-co &#8220;INTERLEAVE=PIXEL&#8221;: Forces pixel interleaving in the output files, the only allowed interleaving schema.</li>
<li>-co &#8220;TILED=yes&#8221;: Forces the creation of stripped TIFF files.</li>
<li>-co &#8220;BLOCKXSIZE=50&#8243;, -co BLOCKYSIZE=50&#8243;: Dimensions for tiles. The same used in WKT Raster tutorial.</li>
</ul>
<p>Further information about GeoTIFF driver for GDAL <a href="http://www.gdal.org/frmt_gtiff.html">here</a>. Now, we have to repit this with every single file we&#8217;re going to load. Once done, we can load the files in Oracle GeoRaster, using SDO_GEOR.importFrom procedure as follows:</p>
<pre>DECLARE
geor SDO_GEORASTER;
BEGIN
-- Initialize an empty GeoRaster object into which the external image
-- is to be imported.
INSERT INTO spain_images
values( 1, 'Spain_TIFF_1', sdo_geor.init('spain_images_rdt') );
-- Import the TIFF image.
SELECT image INTO geor FROM spain_images
WHERE image_id = 1 FOR UPDATE;
sdo_geor.importFrom(geor, 'blocksize=(50,50) spatialExtent=TRUE', 'TIFF', 
'file', 'C:\orcl_tut\srtm_35_04_new.tif',
'WORLDFILE', 'FILE', 'C:\orcl_tut\srtm_35_04_new.tfw');
UPDATE spain_images SET image = geor WHERE image_id = 1;
END;</pre>
<p>&nbsp;<br />
Three comments here:</p>
<ul>
<li>The option &#8216;<em>blocksize=(50,50)</em>&#8216; is not really needed. As we can read in the <a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28398/geor_intro.htm#CHDIJFCD">Oracle Spatial Developer&#8217;s guide, storage parameters section</a>, &#8220;If you specify neither <code>blocking</code> nor <code>blockSize</code>, default values are derived from the source GeoRaster object: that is, if the original data is not blocked, the data in the output GeoRaster object is by default not blocked; and if the original data is blocked, the data in the output GeoRaster object is blocked with the same blocking scheme&#8221;. As long as we specified block size when reformatting GeoTIFF files, we wouldn&#8217;t need to use that option now.</li>
<li>The option &#8216;<em>spatialExtent=TRUE</em>&#8216; will be necessary later. Anyway, if we omit this option, we can generate the spatial extent of the raster objects by <em>SDO_GEOR.generateSpatialExtent</em> procedure, once raster data are loaded. Further information on generating and setting spatial extents in the <a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28398/geor_operations.htm#CIHGGAIG">Oracle Georaster Developer&#8217;s Guide, section 3.6</a></li>
<li>We provide, as additional arguments, the World File, with georeference information.</li>
</ul>
<div>Now, we can see the extent coordinates in the correct reference system:</div>
<div>
<div id="attachment_361" class="wp-caption aligncenter" style="width: 651px"><a href="http://gis4free.files.wordpress.com/2010/08/srtm_spatial_extent_ok1.png"><img class="size-full wp-image-361" title="GeoRaster spatial extent ok" src="http://gis4free.files.wordpress.com/2010/08/srtm_spatial_extent_ok1.png?w=600" alt=""   /></a><p class="wp-caption-text">GeoRaster spatial extent ok</p></div>
</div>
<p>As you can see, the extent of the raster is represented as a polygon in SDO_GEOMETRY format. For me, looks complicated&#8230; If you want to know more about the meaning of all fields of the SDO_GEOMETRY object, you can check it <a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28400/sdo_objrelschema.htm#i1004087">here</a>.</p>
<p>What is the reason of keeping a representation format so complicated? Ok, it could be my impression. After all, I&#8217;m new in this world. Anyway, I started a <a href="http://postgis.refractions.net/pipermail/postgis-devel/2010-August/009951.html">thread </a>on PostGIS devel list, asking for this. One important topic that came up in conversation is Oracle has a <a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28399/toc.htm">topological storage model</a>. But if you want to work with this model, you must use the SDO_TOPO package. And there&#8217;s probably no one tool able to work with this model, apart from Oracle itself, of course.</p>
<p>Take into account, in this particular case, the SDO_GEORASTER table is composed of 4 objects, because we had 4 GeoTIFF files. So, the extent is calculated for each object, not for the whole coverage. If we want only one object, we should:</p>
<ul>
<li>Merge the files before loading them.</li>
<li>Use <a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28398/geor_ref.htm#CACCIGJA"><em>SDO_GEOR.mergeLayers</em></a></li>
</ul>
<p>But, honestly, I didn&#8217;t try these solutions yet.</p>
<p>The last thing we have to do with raster data is&#8230; create and index. As we can read in <a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28398/geor_operations.htm#CIHEHBJB">Oracle GeoRaster developer&#8217;s guide, section 3.7</a>, &#8220;the most important index you can create on a GeoRaster object is a spatial index on the spatial extent (footprint) geometry of the GeoRaster object&#8221;. And we need to take one more thing into account&#8230; According to the <a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28400/sdo_objindex.htm#i78196">documentation (chapter 18)</a>, one of the prerequisites for creating an spatial index over a geometry column is &#8220;The USER_SDO_GEOM_METADATA view must contain an entry with the dimensions and coordinate boundary information for the table column to be spatially indexed&#8221;. And again, in the <a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28400/sdo_objrelschema.htm#i1001937">documentation (chapter 2, section 2.8)</a>: &#8220;Spatial users are responsible for populating these views. For each spatial column, you must insert an appropriate row into the USER_SDO_GEOM_METADATA view. Oracle Spatial ensures that the ALL_SDO_GEOM_METADATA view is also updated to reflect the rows that you insert into USER_SDO_GEOM_METADATA.&#8221; .</p>
<p>So, let&#8217;s do it:</p>
<pre>DELETE FROM user_sdo_geom_metadata WHERE table_name = 'spain_images' AND 
column_name = 'IMAGE.SPATIALEXTENT';
INSERT INTO user_sdo_geom_metadata VALUES ('spain_images', 'IMAGE.SPATIALEXTENT', 
SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -180, 180, .00000005),
SDO_DIM_ELEMENT('Y', -90, 90, .00000005)), 4326);
DROP INDEX spain_images_sidx;
CREATE INDEX spain_images_sidx ON spain_images(image.spatialExtent) INDEXTYPE IS mdsys.spatial_index;</pre>
<p>&nbsp;</p>
<p>Once done, our raster data is ready to work.</p>
<p><span style="color:#ff0000;">And WKT Raster?</span>: All things we&#8217;ve done to load our raster data in Oracle GeoRaster and create an index, can be done in PostGIS WKT Raster by executing these two lines:</p>
<pre>&gt; gdal2wktraster.py" -r C:\orcl_tut\*.tif -t spain_images -s 4326 -k 50x50 -I 
-o C:\orcl_tut\srtm.sql
&gt; psql -d tutorial01 -f C:\orcl_tut\srtm.sql</pre>
<p>&nbsp;<br />
Of course, you need to install all the PostGIS stuff. You have an useful tutorial on how to do this <a href="http://blog.geoprocessamento.net/2010/07/postgis-wkt-raster/">here</a> (in Portuguese, but I think it&#8217;s easy to follow. If you find it difficult, you can read <a href="http://trac.osgeo.org/postgis/wiki/WKTRaster/Documentation01">WKT Raster documentation</a> or ask in the <a href="http://postgis.refractions.net/mailman/listinfo/postgis-users">PostGIS users list</a>.</p>
<p>So far, I find too difficult the simple operation of loading GeoTIFF data in Oracle GeoRaster, comparing it with the same operation done with PostGIS WKT Raster. Of course you can always ask in <a href="http://forums.oracle.com/forums/forum.jspa?forumID=76&amp;start=0">Oracle Spatial forum</a> (register required). The questions I&#8217;ve asked were quickly answered. Really great people in these forums.</p>
<p>Another important difference between both extensions are the indexes. Oracle GeoRaster creates spatial indexes over the footprint of raster data, and WKT Raster creates GiST indexes over the raster data itself. Just a newbie guessing: as far as I know, the operations you can do with raster data itself in Oracle GeoRaster are rather limited. Spatial operations, like intersections, can only be done with the MBR of the data, so, that&#8217;s the reason the indexes are created over the footprint. On the other hand, in PostGIS WKT Raster, you can do really heavy operations with raster data, like <a href="http://postgis.refractions.net/documentation/manual-svn/RT_ST_DumpAsPolygons.html">ST_DumpAsPolygons</a>. Then, create an index over these raster data has more sense.</p>
<p>And if you want to interact with real raster data in Oracle GeoRaster? You can use the <a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28398/geor_operations.htm#CIHIICDF">functionalities </a>provided by SDO_GEOR package or directly <em>attack </em>the data blobs, using <em><a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_lob.htm#BABDDFDH">DBMS_LOB </a></em><a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_lob.htm#BABDDFDH">package</a>. But this last option is a <em>blind</em> attack over raw binary data.</p>
<p>About the spatial extent of the raster data, in WKT Raster the spatial extent of a raster is calculated during the loading process, using GDAL provided raster dimensions, and calculating the georeferenced coordinates for the upper and lower corners. But in this case, the spatial extent of the raster is the enclosing geometry in its model space coordinate system. In Oracle GeoRaster, this is not necessarily in this way. Better idea? Worse idea? Honestly, I don&#8217;t know. An expert may surely provide and smarter point than mine. Reference: <a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28398/geor_operations.htm#CIHGGAIG">Oracle Georaster Developer&#8217;s Guide, section 3.6</a></p>
<h3>Making buffers around the caribou points</h3>
<p>Next step is to make 1km buffers around the caribou points, and reproject our buffers to WGS84, as our raster coverage. We&#8217;ll later use the buffers as sampling window for calculating statistics over an area of the GeoRaster data using <em>SDO_GEOR.generateStatistics. </em>We use a sampling window with Oracle GeoRaster because we can&#8217;t intersect vector and raster data. The closer operation is the one performed by <em>SDO_GEOR.generateStatistics</em>, or <em>SDO_GEOR.subset</em>. This is, select a window to clip an area of the raster and get statistics or raster data over this area.</p>
<p><span style="color:#ff0000;">Problem:</span> The cariboupoints table doesn&#8217;t have a valid SRID. I forgot to specify it when dumping the table from PostGIS. We can set the SRID now:</p>
<div id="attachment_366" class="wp-caption aligncenter" style="width: 478px"><a href="http://gis4free.files.wordpress.com/2010/08/cariboupoints_update.png"><img class="size-full wp-image-366" title="Cariboupoints table update" src="http://gis4free.files.wordpress.com/2010/08/cariboupoints_update.png?w=600" alt=""   /></a><p class="wp-caption-text">Cariboupoints table update</p></div>
<p>We have to update the metadata too:</p>
<div id="attachment_367" class="wp-caption aligncenter" style="width: 652px"><a href="http://gis4free.files.wordpress.com/2010/08/cariboupoints_metadata_update.png"><img class="size-full wp-image-367" title="Cariboupoints metadata update" src="http://gis4free.files.wordpress.com/2010/08/cariboupoints_metadata_update.png?w=600" alt=""   /></a><p class="wp-caption-text">Cariboupoints metadata update</p></div>
<p><span style="color:#ff0000;">Problem:</span> As we can read in <em><a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28398/geor_ref.htm#CHEDCICI">SDO_GEOR.generateStatistics </a></em><a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28398/geor_ref.htm#CHEDCICI">documentation</a>, the sampling window must be <strong>rectangular</strong>, so, we can&#8217;t create round buffers around the cariboupoints. My solution: use the MBR of the buffers as sampling window.</p>
<div id="attachment_393" class="wp-caption aligncenter" style="width: 710px"><a href="http://gis4free.files.wordpress.com/2010/08/buffers_with_mbr.png"><img class="size-full wp-image-393" title="Round buffers with MBR" src="http://gis4free.files.wordpress.com/2010/08/buffers_with_mbr.png?w=600" alt=""   /></a><p class="wp-caption-text">Round buffers with MBR</p></div>
<p>This is the SQL code for creating the table with rectangular buffers around cariboupoints elements:</p>
<pre>create table cariboupoint_buffers_wgs AS
select <a href="http://t.id/" target="_blank">t.id</a>, sdo_geom.sdo_mbr(sdo_geom.sdo_buffer(sdo_cs.transform(t.geom,
4326), 1000, 1)) geom
from cariboupoints t;</pre>
<p>&nbsp;<br />
Now, we create an index over the polygons:</p>
<pre>DELETE FROM user_sdo_geom_metadata WHERE table_name = 'cariboupoint_buffers_wgs' AND 
column_name = 'geom';
INSERT INTO user_sdo_geom_metadata VALUES ('cariboupoints_buffers_wgs', 'geom', 
SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', -180, 180, .00000005),
SDO_DIM_ELEMENT('Y', -90, 90, .00000005)), 4326);
DROP INDEX spain_images_sidx;
CREATE INDEX cariboupoints_buffers_wgs_gidx ON cariboupoints_buffers_wgs(geom) 
INDEXTYPE IS mdsys.spatial_index;</pre>
<p>&nbsp;<br />
<span style="color:#ff0000;">And in PostGIS?</span>: As in Oracle Spatial, when you create a new table, you can create a GiST index over the spatial column (or a R-Tree index, but <a href="http://postgis.refractions.net/docs/ch04.html#id2794434">GiST indexes are recommended</a>). However, I think the process in PostGIS is simpler: you only have to create the table and then the index.  In Oracle, you first have to update the metadata view, as seen. And you need to know not only the srid of your spatial data (easy to get) but the dimensions limits, and provide a <em><a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28400/sdo_intro.htm#i884589">tolerance</a></em>, one concept you doesn&#8217;t need to necesarily know in Oracle&#8217;s context.</p>
<p>Let&#8217;s continue. Now, we show in OpenJump 2 layers:</p>
<ul>
<li>One layer with the extent of our rasters (we can&#8217;t polygonize them with Oracle GeoRaster, like in <a href="http://postgis.refractions.net/documentation/manual-svn/RT_ST_DumpAsPolygons.html">PostGIS WKT Raster</a>). SRID 4326.</li>
<li>One layer with 1 KM rectangular buffers around cariboupoints. srid 4326.</li>
</ul>
<div id="attachment_392" class="wp-caption aligncenter" style="width: 710px"><a href="http://gis4free.files.wordpress.com/2010/08/buffers_and_spatial_extent.png"><img class="size-full wp-image-392" title="Rectangular Buffers and spatial extent of the raster data" src="http://gis4free.files.wordpress.com/2010/08/buffers_and_spatial_extent.png?w=600" alt=""   /></a><p class="wp-caption-text">Rectangular Buffers and spatial extent of the raster data</p></div>
<p>Closer screenshot</p>
<div id="attachment_396" class="wp-caption aligncenter" style="width: 710px"><a href="http://gis4free.files.wordpress.com/2010/08/intersections2.png"><img class="size-full wp-image-396" title="Extents with intersections (closer)" src="http://gis4free.files.wordpress.com/2010/08/intersections2.png?w=600" alt=""   /></a><p class="wp-caption-text">Extents with intersections (closer)</p></div>
<h3>Intersecting the caribou buffers with the elevation rasters</h3>
<p><span style="color:#ff0000;">Big Problem</span>: As said,<strong> you can&#8217;t intersect vector raster data with Oracle Database</strong>. Oracle Spatial has some <a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28400/sdo_operat.htm#i76448">spatial operators</a>, and a <a href="http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28400/sdo_objgeom.htm#i865398">geometry package</a>, and you can perform some spatial operations. But Oracle GeoRaster doesn&#8217;t have this capability.</p>
<p>The solution adopted was to:</p>
<ol>
<li>Calculate what are the buffers that intersects the spatialExtent of the GeoRaster objects.</li>
<li>Using these buffers as sampling windows, generate statistics for each pair buffer-georaster object, and store these statistics in a table</li>
<li>Using the statistics generated, calculate the weighted mean elevation of the raster areas delimited by the buffers, and store the results in another table.</li>
</ol>
<p>We can see these 3 steps in the next piece of PL/SQL code:</p>
<pre style="padding-left:30px;">declare
cellCoordinate mdsys.sdo_geometry;
ret varchar2(256);
generated_statistics sdo_number_array;
gr sdo_georaster;
begin</pre>
<pre style="padding-left:30px;">-- create statistics table
create table srtm_caribou_inter_statistics (
id number, -- buffer id
rid number,
statistics sdo_number_array
);</pre>
<pre style="padding-left:30px;">-- Intersects spatial extent of the rasters with the buffers
for intersection in
(select <a href="http://t.id/" target="_blank"><span style="color:#000000;">t.id</span></a>, t.geom, r.image_id as rid from spain_images r,
cariboupoint_buffers_wgs t
where sdo_geom.sdo_intersection(r.image.spatialExtent, t.geom, 0.005)
is not null)</pre>
<pre style="padding-left:30px;">loop
-- Get georaster image
select image into gr from spain_images where image_id
= intersection.rid for update;</pre>
<pre style="padding-left:30px;">-- First, we need geom coordinates in raster space coordinates
sdo_geor.getCellCoordinate(gr, 0, intersection.geom,
cellCoordinate);</pre>
<pre style="padding-left:30px;">-- Generate statistics for a given georaster object
ret := sdo_geor.generateStatistics(gr,
'samplingFactor=1', cellCoordinate, 'FALSE', '1-1', 'TRUE', NULL,
'TRUE');</pre>
<pre style="padding-left:30px;">-- update object
update spain_images r set r.image = gr where
r.image_id = intersection.rid;</pre>
<pre style="padding-left:30px;">-- commit changes
commit;</pre>
<pre style="padding-left:30px;">-- get generated statistics
generated_statistics := sdo_geor.getStatistics(gr, 1);</pre>
<pre style="padding-left:30px;">-- insert them in statistics table
insert into srtm_caribou_inter_statistics(id, rid, statistics) values
(<a href="http://intersection.id/" target="_blank"><span style="color:#000000;">intersection.id</span></a>, intersection.rid, generated_statistics);</pre>
<pre style="padding-left:30px;">end loop;
commit;
end;
/</pre>
<p>&nbsp;<br />
The code can be improved, as Jeffrey Xie suggested in <a href="http://forums.oracle.com/forums/thread.jspa?threadID=1121361&amp;tstart=0">this post</a>, by using the result of the intersection operation as sampling window.  Anyway, this code runs very fasts. Less than 2 minutes. Only 212 buffers of the 814 intersects with the raster extents. Here, we can see a screenshot of the raster data and the intersecting buffers only (212). We can compare it with the previous OpenJUMP screenshot, with all the points (814).</p>
<div id="attachment_395" class="wp-caption aligncenter" style="width: 710px"><a href="http://gis4free.files.wordpress.com/2010/08/intersections1.png"><img class="size-full wp-image-395" title="Extents with intersections" src="http://gis4free.files.wordpress.com/2010/08/intersections1.png?w=600" alt=""   /></a><p class="wp-caption-text">Extents with intersections</p></div>
<p><span style="color:#ff0000;">And WKT Raster?</span>: In WKT Raster we can create round buffers, and really<a href="http://postgis.refractions.net/documentation/manual-svn/RT_ST_Intersection.html"> intersects these polygons with the raster data</a>. But the intersection is much slower, for 2 reasons:</p>
<ol>
<li>To really intersects vector and raster data (NOT vector with raster MBRs), we have to polygonize the raster, and then intersects these polygons with the vector data. This is a really heavy operation. In Oracle, you only check intersection betweem MBR, and only 212 of the 814 buffers intersect with the raster</li>
<li>The sampling windows used in Oracle GeoRaster for intersection are rectangular. The buffers intersected with the raster data in WKT Raster are not rectangular.</li>
</ol>
<h3>Summarizing the elevation values for each buffer and exporting the table to CSV</h3>
<p>As Pierre did, our last step is to compute the weighted mean elevation raster.  We&#8217;ll do in four steps:</p>
<ul>
<li> Create a table to store the mean elevation data. The SQL code is:
<pre>create table means_table(id number, rid number, mean number)</pre>
</li>
<li>Fill the table. We have a problem here, because the varray field (the statistics obtained by SDO_GEOR.generateStatistics) must be cast to a nested table to access its fields, like we can read <a href="http://forums.oracle.com/forums/thread.jspa?threadID=358862">here</a>. The PL/SQL code to do this is:</li>
</ul>
<pre style="text-align:justify;padding-left:60px;">declare</pre>
<pre style="text-align:justify;padding-left:90px;">st_array sdo_number_array;</pre>
<pre style="text-align:justify;padding-left:90px;">sql_stmt varchar(256);</pre>
<pre style="text-align:justify;padding-left:60px;">begin</pre>
<pre style="padding-left:90px;">for c1 in (select * from srtm_caribou_inter_statistics) loop</pre>
<pre style="padding-left:120px;">for i in c1.stats_array.FIRST..c1.stats_array.LAST loop¡</pre>
<pre style="padding-left:150px;">if i = 3 then</pre>
<p style="padding-left:60px;">
<pre style="padding-left:180px;">sql_stmt := 'insert into means_table values (:1, :2, :3)';</pre>
<pre style="padding-left:180px;">execute immediate sql_stmt using <a href="http://c1.id" target="_blank"><span style="color:#000000;">c1.id</span></a>, c1.rid, c1.stats_array(i);</pre>
<pre style="padding-left:150px;">end if;</pre>
<pre style="padding-left:120px;">end loop;</pre>
<pre style="padding-left:90px;">end loop;</pre>
<pre style="padding-left:90px;">commit;</pre>
<pre style="text-align:justify;padding-left:60px;">end;</pre>
<p>&nbsp;</p>
<ul>
<li>Generate mean elevation data, by this query:</li>
</ul>
<ul style="padding-left:60px;"></ul>
<pre style="padding-left:60px;">select <a href="http://m.id" target="_blank">m.id</a>, m.mean*sdo_geom.sdo_area(sdo_cs.transform(cpb.geom,
32198), 1)  / sdo_geom.sdo_area(sdo_cs.transform(cpb.geom, 32198), 1)
as meanelev from means_table m, cariboupoint_buffers_wgs cpb where <a href="http://cpb.id" target="_blank">cpb.id</a> = <a href="http://m.id" target="_blank">m.id</a>;</pre>
<p>&nbsp;</p>
<ul>
<li>Export the data to a CSV file. We need more PL/SQL for this. In <a href="http://pandazen.wordpress.com/2008/02/01/export-oracle-query-result-to-csv/">this page</a> there is an excellent method to dump query results in a csv file.</li>
</ul>
<ul style="padding-left:60px;"></ul>
<h3>Conclussions</h3>
<p>With Oracle GeoRaster you can do a basic raster/vector overlay analysis: compute pixel value statistics on areas delimited by vector polygons. But, in my opinion, it&#8217;s a hard task, because of non-intuitive tools and operations, and the fact Oracle GeoRaster wasn&#8217;t thought for spatial analysis, but mainly for raster data storage. And even using it for raster data storage, I think it&#8217;s a bit difficult. On the other hand, with PostGIS WKT Raster, you can perform this kind of operations in an easier and more intuitive way, at least for a non-experienced user, like me. </p>
<p>Next post: comparing the <em>ideal</em> raster-on-database support with both extensions: Oracle GeoRaster and PostGIS WKT Raster</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gis4free.wordpress.com/343/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gis4free.wordpress.com/343/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gis4free.wordpress.com&#038;blog=13838197&#038;post=343&#038;subd=gis4free&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gis4free.wordpress.com/2010/09/01/oracle-georaster-part-ii/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/30cf35ac4c992fff8298cdbd2f887025?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gis4free</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2010/08/pgsql2shp.png" medium="image">
			<media:title type="html">Dumping cariboupoints table</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2010/08/shp2sdo_2.png" medium="image">
			<media:title type="html">Transforming cariboupoints SHP to SDO format</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2010/08/openjump_1.png" medium="image">
			<media:title type="html">Viewing cariboupoints table from Oracle in OpenJUMP</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2010/08/srtm_spatial_extent_ok1.png" medium="image">
			<media:title type="html">GeoRaster spatial extent ok</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2010/08/cariboupoints_update.png" medium="image">
			<media:title type="html">Cariboupoints table update</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2010/08/cariboupoints_metadata_update.png" medium="image">
			<media:title type="html">Cariboupoints metadata update</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2010/08/buffers_with_mbr.png" medium="image">
			<media:title type="html">Round buffers with MBR</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2010/08/buffers_and_spatial_extent.png" medium="image">
			<media:title type="html">Rectangular Buffers and spatial extent of the raster data</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2010/08/intersections2.png" medium="image">
			<media:title type="html">Extents with intersections (closer)</media:title>
		</media:content>

		<media:content url="http://gis4free.files.wordpress.com/2010/08/intersections1.png" medium="image">
			<media:title type="html">Extents with intersections</media:title>
		</media:content>
	</item>
	</channel>
</rss>
