July 29, 2009

Installing PostgreSQL and PostGIS - Part 3

Storing some geospatial data.
Following the steps documented in Postgis documentation here.
I have used pgadmin for accessing postgresql but psql will suffice too. I recommend pgadmin as it lets you see the spatial structures much more easily.


Step 1 - Create some normal table

CREATE TABLE roads (
road_id INTEGER,
road_name VARCHAR
);

Step 2 - Add a special column for spatial data

SELECT AddGeometryColumn( 'roads', 'roads_geom', -1, 'GEOMETRY',
 2 );

The 2 at the end of the sql command indicates the dimension of the geometry.

Step 3 - Add some data

BEGIN;
INSERT INTO roads (road_id, roads_geom, road_name)
VALUES (1,ST_GeomFromText('LINESTRING(191232 243118,191108 243242)',-1),'Jeff Rd');
INSERT INTO roads (road_id, roads_geom, road_name)
VALUES (2,ST_GeomFromText('LINESTRING(189141 244158,189265 244817)',-1),'Geordie Rd');
INSERT INTO roads (road_id, roads_geom, road_name)
VALUES (3,ST_GeomFromText('LINESTRING(192783 228138,192612 229814)',-1),'Paul St');
INSERT INTO roads (road_id, roads_geom, road_name)
VALUES (4,ST_GeomFromText('LINESTRING(189412 252431,189631 259122)',-1),'Graeme Ave');
INSERT INTO roads (road_id, roads_geom, road_name)
VALUES (5,ST_GeomFromText('LINESTRING(190131 224148,190871 228134)',-1),'Phil Tce');
INSERT INTO roads (road_id, roads_geom, road_name)
VALUES (6,ST_GeomFromText('LINESTRING(198231 263418,198213 268322)',-1),'Dave Cres');
COMMIT;

You can view the data from some postgis enabled application like uDIG or JGrass.

Related posts:
[1]Installing PostgreSQL and PostGIS - Part 1
[2]Installing PostgreSQL and PostGIS - Part 2

Installing PostgreSQL and PostGIS - Part 2

The previous step was [1].

Now installing postgis 1.4. Actually this consists of copying some dlls and running some scripts for creating spatial datatypes and functions.
My database name is deneme.

Installing

Step 1
Downloaded postgis and unzipped it, copied everything to the postgresql installation directory.
Step 2
Ran some sql scripts using psql. Followed the steps in postgis documentation here...

That was all...

Part 3 is for loading some data...

[1] Installing PostgreSQL and PostGIS - Part 1

Difference between WCS, WMS and WFS

(Writing this entry hoping it makes clear of a novice GIS developer like me)

First the terminology...
WMS - Web Map Service
This service only serves image files, nothing else. You get pngs,gifs, jpgs or tiffs. You can also display coverage data but your actual data is mapped to imagery. For example, in geoserver, you can actually serve bathymetry (elevation including seas) data in geotiff to clients, but your coverage data including elevation is mapped to RGB data in png.

WCS - Web Covarage Service
From the introduction part from OGC 's WCS Implementation Standart Document.

The Web Coverage Service (WCS) supports electronic retrieval of geospatial data as "coverages" – that is, digital geospatial information representing space-varying phenomena.

A WCS provides access to potentially detailed and rich sets of geospatial information, in forms that are useful for client-side rendering, multi-valued coverages, and input into scientific models and other clients. The WCS may be compared to the OGC Web Map Service (WMS) and the Web Feature Service (WFS); like them it allows clients to choose portions of a server's information holdings based on spatial constraints and other criteria.

Unlike the WMS [OGC 06-042], which portrays spatial data to return static maps (rendered as pictures by the server), the Web Coverage Service provides available data together with their detailed descriptions; defines a rich syntax for requests against these data; and returns data with its original semantics (instead of pictures) which may be interpreted, extrapolated, etc. – and not just portrayed.

Unlike WFS [OGC 04-094], which returns discrete geospatial features, the Web Coverage Service returns coverages representing space-varying phenomena that relate a spatio-temporal domain to a (possibly multidimensional) range of properties.

July 22, 2009

Installing PostgreSQL and PostGIS - Part 1

(This post is all about my Windows XP experience... Note that under normal conditions postgresql installer should work just fine, my situation is an exceptional case, I guess )

I have been trying to install PostGIS. I have encountered some issues which may be helpful for others. I have not yet been successfull, as I will update this post as a log of my status.

Take 1 - Downloaded PosgreSQL 8.4 and installed it. Postgresql comes with a tool called Stack Builder which lets you install additional components. Postgis can be installed this way, they say. I have chosen in the list and saw spatial node. Chose postgis 1.3.6 and a mirror service for download. It downloaded successfully, started installing and bingo, it is not compatible with postgresql 8.4. Then why in the hell is it listed in the stack builder at first place.

Take 2 - Uninstalled 8.4, installed 8.3. Same steps... When I ran Stack Builder I have detected that 8.3 server is not running, erronous installation. Uninstalling again, going thru regedit, deleting all keys for postgresql, and trying to reinstall 8.3. Uhhh, not worked again, I guess I will have to restart $%#$%#$%.


Take 3 - Restarted. No change. Now took a different path. I have downloaded the zip file of the PostgreSQL 8.4.1 and unzipped it.

Creating the database
I have created a database using the command line tool createdb;
createdb deneme

Give full rights to this directory for the user postgresql database will run under(in my case this is the user postgres).

Running postgresql
In standart case postgresql can not be run under administrative user for security reasons. For this reason you should use runas command from the command prompt.
I tried to run the postgresql from command line using the command :
postgres -D ..\data and have encountered an error. -D indicates the data directory for the postgresql.

Tried this instead;
runas /env /user:postgres "postgres -D ..\data".
You can use absolute paths here.

That's all.

Related posts:
[1] Installing PostgreSQL and PostGIS - Part 2 
[2]  Installing PostgreSQL and PostGIS - Part 3