[postgis-users] PostGIS and Section lines

Bruce Rindahl rindahl at lrcwe.com
Thu Jan 25 19:46:46 PST 2007


I am trying to us PostGIS to develop a program to locate points in relation
to section lines (almost all of the US is mapped into 1 mile by 1 mile
squares called sections).
I have a good idea of how to approach this but need a few suggestions on
some of the details.  The table containing all of the sections for I need is
in PostGIS. These are in general square polygons but not perfectly shaped or
vertical/horizontal.

Step one is to find the vertex that is the closest to the corners of the
bounding box.  I plan on getting the extent of the section using envelope().
Then for each point in the geometry I need to get the distance to the
XMIN,YMIN point in the bounding box.  The point with the shortest distance
is the South West corner of the section. I will update the table with the
index of that point.  Each point can be found from:
PointN(ExteriorRing(GeometryN(the_geom,1)),x) where x goes from 1 to
NumPoints(ExteriorRing(GeometryN(the_geom,1))).
Is there a straight forward way to get this index?  I need them for each
corner of the polygon (section).  This is done once and the table will be
updated with the indexes for the SW, SE, NE and NW corners of the section.

Step two is to create lines on the fly from these indexes.  If the index for
the NE corner is say 3 and the SE corner is 6, then the East line of the
section is the line from point(3) to point(4) to point(5) to point(6).  If a
location is defined as 500 feet from the east section line and 1000 feet
from the south section line (very typical in my application) the I can
create the east line and the south line as above, translate the east line
500 feet west, the south line 1000 feet north, and the result is the
intersection of these translated lines.  Given a point the distances to the
lines is easy - distance(the point , a section line).  The question here is
what is the easiest way to generate a line from specified vertexes of a
polygon?

Any help would be greatly appreciated.

Bruce Rindahl
 





More information about the postgis-users mailing list