[GIS] Loading raster data to postgis

postgisrasterraster2pgsql

I'm a newbie in GIS technology and need some help in loading a rainfall radar raster data into PostGIS. The raster image is shown here:

enter image description here

What I need is to store in the database the radar reflectivity values. I supose that a previous image processing is needed, in order to extract the background and get an image with only the reflectivity pixels represented by colors. No problem with this, I can easily convert it. It uses a polar stereographic projection and I know the coordinates of the image center.

At this point, I'm wondering which is the best way to achieve this. A quick look up in google points me to use the raster2pgsql process.

My questions are:

1) Is really raster2pgsql the best tool for my purposes?

2) Could you give me some help in how to use raster2pgsql to achieve this?

3) Is there any easy way to check the projection of the image? I mean, is there any tool in which i can easily charge the image as a layer and try to match it to a projection to verify that the image projection is the expected?

Thanks in advance.

Best Answer

The biggest problem as I see it in your problem is your data, using a valid SRID, before the actual insertion. If you can achieve that using the raster2pgsql program is pretty straightforward.

raster2pgsql  -s <srid>       #The srid you chose.
              -t WIDTHxHEIGH  #Dimensions of each block that contains your data. usually, 50x50 for vector/raster analysis is good.
              -f              #Name of raster column. Usually named rast
              -I              #Create Gist index. You want this for using spatial indexes.
              -Y              #Use copy instead of insert when importing the data. Much faster. harder to debug if there are problems.

So keeping with the above, when you have your raster to import it just run

raster2pgsql -s <srid> -t 50x50 -f -I -Y myRaster.tif rasterSchema.RasterName > raster.sql`
psql -h localhost -U someuser -d mydb -f raster.sql
Related Question