In this recipe, we will create PLPGSQL functions that implement three noise-based obfuscation mechanisms: Rand, N-Rand, and Pinwheel. Then we will create a trigger function for a table in order to alter all newly inserted points. For this chapter, we will reuse the rk_track_points dataset used in Chapter 3, Working with Vector Data – The Basics.
In this recipe, we will use the ST_Project function to add noise to a single point. Then, we will compare the original data with obfuscated data in QGIS. Finally, we will show the impact of noise filtering on the obfuscated data.
In the recipe, we will use some of the same steps as in Chapter 3, Working with Vector Data – The Basics, but for a new schema.
First, be sure of the format of the .gpx files that you need to import to PostGIS. Open one of them and check the file structure—each file must be in the XML format, composed of one <trk> element, which contains just one <trkseg> element, which contains multiple <trkpt> elements (the points stored from the runner's GPS device).