Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Hi GIS Stackexchange people,

When I try to load a asc file into my psql setup, I get a strange error message. I have created the sql input file via

raster2pgsql -s 4236 -I -C -M gis_data.asc -F public.lightning > lightning.sql

The parameters follow exactly this link here. When I try to load the data into pgsql with

psql -d database_name -f lightning.sql

I get the following error message:

BEGIN
psql:lightning.sql:2: NOTICE:  CREATE TABLE will create implicit sequence "lightning_rid_seq" for serial column "lightning.rid"
psql:lightning.sql:2: ERROR:  type "raster" does not exist
LINE 1: ...lic"."lightning" ("rid" serial PRIMARY KEY,"rast" raster,"fi...
                                                             ^
psql:lightning.sql:3: ERROR:  current transaction is aborted, commands ignored until end of transaction block
psql:lightning.sql:4: ERROR:  current transaction is aborted, commands ignored until end of transaction block
psql:lightning.sql:5: ERROR:  current transaction is aborted, commands ignored until end of transaction block
psql:lightning.sql:6: ERROR:  current transaction is aborted, commands ignored until end of transaction block
ROLLBACK
psql:lightning.sql:8: ERROR:  relation "public.lightning" does not exist

I thought that the sql input file would instruct pgsql to create the required tables, especially since the lightning.sql file starts with

BEGIN;
CREATE TABLE "public"."lightning" ("rid" serial PRIMARY KEY,"rast" raster,"filename"   
text); 

Do I need to create the tables manually? What is the required type raster? Where is the mistake i do to get the gis data into the pgsql database?

Thank you for your advice!

PS: Interestingly, my lightning.sql file contains a strange bit sequence. Is that normal? I thought it would be a full ascii file with sql instructions?

BEGIN; CREATE TABLE "public"."lightning" ("rid" serial PRIMARY KEY,"rast" raster,"filename"
text);

INSERT INTO "public"."lightning" ("rast","filename") VALUES                            
('01000001001975ADBD4F55B53F1975ADBD4F55B5BF0000000000003BC0B4CA4C69FDFF514000000000000 ... ')
CREATE INDEX "lightning_rast_gist" ON "public"."lightning" USING gist                  
(st_convexhull("rast"));
ANALYZE "public"."lightning";
SELECT AddRasterConstraints('public','lightning','rast',TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,,
FALSE,TRUE,TRUE,TRUE,TRUE,TRUE);
END;
VACUUM ANALYZE "public"."lightning";

Was maybe the conversion not ok?

share|improve this question
    
U2ros's answer works for me. For windows users, you can find these files in: "C:/Program Files/PosgreSQL/[your version]/share/contrib/[your version]/" PS: It should be a comment, but I don't have enough reputation to post a comment. –  Jackie Jan 16 at 4:23
add comment

1 Answer

up vote 3 down vote accepted

When you create a Postgis template database via loading and executing the sql scripts: postgis.sql and spatial_ref_sys.sql, you create the basic postgis template. This adds the spatial functions, reference systems, geometry data types, but not the raster datatype. To add that, you have to load and execute another script: rtpostgis.sql which is located next to the other 2 files. On linux thats in /usr/share/postgresql/9.1/contrib/postgis-2.0.1/rtpostgis.sql

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.