W W W. R E F R A C T I O N S. N E T Tips for the PostGIS Power User.

Slides:



Advertisements
Similar presentations
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Advertisements

XIr2 Recommended Performance Tuning Andy Erthal BI Practice Manager.
Adam Jorgensen Pragmatic Works Performance Optimization in SQL Server Analysis Services 2008.
ASP.NET Best Practices Dawit Wubshet Park University.
Big Data Working with Terabytes in SQL Server Andrew Novick
CS 540 Database Management Systems
Spatial Data Mining. 2 Introduction Spatial data mining is the process of discovering interesting, useful, non-trivial patterns from large spatial datasets.
Query Processing in Databases Dr. M. Gavrilova.  Introduction  I/O algorithms for large databases  Complex geometric operations in graphical querying.
Database Systems: A Practical Approach to Design, Implementation and Management International Computer Science S. Carolyn Begg, Thomas Connolly Lecture.
Spatial Information Systems (SIS) COMP Spatial access methods: Indexing.
Oracle spatial – Creating spatial tables Object Relational Model Creating Spatial Tables.
Physical Database Monitoring and Tuning the Operational System.
OpenSource GIS 2004 Ottawa, Canada Introduction to PostGIS PostGIS Basics for the New User Paul Ramsey & Chris Hodgson Refractions.
Geographic Information Systems and Science SECOND EDITION Paul A. Longley, Michael F. Goodchild, David J. Maguire, David W. Rhind © 2005 John Wiley and.
Object Relational Model Creating Spatial Tables. Concepts Describe the schema associated with a spatial layer Explain how spatial data is stored using.
Troubleshooting SQL Server Enterprise Geodatabase Performance Issues
PostgreSQL and relational databases As well as assignment 4…
Spatial Database Souhad Daraghma.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
Physical Database Design Chapter 6. Physical Design and implementation 1.Translate global logical data model for target DBMS  1.1Design base relations.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Creating High Performance Spatial Databases with SQL Server 2008 Alastair Aitchison.
PostgreSQL and relational databases As well as assignment 4…
6. Simple Features Specification Background information UML overview Simple features geometry.
Chapter 16 Methodology – Physical Database Design for Relational Databases.
DANIEL J. ABADI, ADAM MARCUS, SAMUEL R. MADDEN, AND KATE HOLLENBACH THE VLDB JOURNAL. SW-Store: a vertically partitioned DBMS for Semantic Web data.
PostGIS and Spatial Queries Steve Signell, Instructor Robert Poirier, TA School of Science Rensselaer Polytechnic Institute.
SQL access and working with ST_Geometry Functions
PostGIS Tips for Power Users
Chapter 16 Practical Database Design and Tuning Copyright © 2004 Pearson Education, Inc.
10/10/2012ISC239 Isabelle Bichindaritz1 Physical Database Design.
PostGIS and Spatial Queries Steve Signell, Instructor Robert Poirier, TA School of Science Rensselaer Polytechnic Institute.
Creating and Maintaining Geographic Databases. Outline Definitions Characteristics of DBMS Types of database Relational model SQL Spatial databases.
Data Types Lesson 4. Skills Matrix Table A table stores your data. Tables are relational in that they are organized as rows and columns (a matrix). Each.
ESRI User Conference 2004 ArcSDE. Some Nuggets Setup Performance Distribution Geodatabase History.
Methodology – Physical Database Design for Relational Databases.
Intro to GIS | Summer 2012 Attribute Tables – Part 1.
Praveen Srivatsa Director| AstrhaSoft Consulting blogs.asthrasoft.com/praveens |
Benjamin Post Cole Kelleher.  Availability  Data must maintain a specified level of availability to the users  Performance  Database requests must.
Lec 7 Practical Database Design and Tuning Copyright © 2004 Pearson Education, Inc.
Relational Operator Evaluation. Overview Application Programmer (e.g., business analyst, Data architect) Sophisticated Application Programmer (e.g.,
Database technology Introduction ER Modeling Database objects (intro) SQL.
1 Overview of Query Evaluation Chapter Outline  Query Optimization Overview  Algorithm for Relational Operations.
Copyright Sammamish Software Services All rights reserved. 1 Prog 140  SQL Server Performance Monitoring and Tuning.
Understanding Core Database Concepts Lesson 1. Objectives.
Introduction to Partitioning in SQL Server
Spatial Data Management
Trigger used in PosgreSQL
PostGIS and Spatial Queries
PostGIS and Spatial Queries
Practical Database Design and Tuning
Indexes By Adrienne Watt.
Hitting the SQL Server “Go Faster” Button
UFC #1433 In-Memory tables 2014 vs 2016
Chapter 25: Advanced Data Types and New Applications
Physical Structure of GDB
Hash-Based Indexes Chapter 11
Chapter 12: Query Processing
Introduction to PostGIS
Database Performance Tuning and Query Optimization
Hitting the SQL Server “Go Faster” Button
© Copyright TIBCO Software Inc.
Introdução to Geoinformatics: vector geometries
Practical Database Design and Tuning
Hash-Based Indexes Chapter 10
Database Design and Programming
Chapter 11 Database Performance Tuning and Query Optimization
CPSC-608 Database Systems
Chapter 11 Instructor: Xin Zhang
Understanding Core Database Concepts
Presentation transcript:

W W W. R E F R A C T I O N S. N E T Tips for the PostGIS Power User

W W W. R E F R A C T I O N S. N E TTopics PostGIS functions –Geometry constructors / deconstructors accessors / spatial predicates –Walk through a few examples. DE-9IM –Fine-tuning spatial predicates PostgreSQL –Table inheritance / partitioning –Database tuning

W W W. R E F R A C T I O N S. N E TIntroduction What is PostGIS? –A PostgreSQL database extension that "spatially enables" the server back-end to support the storage of geometric objects in an object-relational PostgreSQL database. –

W W W. R E F R A C T I O N S. N E TIntroduction Geometry Constructors –ST_GeomFromText(text) –ST_GeomFromWKB(bytea) –Creates a geometry data type in EPSG:3005 projection SELECT ST_GeomFromText( ‘POINT( )’, 3005 );

W W W. R E F R A C T I O N S. N E T SELECT geom FROM gps_point_data SELECT geom FROM gps_point_data Introduction SELECT geom FROM gps_point_data WHERE time_stamp::date = ‘ ’::date SELECT geom FROM gps_point_data WHERE time_stamp::date = ‘ ’::date ORDER BY time_stamp SELECT ST_MakeLine(gps_points.geom) FROM (SELECT geom FROM gps_point_data WHERE time_stamp::date = ‘ ’::date ORDER BY time_stamp ) AS gps_points; SELECT ST_MakeLine(gps_points.geom) FROM (SELECT geom FROM gps_point_data WHERE time_stamp::date = ‘ ’::date ORDER BY time_stamp ) AS gps_points; Geometry Constructors

W W W. R E F R A C T I O N S. N E TIntroduction Geometry Constructors –ST_BuildArea() SELECT ST_BuildArea(ST_Collect(geom)) FROM... SELECT ST_BuildArea(ST_Collect(geom)) FROM...

W W W. R E F R A C T I O N S. N E TIntroduction Geometry Accessors / Deconstructors –ST_StartPoint() –ST_PointN(geometry, int) –ST_ExteriorRing(geometry) SELECT ST_StartPoint(geom) FROM my_lines; SELECT ST_StartPoint(geom) FROM my_lines;

W W W. R E F R A C T I O N S. N E TIntroduction Geometry Accessors / Deconstructors Caution: GROUP BY uses a geometry’s bounding box ! SELECT ST_StartPoint(geom) AS point FROM my_lines SELECT ST_StartPoint(geom) AS point FROM my_lines UNION ALL SELECT ST_EndPoint(geom) AS point FROM my_lines SELECT point FROM (SELECT ST_StartPoint(geom) AS point FROM my_lines UNION ALL SELECT ST_EndPoint(geom) AS point FROM my_lines) AS a GROUP BY point HAVING count(*) = 4; SELECT point FROM (SELECT ST_StartPoint(geom) AS point FROM my_lines UNION ALL SELECT ST_EndPoint(geom) AS point FROM my_lines) AS a GROUP BY point HAVING count(*) = 4;

W W W. R E F R A C T I O N S. N E TIntroduction Geometry Accessors / Deconstructors –How to explode a MULTI* table SELECT ST_GeometryN( geom, 1 ) FROM my_multilines; SELECT generate_series( 1, 5 ); generate_series (5 rows) generate_series (5 rows) SELECT ST_GeometryN(geom, generate_series(1, ST_NumGeometries(geom))) AS geom FROM my_multilines SELECT ST_GeometryN(geom, generate_series(1, ST_NumGeometries(geom))) AS geom FROM my_multilines SELECT ST_GeometryN(geom, generate_series(1, ST_NumGeometries(geom))) AS geom FROM my_multilines CREATE TABLE my_lines AS SELECT geom FROM (SELECT ST_GeometryN(geom, generate_series(1, ST_NumGeometries(geom))) AS geom FROM my_multilines ) AS foo;

W W W. R E F R A C T I O N S. N E T Geometry Accessors / Deconstructors –How to explode a MULTI* table generate_series (5 rows) generate_series (5 rows) CREATE TABLE my_lines AS SELECT geom FROM (SELECT ST_GeometryN(geom, generate_series(1, ST_NumGeometries(geom))) AS geom FROM my_multilines ) AS foo; CREATE TABLE my_lines AS SELECT geom FROM (SELECT ST_GeometryN(geom, generate_series(1, ST_NumGeometries(geom))) AS geom FROM my_multilines ) AS foo; CREATE TABLE my_lines AS SELECT ((ST_Dump(geom)).geom FROM my_multilines; Introduction SELECT ST_GeometryN( geom, 1 ) FROM my_multilines; SELECT generate_series( 1, 5 );

W W W. R E F R A C T I O N S. N E TIntroduction Geometry Spatial Predicates / Functions –ST_Intersects() –ST_Within() –ST_Touches() –ST_GeomUnion() –ST_SymmetricDifference() –ST_ConvexHull() –…

W W W. R E F R A C T I O N S. N E T SELECT ST_Intersection(a.geom, ST_Buffer(b.geom, 20)) FROM streams a, logging b WHERE a.geom && ST_Buffer(b.geom, 20) AND ST_Intersects(a.geom, ST_Buffer(b.geom, 20)) SELECT ST_Intersection(a.geom, ST_Buffer(b.geom, 20)) FROM streams a, logging b WHERE a.geom && ST_Buffer(b.geom, 20) AND ST_Intersects(a.geom, ST_Buffer(b.geom, 20)) Sample PostGIS Queries 1.Identify the locations where clearcut logging occurs closer than 20m to a stream or river. SELECT ST_Intersection(a.geom, ST_Buffer(b.geom, 20)) FROM streams a, logging b WHERE a.geom && ST_Buffer(b.geom, 20) AND ST_Intersects(a.geom, ST_Buffer(b.geom, 20)) SELECT ST_Intersection(a.geom, ST_Buffer(b.geom, 20)) FROM streams a, logging b WHERE a.geom && ST_Expand(b.geom, 20) AND ST_Intersects(a.geom, ST_Buffer(b.geom, 20)) SELECT ST_Intersection(a.geom, ST_Buffer(b.geom, 20)) FROM streams a, logging b WHERE a.geom && ST_Expand(b.geom, 20) AND ST_Intersects(a.geom, ST_Buffer(b.geom, 20)) SELECT ST_Intersection(a.geom, ST_Buffer(b.geom, 20)) FROM streams a, logging b WHERE a.geom && ST_Expand(b.geom, 20) AND ST_Distance(a.geom, b.geom) <= 20 SELECT ST_Intersection(a.geom, ST_Buffer(b.geom, 20)) FROM streams a, logging b WHERE a.geom && ST_Expand(b.geom, 20) AND ST_Distance(a.geom, b.geom) <= 20 SELECT ST_Intersection(a.geom, ST_Buffer(b.geom, 20)) FROM streams a, logging b WHERE ST_DWithin(a.geom, b.geom, 20)

W W W. R E F R A C T I O N S. N E T Sample PostGIS Queries 2.What is the average elevation of a lake digitized in 3D? SELECT avg(ST_Z(ST_PointN(ring, generate_series(1, ST_NumPoints(ring)) ) FROM ( SELECT ST_ExteriorRing(geom) AS ring FROM lakes WHERE lake_id = 1 UNION ALL SELECT ST_InteriorRingN(geom, generate_series(1, ST_NumInteriorRings(geom)) ) AS ring FROM lakes WHERE lake_id = 1 ) AS foo SELECT avg(ST_Z(ST_PointN(ring, generate_series(1, ST_NumPoints(ring)) ) FROM ( SELECT ST_ExteriorRing(geom) AS ring FROM lakes WHERE lake_id = 1 UNION ALL SELECT ST_InteriorRingN(geom, generate_series(1, ST_NumInteriorRings(geom)) ) AS ring FROM lakes WHERE lake_id = 1 ) AS foo SELECT avg(ST_Z(ST_PointN(ring, generate_series(1, ST_NumPoints(ring)) ) FROM ( SELECT ST_ExteriorRing(geom) AS ring FROM lakes WHERE lake_id = 1 UNION ALL SELECT ST_InteriorRingN(geom, generate_series(1, ST_NumInteriorRings(geom)) ) AS ring FROM lakes WHERE lake_id = 1 ) AS foo SELECT avg(ST_Z(ST_PointN(ring, generate_series(1, ST_NumPoints(ring)) ) FROM ( SELECT ST_ExteriorRing(geom) AS ring FROM lakes WHERE lake_id = 1 UNION ALL SELECT ST_InteriorRingN(geom, generate_series(1, ST_NumInteriorRings(geom)) ) AS ring FROM lakes WHERE lake_id = 1 ) AS foo SELECT avg(ST_Z(ST_PointN(ring, generate_series(1, ST_NumPoints(ring)) ) FROM ( SELECT ST_ExteriorRing(geom) AS ring FROM lakes WHERE lake_id = 1 UNION ALL SELECT ST_InteriorRingN(geom, generate_series(1, ST_NumInteriorRings(geom)) ) AS ring FROM lakes WHERE lake_id = 1 ) AS foo

W W W. R E F R A C T I O N S. N E T Sample PostGIS Queries 3.Efficiently, union a set of polygons. SELECT ST_Union(the_geom) FROM... (takes ~16.7 seconds) SELECT ST_Union(the_geom) FROM... (takes ~16.7 seconds) SELECT ST_Buffer(ST_Collect(geom), 0.0) FROM... (takes ~4.1 seconds) SELECT ST_Buffer(ST_Collect(geom), 0.0) FROM... (takes ~4.1 seconds) Bighorn Creek

W W W. R E F R A C T I O N S. N E T ST_Within? ST_Intersects? ST_Touches? Sample PostGIS Queries 4.Find all docks that are contained completely within a lake, not touching a lake bank. What PostGIS functions would you use?

W W W. R E F R A C T I O N S. N E T DE-9IM The Dimensionally Extended – Nine Intersection Model Approach –make pair-wise tests of the intersections between the Interiors, Boundaries, and Exteriors of two geometries and to represent these relationships in an “intersection” matrix

W W W. R E F R A C T I O N S. N E T DE-9IM The Dimensionally Extended – Nine Intersection Model Possible values: {T, F, *, 0, 1, 2} InteriorBoundaryExterior Interiordim( I(a) ∩ I(b) )dim( I(a) ∩ B(b) )dim( I(a) ∩ E(b) ) Boundarydim( B(a) ∩ I(b) )dim( B(a) ∩ B(b) )dim( B(a) ∩ E(b) ) Exteriordim( E(a) ∩ I(b) )dim( E(a) ∩ B(b) )dim( E(a) ∩ E(b) ) Where: T == {0,1,2} F == empty set * == don’t care 0 == dimensional 0 – point 1 == dimensional 1 – line 2 == dimensional 2 - area

W W W. R E F R A C T I O N S. N E T DE-9IM The Dimensionally Extended – Nine Intersection Model Geometry Topology Boundary –the set of geometries of the next lower dimension Point (dim-0) Line (dim-1) Polygon (dim-2)

W W W. R E F R A C T I O N S. N E T DE-9IM The Dimensionally Extended – Nine Intersection Model Geometry Topology Interior –the points that are left when the boundary points are removed Point (dim-0) Line (dim-1) Polygon (dim-2)

W W W. R E F R A C T I O N S. N E T DE-9IM The Dimensionally Extended – Nine Intersection Model Geometry Topology Exterior –consists of points not in the interior and boundary Point (dim-0) Line (dim-1) Polygon (dim-2)

W W W. R E F R A C T I O N S. N E T DE-9IM The Dimensionally Extended – Nine Intersection Model InteriorBoundaryExterior Interior Boundary Exterior (a) (b) ST_Relate(a, b) = ‘ ’

W W W. R E F R A C T I O N S. N E T Sample PostGIS Queries 3.Find all docks that are contained completely within a lake, not touching a lake bank. SELECT a.id FROM docks a, lakes b WHERE a.geom && b.geom AND ST_Relate(a.geom, b.geom, ‘ ’); SELECT a.id FROM docks a, lakes b WHERE a.geom && b.geom AND ST_Relate(a.geom, b.geom, ‘TFF ’); SELECT a.id FROM docks a, lakes b WHERE a.geom && b.geom AND ST_Relate(a.geom, b.geom, ‘TFFTFF ’); SELECT a.id FROM docks a, lakes b WHERE a.geom && b.geom AND ST_Relate(a.geom, b.geom, ‘TFFTFF212’); SELECT a.id FROM docks a, lakes b WHERE a.geom && b.geom AND ST_Relate(a.geom, b.geom, ‘TFFTFF212’); SELECT a.id FROM docks a, lakes b WHERE a.geom && b.geom AND ST_Relate(a.geom, b.geom, ‘TFFTFF212’);

W W W. R E F R A C T I O N S. N E T Sample PostGIS Queries 4.Identify linear spatial features that intersect on a line and not at a point. SELECT a.id FROM mylines a, mylines b WHERE a.id != b.id AND a.geom && b.geom AND ST_Relate(a.geom, b.geom, ‘ ’); SELECT a.id FROM mylines a, mylines b WHERE a.id != b.id AND a.geom && b.geom AND ST_Relate(a.geom, b.geom, ‘ ’); SELECT a.id FROM mylines a, mylines b WHERE a.id != b.id AND a.geom && b.geom AND ST_Relate(a.geom, b.geom, ‘1*1***1**’); SELECT a.id, intersection(a.geom, b.geom) FROM mylines a, mylines b WHERE a.id != b.id AND a.geom && b.geom AND ST_Relate(a.geom, b.geom, ‘1*1***1**’);

W W W. R E F R A C T I O N S. N E T Table Inheritance cities nametext populationreal altitudeint capitals nametext populationreal altitudeint provincetext CREATE TABLE cities ( name text, population real, altitude int ); CREATE TABLE cities ( name text, population real, altitude int ); CREATE TABLE capitals ( province text ) INHERITS (cities); CREATE TABLE capitals ( province text ) INHERITS (cities); inherits

W W W. R E F R A C T I O N S. N E T Table Inheritance metadata dataset_namechar(4) NOT NULL validity_datedate NOT NULL table1 dataset_namechar(4) NOT NULL validity_datedate NOT NULL attr1int attr2geometry table2 dataset_namechar(4) NOT NULL validity_datedate NOT NULL attr1int attr2text attr2geometry … dat…ch... val…da… …int inherits

W W W. R E F R A C T I O N S. N E T Table Partitioning hydro_edges code smallint the_geom geometry hol_edges code smallint the_geom geometry admin_edges code smallint the_geom geometry cwb_edges code smallint the_geom geometry new_hol_edges code smallint the_geom geometry new_admin_edges code smallint the_geom geometry inherits (16 million tuples) code check constraints Empty table

W W W. R E F R A C T I O N S. N E T Table Partitioning CREATE TABLE hydro_edges ( ) INHERITS cwb_edges; ALTER TABLE hydro_edges ADD CONSTRAINT code_check CHECK (code =...); CREATE TABLE hydro_edges ( ) INHERITS cwb_edges; ALTER TABLE hydro_edges ADD CONSTRAINT code_check CHECK (code =...); hydro_edges code smallint the_geom geometry cwb_edges code smallint the_geom geometry code check constraints -- ADD Rules to parent table CREATE RULE insert_hydro AS ON INSERT TO cwb_edges WHERE code =... DO INSTEAD INSERT INTO hydro_edges (code, geom) VALUES (NEW.code, NEW.geom); -- ADD Rules to parent table CREATE RULE insert_hydro AS ON INSERT TO cwb_edges WHERE code =... DO INSTEAD INSERT INTO hydro_edges (code, geom) VALUES (NEW.code, NEW.geom);

W W W. R E F R A C T I O N S. N E T PostgreSQL Tuning The biggest bottleneck in a spatial database is I/O When setting up a server, invest in a: –great file system RAID 5 – good for web servers, not spatial DBs Recommend RAID 1/0 –good memory –adequate CPU(s)

W W W. R E F R A C T I O N S. N E T PostgreSQL Tuning postgresql.conf –Startup checkpoint_segment_size –# of WAL files – 16MB each –Default: 3 –Set to at least 10 or 30 for databases with heavy write activity or more for large database loads –Possibly store the xlog on a separate disk device shared_buffers –Default: ~32MB –About 1/3 to 3/4 of available RAM

W W W. R E F R A C T I O N S. N E T PostgreSQL Tuning postgresql.conf –Startup constraint_exclusion –Default: “off” –Set to “on” to ensure the query planner will optimize as desired.

W W W. R E F R A C T I O N S. N E T PostgreSQL Tuning postgresql.conf –Runtime work_mem –Memory used for sort operations and complex queries –Default: 1MB –Adjust up for large dbs, complex queries, lots of RAM –Adjust down for many concurrent users or low RAM

W W W. R E F R A C T I O N S. N E T PostgreSQL Tuning postgresql.conf –Runtime maintainence_work_mem –Memory used for VACUUM, CREATE INDEX, etc. –Default:16MB –Generally too low – ties up I/O, locks objects while swapping memory. –Recommend 32MB to 256MB on production servers with lots of RAM, but depends on number of concurrent users.

W W W. R E F R A C T I O N S. N E T PostgreSQL Tuning postgresql.conf –Runtime On development systems with lots of RAM and few developers… SET work_mem TO ; SET maintainence_work_mem TO ;

W W W. R E F R A C T I O N S. N E T PostgreSQL Tuning postgresql.conf –Runtime client_min_messages –Useful when writing PL/Pgsql functions. SET client_min_messages to DEBUG; CREATE FUNCTION my_function () RETURNS TEXT AS $BODY$ BEGIN... RAISE DEBUG ‘myvar: %’ var;... CREATE FUNCTION my_function () RETURNS TEXT AS $BODY$ BEGIN... RAISE DEBUG ‘myvar: %’ var;...

W W W. R E F R A C T I O N S. N E T Performance Tips Spatial function calls can be expensive. Be efficient in their use - avoid unnecessary/duplicate function calls. –Use St_Expand where appropriate –Use one relate call instead of 2 or 3 other spatial calls. –Use St_Distance()==0 instead of intersects() on large geometries –Avoid St_Buffer() unless you need a buffered geometry

W W W. R E F R A C T I O N S. N E T Performance Tips Partition your data into Most Frequently Used (MFU) and Least Frequently Used (LFU).

Questions

W W W. R E F R A C T I O N S. N E T Appendex A // PostGIS and JTS Class.forName(“org.postgresql.Driver”); Connection conn = DriverManager.getConnection(“jdbc:postgresql://...”); WKBReader wkbReader = new WKBReader(); WKBWriter wkbWriter = new WKBWriter(); String query = “SELECT the_geom FROM my_spatial_table WHERE the_geom && ST_GeomFromWKB(?, 3005)”); PreparedStatement pstmt = conn.prepareStatement(query); pstmt.setBytes(1, wkbWriter.write(myJTSPolygon); ResultSet rs = pstmt.executeQuery(); while(rs.next) { Geometry g = wkbReader.read(WKBReader.hexToBytes( rs.getString(1)));... // Do stuff with Geometry } // PostGIS and JTS Class.forName(“org.postgresql.Driver”); Connection conn = DriverManager.getConnection(“jdbc:postgresql://...”); WKBReader wkbReader = new WKBReader(); WKBWriter wkbWriter = new WKBWriter(); String query = “SELECT the_geom FROM my_spatial_table WHERE the_geom && ST_GeomFromWKB(?, 3005)”); PreparedStatement pstmt = conn.prepareStatement(query); pstmt.setBytes(1, wkbWriter.write(myJTSPolygon); ResultSet rs = pstmt.executeQuery(); while(rs.next) { Geometry g = wkbReader.read(WKBReader.hexToBytes( rs.getString(1)));... // Do stuff with Geometry }

W W W. R E F R A C T I O N S. N E T Appendex B