Opened 10 years ago

Closed 10 years ago

Last modified 4 years ago

#895 closed patch (invalid)

[raster]: FV.01 functions

Reported by: Bborie Park Owned by: Bborie Park
Priority: medium Milestone: PostGIS Fund Me
Component: raster Version: main
Keywords: Cc: jorge.arevalo@…

Description

Well, I believe I've completed the functions for FV.01. The following functions have been added:

ST_Band(rast raster, bandnums int[])

ST_AsGDALRaster(rast raster, format text, options text[], srs text)

ST_AsTiff(rast raster, options text[], srs text)

ST_AsPNG(rast raster, options text[], srs text)

ST_AsJPEG(rast raster, options text[], srs text)

Each of the above have several variations.

I've also added two ancillary function:

ST_getGDALDrivers()

for getting available and usable GDAL drivers on the server

ST_srtext(rast raster)

A bunch of the functions needed to get a spatial reference's srtext/proj4text to pass to the GDAL raster, so this function was written.

I've added test cases to both test/core and test/regress though I think the test cases could be built upon.

As my C skills were definitely rusty when I started this, please feel free to correct my errors and more importantly, let me know what they are. I will admit, the code was easy to understand and well documented!

Oh, I did make one tweak to raster/scripts/python/Makefile.in to accept the variable DESTDIR for when building packages.

-bborie

Attachments (1)

FV.01.patch (62.8 KB) - added by Bborie Park 10 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 10 years ago by robe

Component: postgispostgis raster
Owner: changed from pramsey to pracine
Summary: FV.01 functions[raster]: FV.01 functions

comment:2 Changed 10 years ago by Bborie Park

I need to do some more work on ST_AsJPEG and ST_AsPNG to add more checks due to various format limitations and add a method to specify band numbers. Hopefully, I'll have the changes done on Friday.

comment:3 Changed 10 years ago by pracine

Some questions:

-Would it not be more useful to provide PostGIS users with flexible but more user friendly parameters for Tiff, JPEG, and PNG so that we don't have to copy or refer to the GDAL doc? It would be our job to wrap those to the option strings provided to _st_asgdalraster(). We could provide both the wrapped ones and the generic ones (in case our wrapped one are not yet aligned to GDAL or we do not provide a very specific option).

-How will 1, 2, 4 or more band rasters be converted to JPEG and/or PNG?

-What is the use of the "srs text" parameter?

comment:4 in reply to:  3 Changed 10 years ago by Bborie Park

Replying to pracine:

Some questions:

-Would it not be more useful to provide PostGIS users with flexible but more user friendly parameters for Tiff, JPEG, and PNG so that we don't have to copy or refer to the GDAL doc? It would be our job to wrap those to the option strings provided to _st_asgdalraster(). We could provide both the wrapped ones and the generic ones (in case our wrapped one are not yet aligned to GDAL or we do not provide a very specific option).

Yes, you are correct. I plan on writing the appropriate ST_AsPNG, ST_AsJPEG and ST_AsTIFF variations today and over the weekend. Most of the ones I've written thus far are generic and meant to provide a raw interface.

-How will 1, 2, 4 or more band rasters be converted to JPEG and/or PNG?

I know that 1 and 3 band rasters work fine. I'm thinking of raising a notice for rasters with 2, 4 or more bands and only using the first band.

-What is the use of the "srs text" parameter?

I couldn't find a way to get the srtext (or proj4text if srtext isn't available) in rt_pg.c for a raster's srid to embed as the GDAL raster's srs. GeoTIFF does support this while PNG and JPEG do not. If there is a correct way to get the srtext from rt_pg.c, please let me know.

comment:5 Changed 10 years ago by pracine

It would also probably nice and more standard with other functions to have some variants enabling to specify the band to convert directly in the functions instead of having to use ST_Band():

ST_AsTiff(rast raster, bands[], options text[], srs text)

But it's nice to have ST_Band() as well.

comment:6 Changed 10 years ago by Bborie Park

I'll add the bands parameter as I expand the function set.

comment:7 Changed 10 years ago by Bborie Park

I'd like some feedback on the TIFF, PNG, and JPEG ST_AsXXX functions. I've already implemented the most generic functions but and particularly interested in opinions regarding the "compression" and "bands" arguments.

Are there any other function parameters that should be considered?

-- ST_AsTIFF
ST_AsTIFF(rast raster)
ST_AsTIFF(rast raster, options text[])
ST_AsTIFF(rast raster, options text[], srs text)

ST_AsTIFF(rast raster, bands int[])
ST_AsTIFF(rast raster, bands int[], options text[])
ST_AsTIFF(rast raster, bands int[], options text[], srs text)

ST_AsTIFF(rast raster, compression text) /* e.g. DEFLATE9 or JPEG75 */
ST_AsTIFF(rast raster, compression text, srs text)
ST_AsTIFF(rast raster, bands int[], compression text)
ST_AsTIFF(rast raster, bands int[], compression text, srs text)

-- ST_AsJPEG
ST_AsJPEG(rast raster)
ST_AsJPEG(rast raster, options text[])

ST_AsJPEG(rast raster, bands int[])
ST_AsJPEG(rast raster, bands int[], options text[])

ST_AsJPEG(rast raster, compression int)
ST_AsJPEG(rast raster, bands int[], compression int)

-- ST_AsPNG
ST_AsPNG(rast raster)
ST_AsPNG(rast raster, options text[])

ST_AsPNG(rast raster, bands int[])
ST_AsPNG(rast raster, bands int[], options text[])

ST_AsPNG(rast raster, compression int)
ST_AsPNG(rast raster, bands int[], compression int)

comment:8 Changed 10 years ago by Bborie Park

In the latest patch, I've dramatically expanded on the ST_AsTIFF, ST_AsJPEG and ST_AsPNG functions. I've created functions for:

-- ST_AsTIFF
ST_AsTIFF(rast raster)
ST_AsTIFF(rast raster, options text[])
ST_AsTIFF(rast raster, options text[], srs text)

ST_AsTIFF(rast raster, bands int[])
ST_AsTIFF(rast raster, bands int[], options text[])
ST_AsTIFF(rast raster, bands int[], options text[], srs text)

ST_AsTIFF(rast raster, compression text)
ST_AsTIFF(rast raster, compression text, options text[])
ST_AsTIFF(rast raster, compression text, options text[], srs text)

ST_AsTIFF(rast raster, bands int[], compression text)
ST_AsTIFF(rast raster, bands int[], compression text, options text[])
ST_AsTIFF(rast raster, bands int[], compression text, options text[], srs text)

-- ST_AsJPEG
ST_AsJPEG(rast raster)
ST_AsJPEG(rast raster, options text[])

ST_AsJPEG(rast raster, bands int[])
ST_AsJPEG(rast raster, bands int[], options text[])

ST_AsJPEG(rast raster, compression int)
ST_AsJPEG(rast raster, compression int, options text[])

ST_AsJPEG(rast raster, bands int[], compression int)
ST_AsJPEG(rast raster, bands int[], compression int, options text[])

-- ST_AsPNG
ST_AsPNG(rast raster)
ST_AsPNG(rast raster, options text[])

ST_AsPNG(rast raster, bands int[])
ST_AsPNG(rast raster, bands int[], options text[])

ST_AsPNG(rast raster, compression int)
ST_AsPNG(rast raster, compression int, options text[])

ST_AsPNG(rast raster, bands int[], compression int)
ST_AsPNG(rast raster, bands int[], compression int, options text[])

Changed 10 years ago by Bborie Park

Attachment: FV.01.patch added

comment:9 Changed 10 years ago by Bborie Park

Owner: changed from pracine to Bborie Park

comment:10 Changed 10 years ago by Bborie Park

Resolution: invalid
Status: newclosed

The functions comprised in FV.01 has been processed in individual tickets for each key function. As such, this ticket is closed.

comment:11 Changed 10 years ago by Bborie Park

Refer to the following tickets and associated patches for the functions of FV.01.

#339 ST_Band

#902 ST_MinMax and ST_ApproxMinMax

#903 ST_Reclass

#901 ST_AsGDALRaster, ST_getGDALDrivers and ST_srtext

#341 ST_AsTIFF

#340 ST_AsJPEG

#342 ST_AsPNG

comment:12 Changed 9 years ago by pracine

Milestone: PostGIS Raster FuturePostGIS Future

comment:13 Changed 4 years ago by robe

Milestone: PostGIS FuturePostGIS Fund Me

Milestone renamed

Note: See TracTickets for help on using tickets.