12.07.2015 Views

PostGIS 1.5.8 Manual - Fedora Project Packages GIT repositories

PostGIS 1.5.8 Manual - Fedora Project Packages GIT repositories

PostGIS 1.5.8 Manual - Fedora Project Packages GIT repositories

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>PostGIS</strong> <strong>1.5.8</strong> <strong>Manual</strong>215 / 310DescriptionOutput type can be a MULTI* or a GEOMETRYCOLLECTION. Comes in 2 variants. Variant 1 collects 2 geometries. Variant2 is an aggregate function that takes a set of geometries and collects them into a single ST_Geometry.Aggregate version: This function returns a GEOMETRYCOLLECTION or a MULTI object from a set of geometries. TheST_Collect() function is an "aggregate" function in the terminology of PostgreSQL. That means that it operates on rows ofdata, in the same way the SUM() and AVG() functions do. For example, "SELECT ST_Collect(GEOM) FROM GEOMTABLEGROUP BY ATTRCOLUMN" will return a separate GEOMETRYCOLLECTION for each distinct value of ATTRCOLUMN.Non-Aggregate version: This function returns a geometry being a collection of two input geometries. Output type can be aMULTI* or a GEOMETRYCOLLECTION.NoteST_Collect and ST_Union are often interchangeable. ST_Collect is in general orders of magnitude faster thanST_Union because it does not try to dissolve boundaries or validate that a constructed MultiPolgon doesn’t have overlappingregions. It merely rolls up single geometries into MULTI and MULTI or mixed geometry types into GeometryCollections. Unfortunately geometry collections are not well-supported by GIS tools. To prevent ST_Collect from returninga Geometry Collection when collecting MULTI geometries, one can use the below trick that utilizes ST_Dumpto expand the MULTIs out to singles and then regroup them.Availability: 1.4.0 - ST_Collect(geomarray) was introduced. ST_Collect was enhanced to handle more geometries faster.This function supports 3d and will not drop the z-index.This method supports Circular Strings and Curves This method supports Circular Strings and Curves, but will never returna MULTICURVE or MULTI as one would expect and <strong>PostGIS</strong> does not currently support those.ExamplesAggregate exampleThread ref: http://postgis.refractions.net/pipermail/postgis-users/2008-June/020331.htmlSELECT stusps,ST_Multi(ST_Collect(f.the_geom)) as singlegeomFROM (SELECT stusps, (ST_Dump(the_geom)).geom As the_geomFROMsomestatetable ) As fGROUP BY stuspsNon-Aggregate exampleThread ref: http://postgis.refractions.net/pipermail/postgis-users/2008-June/020331.htmlSELECT ST_AsText(ST_Collect(ST_GeomFromText(’POINT(1 2)’),ST_GeomFromText(’POINT(-2 3)’) ));st_astext----------MULTIPOINT(1 2,-2 3)--Collect 2 d pointsSELECT ST_AsText(ST_Collect(ST_GeomFromText(’POINT(1 2)’),ST_GeomFromText(’POINT(1 2)’) ) );st_astext----------MULTIPOINT(1 2,1 2)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!