Deal of the Day

Home » Main » Manning Forums » 2009 » PostGIS in Action

Thread: Chapter 13 - raster

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 12 - Pages: 1 - Last Post: Feb 1, 2012 2:35 AM by: regina.leo
hachinamio

Posts: 5
From: viet nam
Registered: 9/22/11
Chapter 13 - raster
Posted: Sep 22, 2011 11:29 PM
  Click to reply to this thread Reply

I do everything following the instruction of chapter 13, but i cant still import raster image to postgreSQL. somebody helps me! how to import raster image to postgreSQL. thanks.

regina.leo

Posts: 232
Registered: 5/6/09
Re: Chapter 13 - raster
Posted: Sep 22, 2011 11:41 PM   in response to: hachinamio in response to: hachinamio
  Click to reply to this thread Reply

hachinamio,

What file are you trying to load and what error do you get? It's possible you are using an old binary or you don't have raster installed.

Also you can get more help on the PostGIS newsgroup if you subscribe.

http://www.postgis.org/mailman/listinfo/postgis-users

the PostGIS development team monitors that group as well as many other people using PostGIS raster.

Thanks,
Regina

hachinamio

Posts: 5
From: viet nam
Registered: 9/22/11
Re: Chapter 13 - raster
Posted: Sep 23, 2011 8:56 AM   in response to: hachinamio in response to: hachinamio
  Click to reply to this thread Reply

I wanna impost tif file. I have installed raster postgis to postgreSQL, but i still dont know how to import tif file into postgreSQL.
Thank you in advance.

regina.leo

Posts: 232
Registered: 5/6/09
Re: Chapter 13 - raster
Posted: Sep 23, 2011 9:03 AM   in response to: hachinamio in response to: hachinamio
  Click to reply to this thread Reply

Which OS are you on and which version of PostGIS are you running.

Also do you have raster support installed. You should see raster_columns table if you have raster installed.

You need python 2.5-2.7 with numpy and gdal support to load rasters
then you use the raster2pgsql.py script packaged with PostGIS.

This might help:

http://www.postgis.org/documentation/manual-svn/RT_reference.html#RT_Loading_Rasters

hachinamio

Posts: 5
From: viet nam
Registered: 9/22/11
Re: Chapter 13 - raster
Posted: Sep 29, 2011 4:23 AM   in response to: hachinamio in response to: hachinamio
  Click to reply to this thread Reply

I have raster support installed, and i can see the raster_columns table in postgreSQL
I also installed python 2.7 with numpy and GDAL.

now i try to import the raster image to the postgresql, type of image: tif ~ 50 Mb.
In the command line, i typed:
python raster2pgsql.py -r myimage.tif -t myrt -o myrt.sql
and i got the file myrt.sql in the python directory.

then,in postgreSQL, i create an database named myraster with postgis-template, ofcourse included raster support.
i try to check if myraster database supports postgis-raster. and I see 4 tables in public scheme: geometry_columns, raster_columns, raster_overviews, spatial_ref_sys.
that means myraster database already supports postgis-raster.

now I open the SQL editor and use the file myrt.sql that i got earlier, when i executed that sql code, the program becomes not response. so i have to end process pgAdmin in task manager. I tried and it happened again.

Can u show me how to fix this problem.
when i tried to do the same but with the jpg image ~ 1 mb, the sql code was executed successfully.

thank you so much.

Message was edited by:
hachinamio

regina.leo

Posts: 232
Registered: 5/6/09
Re: Chapter 13 - raster
Posted: Sep 29, 2011 6:28 AM   in response to: hachinamio in response to: hachinamio
  Click to reply to this thread Reply

BY SQL editor you mean psql or pgAdmin.

For larger sql files like the ones produced by bigger rasters, you need to use psql to load them.

hachinamio

Posts: 5
From: viet nam
Registered: 9/22/11
Re: Chapter 13 - raster
Posted: Sep 30, 2011 7:23 AM   in response to: hachinamio in response to: hachinamio
  Click to reply to this thread Reply

i used SQL editor in pgadmin III, then i opened the sql file and executed that sql code, the program became "not response".
so you mean that if i want to import the larger files like tif files , i have to use psql command line to load it?

regina.leo

Posts: 232
Registered: 5/6/09
Re: Chapter 13 - raster
Posted: Sep 30, 2011 12:55 PM   in response to: hachinamio in response to: hachinamio
  Click to reply to this thread Reply

Correct. PgAdmin wasn't designed for loading large files or binary files for that matter.

hachinamio

Posts: 5
From: viet nam
Registered: 9/22/11
Re: Chapter 13 - raster
Posted: Sep 30, 2011 7:42 PM   in response to: hachinamio in response to: hachinamio
  Click to reply to this thread Reply

ok.. what the kind of you. thanks.

Regie.A

Posts: 4
Registered: 1/22/12
Re: Chapter 13 - raster
Posted: Jan 22, 2012 8:28 AM   in response to: regina.leo in response to: regina.leo
  Click to reply to this thread Reply

Where exactly should I find the raster_columns table? I've been trying to install raster support but no luck yet.

regina.leo

Posts: 232
Registered: 5/6/09
Re: Chapter 13 - raster
Posted: Jan 22, 2012 9:16 PM   in response to: Regie.A in response to: Regie.A
  Click to reply to this thread Reply

Regie,

Which version of PostGIS are you using. PostGIS 2.0 (still not released yet), has changed quite a bit since we completed the book.

big changes since we wrote the book
1) raster_columns is now a view, not a table.
http://www.postgis.org/documentation/manual-svn/using_raster.xml.html#RT_Raster_Columns

2) There is no longer a raster2pgsql.py script. This has been replaced with an executable that doesn't require Python.
http://www.postgis.org/documentation/manual-svn/using_raster.xml.html#RT_Raster_Loader

3) The AddRasterColumns etc have been replaced with Add/DropRasterConstraints

http://www.postgis.org/documentation/manual-svn/RT_AddRasterConstraints.html
http://www.postgis.org/documentation/manual-svn/RT_DropRasterConstraints.html

The latest windows experimental builds have these changes. For other platforms you need to compile your own at least until PostGIS 2.0 is officially released.

Hope that helps,
Regina

Regie.A

Posts: 4
Registered: 1/22/12
Re: Chapter 13 - raster
Posted: Jan 28, 2012 7:12 PM   in response to: regina.leo in response to: regina.leo
  Click to reply to this thread Reply

Thanks Regina.

I was able to load the pele.png image (p. 380) and visualized in QGIS 1.7. However, I am having trouble loading in a georeferenced .tif file.

The raster options (and order) in the book are different from http://www.postgis.org/documentation/manual-svn/using_raster.xml.html#RT_Raster_Loader. For example, there is no -k option.

I've searched the internet and most (if not all) of the examples are the same as the book.

Thanks,
Regie

regina.leo

Posts: 232
Registered: 5/6/09
Re: Chapter 13 - raster
Posted: Feb 1, 2012 2:35 AM   in response to: Regie.A in response to: Regie.A
  Click to reply to this thread Reply

Regie,

The switches are quite different in the raster2pgsql since they tried to follow the shp2pgsq switches as much as possible and -k is already used for something else in shp2pgsql.

The equivalent of the old -k is -t. If you look at one of the examples in the reference. You'll see an example like this:

raster2pgsql -s 4236 -I -C -M *.tif -F -t 100x100 public.demelevation > elev.sql


Which chunks the directory of rasters to 100x100 tile size

Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff
Manning Developmental Editor