Next Previous Contents

What kind of geometric objects can I store?

You can store point, line, polygon, multipoint, multiline, multipolygon, and geometrycollections. These are specified in the Open GIS Well Known Text Format (with 3d extentions).

How do I improve searching speed?

Build an index. The following SQL, for example:


CREATE INDEX <index name> ON <table name> USING GIST (<geometry column name> GIST_GEOMETRY_OPS) WITH (islossy);
SET ENABLE_SEQSCAN = OFF;
SELECT * FROM <table> WHERE <geometry column name> && 'BOX3D(0 0 0, 100 100 0)'::BOX3D

Why are the operators not giving me the results I expect?

The operators work on the bounding box of the geometry, not the underlying geometry.

How can I get my search to return things that really are inside the search box, not just overlapping bounding boxes?

Since the " &&" operator only checks for bounding box overlap, use the truly_inside() function. For example:


SELECTt * FROM <table> WHERE <geometry column> && <BOX3D> AND truly_inside(<geometry column>,<BOX3D>);

Since the && is quick (and indexable), this will execute quickly.

What are the available functions and what do they do?

length3d(GEOMETRY) - 3d length of all linestrings in GEOMETRY

length2d(GEOMETRY) - 2d length of all linestringsin GEOMETRY

area2d (GEOMETRY) - area of all polygons (projected to the XY plane)

perimeter2d(GEOMETRY) - 2d length of all polygon rings

perimeter3d(GEOMETRY) - 3d length of all polygon rings

truly_inside(GEOMETRY,GEOMETRY) - true if part of A is inside B's bounding box

A <& B - true if A's bounding box overlaps or is to the right of B's

A << B - true if A's bounding box is strictly to the right of B's

A &> B - true if A's bounding box overlaps or is strictly to the right of B's

A >> B - true if A's bounding box is strictly to the left of B's

A ~= B - true if A's geometry is the same as B's (order of sub-geometry unimportant)

A ~ B - true if A's bounding box is contained by B's bounding box

A @ B - true if A's bounding box contains B's bounding box

A && B- true if A's bounding box overlaps B's bounding box

npoints(GEOMETRY) - (info) how many points are in the geometry

nrings(GEOMETRY) - (info) how many rings are there in the geometry

mem_size(GEOMETRY) - (info) how much space does this geometry take up

numb_sub_objs(GEOMETRY) - (info) how many sub objects are inside this geometry

summary(GEOMETRY) - (info) give a text summary of whats inside the geometry

Why aren't R-Tree's recommended?

They (unlike GiST) cannot handle geometries that are are > 8kb in size, and they take a lot longer to create.


Next Previous Contents