april 2010 oracle spatial user conference · gdal apis for georaster • osgeo gdal is the best...

23
April 2010 Oracle Spatial User Conference

Upload: others

Post on 02-Apr-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial User Conference

Page 2: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

Orac le Spat ia l

User Conferenc e

April 29, 2010

Hyatt Regency Phoenix

Phoenix, Arizona USA

April 2010Oracle Spatial

User Conference

April 2010Oracle Spatial

User Conference

Page 3: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

Qingyun (J ef f rey) X ieSenior Manager of Software Development,Oracle Spatial

April 2010Oracle Spatial

User Conference

April 2010Oracle Spatial

User Conference

Page 4: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

GeoRast er J AVA and GDAL APIs:Overview and Applications

April 2010Oracle Spatial

User Conference

April 2010Oracle Spatial

User Conference

Page 5: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

• GeoRast er App l ic at ion Arc h i t ec t ure and APIs• GeoRast er J ava API Des ign and Over v iew• Develop ETL Tools• Develop Web Appl ic at ions• GDAL APIs for GeoRast er• Develop Im age Proc ess ing and Rast er GIS• Sum m ar y

Agenda

Page 6: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

Im ages and Rast ers in t he GeoRast er Dat abase

GeoRaster Database

Other related data/tables (RDT, VAT, etc)

Table with GeoRaster Column

...

Schema A index

Table with GeoRaster Column

...

index index

Schema B

Page 7: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

GeoRaster APIs: PL/SQL, JAVA, OCI, etc

GeoRast er Appl ic at ion Arc hi t ec t ure

Web Applications and Tools

GeoRaster Database

Oracle Fusion MiddlewareMapViewer and Web Services

Raster ETL Tools

Image Processing

Photogrammetry

Raster GIS

Enterprise Solutions

Business Intelligence

3D Digital Earth

Page 8: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

• PL/SQL API (over 150 functions)• SDO_GEOR Package • SDO_GEOR_UTL Package• SDO_GEOR_ADMIN Package

• Java API• OCI and JDBC – Open GeoRaster Data Model• MapViewer XML and Java API for GeoRaster• Third-party APIs

• OSGeo GDAL C++/C/Java/Python API• Many others

GeoRast er APIs

Page 9: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

• Chal lenge Desc r ip t ion• A c om plet e re-im plem ent at ion of GeoRast er engine is

not eas i l y doable and unnec essar y• A di rec t w rapping of eac h and ever y PL/SQL API a lone

w ould prov ide l im i t ed value• J ava Advanc ed Im aging (JAI) sc alabi l i t y and

per for m anc e issues and i t s ras t er dat a m odel

• Chal lenge Response• A c om plet e m apping of GeoRast er objec t s in pure

J ava• A sql pac k age t o reser ve t he pow er of GeoRast er

eng ine• An im age pac k age t o fu l l y leverage t he pow er of JAI

GeoRast er J ava API Design

Page 10: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

GeoRast er J ava API Arc hi t ec t ure

OracleSpat ial

GeoRasterJDBC Java

georaster: JGeoRaster JGeoRasterMeta JRaster

georaster.sql: SdoGeorPKG

georaster.image: GeoRasterImage

Raster and Image Data I /O

Extensions

Middlew are and Client

Applications

Database Server

Enhancement

GeoRaster JAVA API(3 packages)GeoRaster

Engine

Applicat ion Development

Page 11: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

GeoRast er J ava API Over v iew

• The GeoRast er J AVA API:

• orac le.spat ia l .georast er : Prov ides a c om plet e m apping of t he SDO_GEORASTER objec t t ype and i t s m et adat a t o J ava ob jec t s, and prov ides suppor t for t he c ore GeoRast er feat ures

• orac le.spat ia l .georast er.sq l : Provides a J ava w rapper o f t he GeoRast er PL/SQL API for som e ser ver-s ide operat ions

• orac le.spat ia l .georast er.im age : Provides suppor t for generat ing J ava im ages f rom a GeoRast er ob jec t and for proc essing t he im ages

• The c ore georast er pac k age and t he sq l pac k age are im plem ent ed in pure J ava. I t doesn’t depend upon J ava 2D and J AI t hus overc om es al l t he l im i t at ions f rom t hem . This a l low s us t o fu l l y suppor t GeoRast er feat ures and prov ides g reat ex t ens ib i l i t y for fu t ure enhanc em ent .

• The im age pac k age is based on J ava 2D and J AI . Th is a l low s users t o leverage t he st engt h and advanc ed c apabi l i t ies f rom J ava 2D and J AI . Users c an easi l y use i t t o develop v isua l izers and w eb appl ic at ions.

Page 12: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

//connect to the database and read a specific georaster//thru either SQL query or using connection, RDT and RIDJGeoRaster jgeor = new JGeoRaster(m_conn,rdt,new NUMBER(rid));

//query the georaster for all necessary metadata information if needed//then query a subset based on AOI or JGeometry and automatically//generate a RenderedImage for display GeoRasterImage geor_image = jgeor.getGeoRasterImageObject();

RenderedImage m_image = geor_image.getRasterImage(0,0,0,512,512);

//d isp lay t he subset im age on t he c ur rent panel

if(m_image!=null){

AffineTransform af=AffineTransform.getTranslateInstance(m_oriPixX,m_oriPixY);

((Graphics2D)m_graphics).draw RenderedImage(m_image,af);

}

Develop a GeoRast er V iew er

Page 13: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

//this pseudo-code assumes you have an I/O library for your source file format//init an empty georaster object by insert and update a georaster table//this is done thru a plsql block, which can be executed using JDBCString sqlString="declare … ";CallableStatement initGeoRaster=conn.prepareCall(sqlString);initGeoRaster.registerOutParameter(1,OracleTypes.STRUCT,"MDSYS.SDO_GEORASTER");resultSet=(OracleResultSet)initGeoRaster.executeQuery();JGeoRaster jgeor=new JGeoRaster((STRUCT)initGeoRaster.getObject(1));

//create georaster metadata based on the metadata of source raster fileJGeoRasterMeta meta = geor.getMetadataObject();

meta.init (21001, rasterSpec);

Spat ialReferenceInfo srs = jgeor.getMetadataObject ().getSpatia lReferenceInfo();

srs.setWorldFile(A,B,C,D,E,F); //only if georeferenced

srs.setModelSRID(java.lang.Inte ger(8307));

Develop a Rast er Loader

Page 14: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

//init all raster blocks with empty blobs into the georaster RDT tableJRaster jraster=jgeor.getRasterObject ();

jraster.initRDT();

//loop read all raster blocks from source file and write into the RDTfor-each-block-do-the-follow ing {

rasterBlockBlob=jraster.getRasterBlockLocator(); // BLOB loc at or for a b loc k

sourceBlockData = …; // byte array type containing all cell value of that block

jraster.storeRasterBlock(sourceBlockData, rasterBlockBlob); //w r i t e in t o RDT t able }

//set a new spatial extent if necessary or generate and set it after the georaster object is loadedJ Geom et r y spat ia lEx t ent =New J Geom et r y(…); //c om pose t he spat ia l ex t ent

jgeor.setSpatia lExtent(spat ia lExtent);

//finally store the whole georaster object with metadata into georaster table. commit and done!jgeor.storeToDB(); c onn.c om m it ();

Develop a Rast er Loader (c ont i .)

Page 15: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

//this sample assumes you use JAI to write an exportor for TIFF format//connect to the database and read a specific georaster//thru either SQL query or using connection, RDT and RIDJGeoRaster jgeor = new JGeoRaster(m_conn,rdt,new NUMBER(rid));

//directly then query the image. If needed, query thru JGeoRasterMeta for all necessary metadata//Or, depending on the file format and its I/O library you may loop query subsets and write them into//the file. Call JRaster.getRasterSubset or getRasterBlock to retrieve the raster data for non-JAI appsRenderedImage m_image = jgeor.getGeoRasterImageObject().getRasterImage(0);

//write the image into a TIFF file using JAIFi leOut put St ream out = new Fi leOut put St ream (f i leNam e);

TIFFEnc odeParam enc odeParam = new TIFFEnc odeParam ();

ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", out , encodeParam);

encoder.encode(m_image);

out .c lose();

Develop a Rast er Ex por t or

Page 16: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

GeoRast er J ava API Appl ic at ions

The GeoRast erV iew er, GeoRast erLoader, GeoRast erEx por t er c om m and-l ine t oo ls are developed us ing t he API

(Im ages c ourt esy of Off ic e of MassGIS, Com m onw eal t h of Massac huset t s Ex ec ut ive Off ic e of Envi ronm ent al Af fa i rs)

Page 17: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

MapV iew er and MapBui lder- use t he API for GeoRast er t hem es

GeoRast er J ava API Appl ic at ions (c ont i .)

(Im ages c ourt esy of PCI Geom at ic s)

Page 18: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

Sam ple Appl ic at ion Code

Some sample Java source code using this Java API are under oracle spatial demo directory in your oracle installation

Tools.java Viewer.javaLoader.java Exporter.java(Im age c ourt esy of Dig i t a lGlobe)

Page 19: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

GDAL APIs for GeoRast er

• OSGeo GDAL is t he best open sourc e geospat ia l ETL t ool /SDK for rast er dat a. I t now nat ive l y suppor t s im por t ing and ex por t ing m any for m at s , t o /f rom SDO_GEORASTER, inc lud ing GeoTIFF, J PEG2000, ECW, NITF, HDF, Net CDF, ERDAS IMG, USGS DEM, SPOT, et c .

• GDAL is w r i t t en in C++, and r uns ver y fast and suppor t s large im age f i les

• Prov ides m any proc essing t ools for GeoRast er :• gdal_t rans lat e, gdal_w ar p, gdal_m erge• gdal_g r id , gdal_rast er ize, et c .

• Prov ides C, C++, J ava, C#, Pyt hon, Per l and Ruby APIs for ac c ess ing and proc essing GeoRast er objec t s

Page 20: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

Sam ple Use of GDAL C API

/* In i t ia l ize GDAL dr ivers; Ac c ess an GeoRast er and c reat e a GDAL Dat aset on t ha t GeoRast er ob jec t * /GDALAllRegister();GDALDatasetH hDataset = GDALOpen("geor:scott /t iger@orcl,gdal_rdt ,127", GA_ReadOnly);

/* re t r ieve m et adat a in form at ion f rom t he GeoRast er Dat aset * /int nBandCount = GDALGetRasterCount(hDataset);const char* sWKT = GDALGetProject ionRef(hDataset );

/* re t r ieve a rast er Band f rom t he GeoRast er Dat aset * /GDALRasterBandH hBand = GDALGetRasterBand(hDataset ,1);

/* Get m et adat a in form at ion f rom t he Band* /int nColumns = GDALGetRasterBandXSize(hBand);int nRow s = GDALGetRasterBandYSize(hBand);

/* s t ar t proc essing t he band or t he w hole im age, and w r i t e t he resu l t s in t o a f i le or anot her georast er* /……

/* f in ish ing up* /GDALClose(hDataset ); GDALDestroyDriverManager();return (EXIT_SUCCESS);

Page 21: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference

April 2010

Oracle Spatial

User Conference

Develop Im age Proc ess ing and Rast er GIS Appl ic at ions

(sc reenshot s c our t esy of Geospat ia l Sof t w are In t egra t ion LLC)

OSGeo Quant um GIS, GRASS, OSSIM and MapServer are in t egrat ed w i t h GeoRast er us ing t he GDAL API

Page 22: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

AQ&April 2010

Oracle SpatialUser Conference

April 2010Oracle Spatial

User Conference

Page 23: April 2010 Oracle Spatial User Conference · GDAL APIs for GeoRaster • OSGeo GDAL is the best open source geospatial ETL tool/SDK for raster data. It now natively supports importing

April 2010

Oracle Spatial

User Conference