orbisgis / h2gis

A spatial extension of the H2 database.
http://www.h2gis.org
GNU Lesser General Public License v3.0
208 stars 63 forks source link

H2 native raster functions #586

Open nicolas-f opened 9 years ago

nicolas-f commented 9 years ago
ebocher commented 9 years ago

ST_ImageFromRaster must detect the format suffix no ?

nicolas-f commented 9 years ago

The format of Raster is WKB Raster. This function must translate into another format, defined by the user.

ebocher commented 9 years ago

So this functions is used to convert ?

nicolas-f commented 9 years ago

Yes this is the inverse of ST_RasterFromImage. So you should call something like that:

SELECT ST_ImageFromRaster(ST_RASTERFROMIMAGE(FILE_READ('/home/user/aerial.png'), 150, 200, 1, 1, 0, 0, 4326), 'bmp') bmpData;
ebocher commented 9 years ago

Perfect

nicolas-f commented 8 years ago

Added ImageIO drivers

nicolas-f commented 8 years ago

Added ST_ImageFromRaster

nicolas-f commented 8 years ago

Maybe implement FILE_WRITE( lob, String ), to write image obtained through ImageFromRaster ?

ebocher commented 8 years ago

Yes you are right

nicolas-f commented 8 years ago

Add ST_MakeEmptyRaster

nicolas-f commented 8 years ago

Raster.toString() is converted into human readable metadata: w:10 h:10 bands:3 srid:27572 x:0.00000 y:0.00000 scalex:1.00000 scaley:-1.00000 skewx:0.00000 skewy:0.00000

gpetit commented 8 years ago

@nicolas-f Maybe its more clear to write ST_MakeEmptyRaster ?

nicolas-f commented 8 years ago

ok..

nicolas-f commented 8 years ago

Add ST_BandMetaData

nicolas-f commented 8 years ago

Currently WKB Image parsing is slow because there is absolutely no pixel cache. Here a sample of what is done currently:

I want RGB of pixel 500 red = Blob.getInputStream().skip(adressOfRedBandPixelZero) green = stream.skip(adressOfGreenPixelZero) blue = stream.skip(adressOfBluePixelZero)

I want RGB of Pixel 501 The problem here is the stream is in the blue band area. We have to reopen the stream and skip to the red band for pixel 501.

One solution

The class WKBRasterDataBuffer should cache the bands values for a row. The goal is to reset the minimum of times the stream and reduce the seek amount.

nicolas-f commented 8 years ago

Add ST_WorldToRasterCoord ST_WorldToRasterCoordX ST_WorldToRasterCoordY

ebocher commented 8 years ago

To be consistent with geometry drivers, ST_RasterFromFile function will be renamed by ST_WorldFileImageRead (eg SHPRead) and a new function ST_WorldFileImageWrite will be added.

ebocher commented 8 years ago

Note : I don't want to use raster because it's a type (a category of datatype) and not a format like worldfile, geotiff.

nicolas-f commented 8 years ago

what about ST_RasterFromWorldFile ?

ebocher commented 8 years ago

No because we must also write st_geometryfromfile ;-)

ebocher commented 8 years ago

ST_WorldFileImageWrite will have the following signature

ST_WorldFileImageWrite(RASTER, '/tmp/toto.png')

Usages

SELECT ST_WorldFileImageWrite(the_raster, '/tmp/toto.png') from myRasterTable limit 1;
SELECT ST_WorldFileImageWrite(the_raster,concat( concat( '/tmp/toto_', pkValue), '.png')) from myRasterTable;
gpetit commented 6 years ago

@nico any input about this feature ? We are looking forward using raster in H2GIS ;-)

ebocher commented 6 years ago

Note : The TIFF format will be integrated in JAVA 9 http://openjdk.java.net/jeps/262

nicolas-f commented 6 years ago

Nice.

@gpetit I've merged the raster branch with the last h2 update. I have to write documentation and then create a pull request to h2 database.

ebocher commented 6 years ago

+1 We can help you to write the documentation.

nicolas-f commented 6 years ago

The branch is here https://github.com/nicolas-f/h2database/tree/georaster_patch

Off db raster is still not supported yet. But band metadata can already store the path of the external image.

ebocher commented 6 years ago

Add a unit test ? SELECT FILE_WRITE(ST_IMAGEFROMRASTER(data, 'png'), '/tmp/test.png') FROM test @nicolas-f

ebocher commented 6 years ago

Test done

ebocher commented 6 years ago

A good day https://github.com/h2database/h2database/pull/945