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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.