Database Reference
In-Depth Information
Simplifying geometries
Therewillbemanytimeswhenyouwillneedtogeneratealessdetailedandlighter
version of a vector dataset, as you may not need too-detailed features for several
reasons.Thinkaboutacasewhereyouaregoingtopublishthedatasettoawebsite
and performance is a concern, or maybe you need to deploy the dataset to a col-
leaguewhodoesnotneedtoomuchdetailbecauseheorsheisusingitforalarge-
area map. In all of these cases, GIS tools provide you the implementation of sim-
plification algorithms thatreduceunwanteddetailsfromagivendataset.Basically,
thesealgorithmsreducethevertexnumberscomprisedinacertaintolerance,which
is expressed in units measuring distance.
For this purpose, PostGIS provides you the ST_Simplify and
ST_SimplifyPreserveTopology functions. In many cases, they are the right
solutionsforsimplificationtasks,butinsomecases,especiallyforpolygonalfeatures,
theyarenotthebestoptionoutthereandyouwillneedadifferentGIStoolsuchas
GRASS , or the new PostGIS topology support.
How to do it...
The steps you need to complete this recipe are as follows:
1. SetthePostgreSQL search_path variablesothatallofyournewlycreated
database objects will be stored in the chp03 schema, using the following
code:
postgis_cookbook=# SET search_path TO
chp03,public;
2. Suppose you need a less-detailed version of the states layer for your
mapping website or to deploy to a client; you could consider using the
ST_SimplifyPreserveTopology function, as follows:
postgis_cookbook=# CREATE TABLE
states_simplify_topology AS
SELECT
Search WWH ::




Custom Search