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.

Similar questions have been asked, but since my reputation is not enough I am unable to comment on answers.

(The following is from an answer by nickves for this question Loading raster data to postgis)

Example: raster2sql -s -t 50x50 -f -I -Y myRaster.tif rasterSchema.RasterName > raster.sql` psql -h localhost -U someuser -d mydb -f raster.sql

Question1: What does the following mean in relation to the above example:

  1. rasterSchema.RasterName
  2. raster.sql`psql
  3. -f raster.sql

Question2: Given the following information, what would the syntax look like for loading a raster to a PostGIS 2.0 database?

  1. Image location = C:\Users\Desktop\dem.tif
  2. SRID = 2048
  3. Database name = Rasters
  4. Schema = Elevation

My os is windows 7 (not sure if this makes a differnce).

Regards

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Question 1:

The entire script consists of options to raster2psql tool, where to store the output, then a call to psql utility to load the data into postgresql

rasterschema.rastername: Postgresql database internal structure is made of schemas - which are actually databases, and among other things, tables. So in this case it means that the import SQL script that will be generated by the raster2sql utility will try to import the data into a database called rasterSchema and table called rasterName (i think they must preexist)

Second part... what you should be looking is this:

> raster.sql (note the > char)

This means that the output of the raster2sql utility once you run it, will be directed into the raster.sql file (which will be created from where you call the utility)

The last part: psql till the end, is actually a call to psql admin tool for postgresql, and all parameters are related to loading the script file that the raster2psql tool will generate.

-H option means the hostname where postgresql server is running (this is localhost if your database server is running on your workstation)

-U option = username for the database

-d = database to which data will be loaded

NOTE: -P option may be needed in your case (password)

and finally -f raster.sql is the script that the psql utility will attempt to run.

Question 2: answer should look something like this:

raster2sql -s -t 50x50 -f -I -Y C:\Users\Desktop\dem.tif Raster.Elevation > raster.sql psql -h localhost -U your-user-name -P your-password-if-needed -d Raster -f raster.sql
share|improve this answer
    
Thank you for the explanation. It makes sense. I have changed your example slightly by leaving out Raster.Elevation since it returned a "schema 'raster' does not exist" error (I did create schema Raster before trying to load the raster). The problem I have now is viewing it in QGIS. Loading the raster to QGIS, using the DB Manager, returns a "This is not a valid layer" error. Any suggestions? –  Thunderbolt Jul 29 '13 at 11:18
    
I have found the reason for the QGIS error "This is not a valid layer". For some reason when loading the raster into PostGIS 2.0 a column labeled -i (which is defined as a Raster column) is created. Renaming ths column from -i to rast solved the error. –  Thunderbolt Jul 29 '13 at 11:41

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.