[GRASSLIST:4075] Re: dynamic modeling advice? II
Radim Blazek
blazek at itc.it
Mon Jul 15 05:01:24 EDT 2002
sorry, here is full message:
On Friday 12 July 2002 10:29 pm, Alex Thorn wrote:
> I'm now considering what portions of the analysis
> should be performed by GRASS, and what portions it
> would be more appropriate to use the C programs for.
> I'm finding that much of the spatial manipulation
> that I need (for example, the direction to-nearest-
> object problem that I was asking about yesterday)
> to do could be done by the C program fairly easily
> without involving GRASS at all. It seems that it
> might even be possible only using GRASS to display the
> output. Meanwhile, it seems clear that every use
> of GRASS for a spatial calculation slows down the
> program runtime because of the necessity to create
> support files for the resulting coverages.
Depending on how stable environment you need, you could
consider to use grass51 for vectors (if you wait a moment
Bernhard will reply that nobody should use it, because it is
experimental). Building support in grass51 is very quick because:
1) categories are saved with geometry (no attaching)
2) spatial index is used for nodes
(i run test now: 8s/340000 lines; i think, it was about 3h in grass50)
You can run grass51 and grass50 at the same time in 2 shells.
Example for your direction to nearest (say that we want direction from
points in A vector to nearest point in B vector):
nlines = Vect_get_num_lines (&AIn);
for ( i = 1; i <= nlines; i++ ) {
Vect_read_line (&AIn, APoints, ACats, i);
point = Vect_find_line (Map, APoints->x[0], APoints->y[0], 0,
GV_POINT, thresh, 0);
Vect_read_line (&BIn, BPoints, BCats, point);
dir = atan2(BPoints->y[0]-APoints->y[0], BPoints->y[0]-APoints->x[0]);
Vect_cat_get(ACats, 1, &acat);
Vect_cat_get(BCats, 1, &bcat);
fprintf(stdout,"%d %d %f\n", acat, bcat, dir);
}
Radim
More information about the grass-user
mailing list