[GRASSLIST:9772] Re: access boundary coordinates from square vector
Dylan Beaudette
dylan.beaudette at gmail.com
Mon Jan 9 13:49:38 EST 2006
On Monday 09 January 2006 12:29 am, Radim Blazek wrote:
> On 1/9/06, Dylan Beaudette <dylan.beaudette at gmail.com> wrote:
> > Greetings,
> >
> > I am trying to access the four coordinates (nodes) that define the
> > boundary of a square vector, via the C API. so far i am having no luck.
> >
> > Any tips on where to get started?
>
> A bounding box of the whole vector or points of one area feature?
>
> Radim
perhaps a better description of the problem is in order.
In some parts of the US, there is a legal system of describing parcels of land
called PLSS. In its time (the last century) it worked reasonably well, but
now it is mostly a pain to use. I am trying to create a module for grass that
will convert a PLSS location into a geographic location, based on the plsnet
vector layer describing PLSS grid.
This vector is composed of a network of four-sided polygons, with an attribute
associated with each polygon indicating part of the PLSS code that defines
its location. However, the complete PLSS code describes an area 1/16th that
of the total area, in a fashion like:
NE 1/4 of NE 1/4 of NE 1/4 of Section 1
Where section 1 is a 1x1mile polygon. This part of the PLSS code can be
interpreted as ' the northeast quater of the northeast quarter of the
northeast quarter of section 1". Very strange indeed...
Since I would like to convert a description like this into a geographic
coordinate, I need to subdivide the "section" polygons contained in the
plsnet vector file. I have started work on an algorithm that will do this,
however I need some way to access the 4 nodes which define the vertices of
each four-sides polygon.
I have started with the following code to loop through the points in each line
of a line or boundary vector type:
---------------------
/* loop through each line in the dataset */
Vect_open_old(&In, in_opt->answer, "");
Points = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
ltype = Vect_read_line(&In, Points, Cats, line);
nlines = Vect_get_num_lines(&In);
printf("%i lines\n",nlines);
for (line = 1; line <= nlines; line++) {
/* loop through each point in a line */
for (j = 0; j < Points->n_points; j++) {
printf("%f %f %i\n", Points->x[j], Points->y[j], j);
} /* end looping through point in a line */
printf("\n");
} /* end looping thru lines */
----------------------------------------
the output from this modue is as follows:
v.plss in=pls_test type=boundary
5 lines
-2071410.623504 514294.371112 0
-2070032.693579 513872.241006 1
-2069957.750231 513849.160982 2
-2071410.623504 514294.371112 0
-2070032.693579 513872.241006 1
-2069957.750231 513849.160982 2
-2071410.623504 514294.371112 0
-2070032.693579 513872.241006 1
-2069957.750231 513849.160982 2
-2071410.623504 514294.371112 0
-2070032.693579 513872.241006 1
-2069957.750231 513849.160982 2
-2071410.623504 514294.371112 0
-2070032.693579 513872.241006 1
-2069957.750231 513849.160982 2
.... this doesn't quite match the output from v.out.ascii:
B 2
-2070987.20745953 515885.1103599
-2069456.34247776 515791.24632579
B 2
-2069456.34247776 515791.24632579
-2069957.75023142 513849.16098207
B 2
-2070987.20745953 515885.1103599
-2071410.62350447 514294.37111217
B 3
-2071410.62350447 514294.37111217
-2070032.6935785 513872.24100595
-2069957.75023142 513849.16098207
C 1 1
-2070412.47906158 514949.62378849
1 1144
Ideally, I would like to get a point data type with the NW, NE, SW, and SE x,y
locations...
Any ideas?
Thanks in advance!
--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341
More information about the grass-user
mailing list