Opened 12 years ago

Last modified 10 years ago

#1293 closed enhancement

[raster] ST_Resize to resize raster tiles — at Version 6

Reported by: robe Owned by: pracine
Priority: medium Milestone: PostGIS 2.1.0
Component: raster Version: master
Keywords: history Cc:

Description (last modified by pracine)

Bborie,

I'm ticketing what we discussed. As mentioned, it would be nice to have a resize function that provides the similar functionality to gdal_translate that can take a percentage reduction or max pixel dimensions.

e.g.

what gdal_translate:

gdal_translate -of png -outsize 25% 25% original.png final.png
gdal_translate -of png -outsize 500 500 original.png final.png

Currently have to use ST_Resample for this which requires a lot more arguments, not to mention it doesn't seem to work for rasters with no srid information.

I'm envisioning the signature would look something like

ST_Resize(rast raster, width text, height text)

where width can be a numeric like '500' or can be a percentage like '50%' which is why I made it text.

This will make postgis raster useful for both GIS folks and non-GIS folks as having an easy function to resize a raster will speed up all kinds of analysis. Like I mentioned, my selfish need is that most of my raster projects do not involve objects that fit in a nice spatial reference landscape but the analysis functions we've got so far I'm finding very useful for those (e.g. image recognition, and just plotting and vectorizing non-GIS like things like anatomic parts, or construction objects)

Change History (6)

comment:1 by pracine, 12 years ago

what would be the difference with ST_Rescale()?

comment:2 by Bborie Park, 12 years ago

ST_Resize would use the same underlying function calls as gdal_translate. ST_Rescale (ST_Resample) makes use the of the same underlying function call as gdalwarp. To use ST_Resample, the raster must have a SRID. I ran some basic tests on random pictures I had lying around (no spatial reference) using gdalwarp (to test for behavior) and as expected returned an error.

By the looks of it, gdal_translate will resize any image for you regardless of spatial reference.

So for one of my random pictures

gdal_translate -of png outsize 25% 25% 0884Parkfl\ copy.jpg TEST.PNG

gdal_translate works.

gdalwarp -ts 1000 1000 0884Parkfl\ copy.jpg test.tif

gdalwarp doesn't. Error given is:

ERROR 1: Unable to compute a transformation between pixel/line
and georeferenced coordinates for 0884Parkfl copy.jpg.
There is no affine transformation and no GCPs.

comment:3 by bnordgren, 12 years ago

This still seems like a valid tool request. The requirements would be:

# ignore the affine transform if there is no SRID # "adjust" the affine transform to correctly map pixel indices to geopoints after the pixels have been resized (if an SRID is present).

Does gdal_translate perform function #2 if given a georeferenced image? Perhaps it would point to a set of function calls which allow us a greater degree of control over the data type?

comment:4 by bnordgren, 12 years ago

Argh! I used redmine wiki formatting by mistake. Function #2 is the "adjusting" of the affine transform…

comment:5 by Bborie Park, 12 years ago

Summary: ST_Resize to resize raster tiles[raster] ST_Resize to resize raster tiles

comment:6 by pracine, 12 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.