How to do it...

Carry out the following steps to create the functions:

  1. Create a new schema named chp12 to store the data for all the recipes in this chapter using the following command:
      postgis_cookbook=# create schema chp12;
  1. The implementation of Rand requires the creation of a PLPGSQL function that receives the radius parameter, which defines the maximum distance, and the geometry the_geom to be altered.

The ST_Project function will move the point to a given distance and angle from its original location. In order to simplify the expression, we will use polar noise generation. Execute the following SQL command:

      postgis_cookbook=# CREATE OR REPLACE       FUNCTION chp12.rand(radius numeric, the_geom geometry)       returns geometry as $$
      BEGIN ...

Get PostGIS Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.