[GIS] How to run two PostGIS versions in parallel on Windows

postgispostgis-2.0updatewindows

I'm trying to understand how to install PostGIS2.0 on Windows7. The PostGIS site has the following suggestions:

PostGIS Experimental Binaries PostGIS 2.0.0SVN Binaries with Raster,
Topology support + Extras (Tiger Geocoder 2010) As of November 25th,
2011 (r8242) includes GEOS 3.3.2dev r3516, Proj 4.6.1, JSON-c 0.9,
libgdal 1.9 SVN r23320 (VERSIONS prior to (r7923) require a dump
reload since operators have changed. We now have the 3D spatial
indexes, 3D box operators, KNN GIST for 9.1, and 2 raster map algebra)

More details about what has been fixed/added can be found at PostGIS
2.0.0 and PostGIS 1.5.3/1.5.4 fixes , What is new in PostGIS 2.0, PostGIS Raster support, and improved Topology support These are 32-bit
binaries so will not work on 64-bit PostgreSQL. We are working on
getting 64-bit binaries out as well, but are running into some
stumbling blocks. For the time being — if you are on Windows 64-bit,
you must install the 32-bit PostgreSQL to use these.

For PostgreSQL 8.4 w/ Loader/Dumper including GUI
For PostgreSQL 9.0 (compiled against PostgreSQL 9.0.3) w/ Loader/Dumper including GUI
For PostgreSQL 9.1 (compiled against PostgreSQL 9.1.0 - note 9.1 structure changed in beta 1 so this will not work with alpha releases

but should be fine for all beta, release candidate releases and final
9.1.0 release) w/ Loader/Dumper including GUI. Also includes extensions files to install using new PostgreSQL 9.1+ CREATE EXTENSION
syntax. To install:

First copy the share/extension files into your PostgreSQL share/extension folder.

Then in any database you'd like to spatially enable, run at least postgis (which contains both geometry and raster support) and

optionally postgis_topology commands.

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;

I currently have PostGIS 1.5 installed on PostgreSQL 8.4. This is what my folder structure looks like:

enter image description here

I don't fully understand these instructions:

First copy the share/extension files into your PostgreSQL
share/extension folder.

Then in any database you'd like to spatially enable, run at least
postgis (which contains both geometry and raster support) and
optionally postgis_topology commands.

I've downloaded postgisgui_pgadmin-2.0.0svn and postgis-pg84-binaries-2.0.0svn. In my original folder structure I don't have a folder extension within share. Do I just copy the contents of postgis-pg84-binaries-2.0.0svn into this folder? What does it mean to run at least postgis? I've also tried to follow the detailed instructions at the following blog.


EDIT: I have installed Postgresql 9.1 with PostGIS 1.5.3. I am trying to figure out where to copy the PostGIS 2.0 binaries. It seems like I should be copying them into the folders here:

enter image description here

but the advice suggests placing them in the share/extension folder.

I tried copying the entire folder into share/extension/ and then editing the makepostgis.bat file to make it relevant to my file system (the port is 5434 as I have two instances of Postgresql running).

set PGPORT=5434 
set PGHOST=localhost
set PGUSER=postgres
set PGPASSWORD=****
set THEDB=template_postgis20
set PGBIN=C:\Program Files (x86)\PostgreSQL\9.1\bin\
set PGLIB=C:\Program Files (x86)\PostgreSQL\9.1\lib\

When I run this file as an administrator, I get the following error:

C:\Windows\system32>set PGPORT=5434    
C:\Windows\system32>set PGHOST=localhost    
C:\Windows\system32>set PGUSER=postgres    
C:\Windows\system32>set PGPASSWORD=****    
C:\Windows\system32>set THEDB=template_postgis20    
C:\Windows\system32>set PGBIN=C:\Program Files (x86)\PostgreSQL\9.1\bin\    
C:\Windows\system32>set PGLIB=C:\Program Files (x86)\PostgreSQL\9.1\lib\    
C:\Windows\system32>set POSTGISVER=2.0    
C:\Windows\system32>xcopy bin\*.* "C:\Program Files (x86)\PostgreSQL\9.1\bin\"
File not found - *.*
0 File(s) copied

C:\Windows\system32>xcopy /I /S bin\postgisgui\* "C:\Program Files (x86)\PostgreSQL\9.1\bin\\postgisgui"
File not found - *
0 File(s) copied

C:\Windows\system32>xcopy lib\*.* "C:\Program Files (x86)\PostgreSQL\9.1\lib\"
File not found - *.*
0 File(s) copied

C:\Windows\system32>"C:\Program Files (x86)\PostgreSQL\9.1\bin\\psql"  -c "CREATE DATABASE template_postgis20"
ERROR:  database "template_postgis20" already exists

C:\Windows\system32>"C:\Program Files (x86)\PostgreSQL\9.1\bin\\psql"  -d "template_postgis20" -c "CREATE LANGUAGE plpgs
ql"
ERROR:  language "plpgsql" already exists

C:\Windows\system32>"C:\Program Files (x86)\PostgreSQL\9.1\bin\\psql"  -d "template_postgis20" -f "share\contrib\postgis
-2.0\postgis.sql"
share/contrib/postgis-2.0/postgis.sql: No such file or directory

....the errors continue....

Best Answer

I've updated the instructions on the website. Hope it's a bit clearer.

Nicklas is right you don't really need the makepostgis.bat if you just copy the like folders to your postgresql install (you could also remark out the create db in it since it does copy all the files). You should be able to just overlay ontop since the zip structure is the same as standard windows enterprisedb packaged PostgreSQL binaries. What I neglected to mention in the instructions is that you do still need the binaries and libs. This I have updated so its should be clearer.

We don't have the create extension approach as the official for PostgreSQL 9.1 yet since we are working out some issues with using the ALTER EXTENSION postgis UPGRADE .. syntax which is more of an issue with PostGIS 2.0 non-released since there are no official freeze points yet. In the currently packaged it works fine but its harder to ensure it works given all the flux of stuff going on in PostGIS 2.0 in the past month.