[postgis-users] Importing tiles in PostGIS raster

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Thu Aug 18 06:11:24 PDT 2011


To load many raster at the same time use the * wildcard. E.g. raster2pgsql.py -r c:/yourfolder/*.jpg

To georeference your tiles properly, you could use the -F raster2pgsql option to create a new column with the original filename and then use string functions to extract the upper left X an upper left Y and set them in the raster. If your X and Y coordinates are encoded on three digits you could do something like:

UPDATE yourrasttable SET rast =  ST_SetUpperLeft(rast, substring(filename, 1, 3)::float4, substring(filename, 5, 3)::float4)

You can also set the pixel size at the same time:

UPDATE yourrasttable SET rast =  ST_SetUpperLeft(ST_SetScale(rast, 0.34256), substring(filename, 1, 3)::float4, substring(filename, 5, 3)::float4)

Hope this help,

Pierre

> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-
> bounces at postgis.refractions.net] On Behalf Of Knut Krause
> Sent: Thursday, August 18, 2011 4:58 AM
> To: postgis-users at postgis.refractions.net
> Subject: [postgis-users] Importing tiles in PostGIS raster
> 
> Hi,
> 
> I want to import a raster image in PostGIS. Now my raster image is already split
> into tiles and I can't see how I can handle those images with raster2pgsql.py.
> Currently the filenames are x_y.jpg where x and y refer to the coordinate of the
> upper left corner. How can I import those images using the correct coordinates?
> All examples just mention the SRID and no positions.
> 
> Would be great if someone has experience with that.
> 
> Regards
> 
> 
> Knut



More information about the postgis-users mailing list