I'm learning how to use PostGIS and spatial databases for analysis. What I am trying to do is perform a calculation to get the distance for the nearest polygon in a file, using the edge calculation, rather than vertices.
Using this answer from Paul Ramsey to a similar question:
CREATE TABLE mytable_distances AS SELECT a.id, b.id, ST_Distance(a.geom::geography, b.geom::geography) as distance FROM mytable a, mytable b;
I am attempting to apply it to my spatial database. I don't understand the structure of this query though. I think
CREATE TABLE mytable_distances AS creates a table to store the result but after this part I'm lost. Are
b column names? If so, why would I specify two columns to calculate this?
My table is called
TestArea and I have experimented with some basic queries successfully:
SELECT "TestArea".hgt FROM public."TestArea" WHERE "TestArea".area > 100
The structure of the database in PGAdmin III is as follows, with my table called
TestArea. I'm not sure what the nearest neighbor calculation should look like using my column headers (all of these objects are polygons).