Access points of geometric path data in PostgreSQL 8.1
3
votes
1
answer
226
views
Summary:
I would like to perform basic operations on the points of geometric path data contained in a PostgreSQL 8.1 server which I do not have administrative access to. In particular I would like to be able to iterate over these points using SQL and to access paths as arrays (or something functionally equivalent).
---
Background:
I'm a novice database user who is working with an unsupported legacy application which is using PostgreSQL 8.1 as a back-end database. I would like to be able to manually run some sanity checks on the data in the database in pure SQL (or PL/pgSQL), i.e. I'd like to be able to avoid using an external programming language, which is what I'm currently doing.
Several tables in the database include columns containing geometric data. Here is a description of one such table:
psql -U "${appuser}" -d "${appdatabase}" -c '\d+ path_table'
Table "public.path_table"
Column | Type | Modifiers | Description
--------+---------+-----------+-------------
id | integer | not null |
path | path | not null |
Indexes:
"path_table_pkey" PRIMARY KEY, btree (id)
Check constraints:
"path_table_id_check" CHECK (id > 0)
Has OIDs: no
I consulted the section on [Geometric Functions and Operators](http://www.postgresql.org/docs/8.1/static/functions-geometry.html) from the [PostgreSQL 8.1 Manual](http://www.postgresql.org/docs/8.1/static/) , but to no avail.
Since this might be relevant, I'll mention that I believe that PostGIS 1.3.6 is installed, i.e.:
$ psql -U "${appuser}" -d "${appdatabase}" -c 'SELECT PostGIS_full_version();'
postgis_full_version
----------------------------------------------------------------------------------------
POSTGIS="1.3.6" GEOS="3.1.1-CAPI-1.6.0" PROJ="Rel. 4.7.1, 23 September 2009" USE_STATS
(1 row)
My understanding is that I can get a list of all installed functions by using the psql
\df
meta-command, i.e.
$ psql -U "${appuser}" -d "${appdatabase}" -c '\df'
My understanding is also that all of the available PostGIS commands should be prefixed by the string 'ST_' (denoting spatial type), so that the following should produce a list of all the available PostGIS commands:
$ psql -U "${appuser}" -d "${appdatabase}" -Alt -c '\df' | cut -d'|' -f2 | grep -i '^st_'
Inspecting this list didn't produce any likely candidates besides the ST_Dump function, which doesn't appear to apply to a path type:
SELECT st_dump(path_column) FROM table;
ERROR: function st_dump(path) does not exist
HINT: No function matches the given name and argument types. You may need to add explicit type casts.
Apparently the st_dump argument needs to be of type geometry, so I tried following the hint and casting the path to a geometry type:
SELECT st_dump(path_column::geometry) FROM table;
ERROR: cannot cast type path to geometry
I also consulted the [Geometry Accessors](http://postgis.net/docs/manual-1.3/ch06.html#id438545) of the [PostGIS 1.3.6 Manual](http://postgis.net/docs/manual-1.3) but apparently I don't know enough to be able to cull a solution from the documentation.
Asked by igal
(345 rep)
Nov 6, 2015, 03:05 PM
Last activity: Jun 9, 2025, 12:07 AM
Last activity: Jun 9, 2025, 12:07 AM