[GRASS-user] Re: Further on Checking if a point (X, Y) is inside the, polygons of a shape file using command line

John C. Tull john.tull at wildnevada.org
Tue Mar 4 12:04:14 EST 2008


I think your approach with two runs is adequate, although I am not  
sure which tool you would use to extend your polygon as I have not  
looked into that issue recently. I have similar questions that I  
address. In order to get names of the polygons (conservation areas for  
you), I go beyond v.select to populate a field with the names of the  
areas being queried. I then dump to a text file that I can open in a  
spreadsheet application for summarizing. My example assumes you have a  
field called 'name' in your input polygon file:

v.select ainput=in_points binput=conservation_polygons  
out=points_in_polygons
v.db.addcol points_in_polygons  col="polygon_name VARCHAR(40)"
v.distance from= points_in_polygons  to=conservation_polygons dmax=0  
upload=to_attr to_column=name col=polygon_name
v.db.select points_in_polygons  >  points_in_polygons.txt

Hope that helps. Maybe others will have similar or improved solutions,  
but this has worked for me.

John

On Mar 4, 2008, at 3:00 AM, Corrado wrote:
> Dear John, Rick, Hamish,
>
> thanks for your kind answers.
>
> I explain the problem:
>
> I have a file with some hundreds of species and 58,000 observations.  
> For each
> species, I have the coordinates (X,Y) of the sites where they were  
> observed.
>
> I also have a shape file, with polygons representing conservation  
> areas, like
> natural reserves.
>
> I need to know for each species, how many point fall inside  
> conservation areas
> and how many points fall outside conservation areas. Also, I need to  
> run the
> same test on the conservation areas with a buffer of 100 m and with  
> a buffer
> of 500 m.
>
> This is what I thought:  I test if each point (that is site) is  
> inside the
> polygon (that is conservation area), and I have an answer like yes  
> or no (or
> 0 or 1). I write a routine that does test all the points for each  
> species.
>
> I add the buffer (I do not know how to do it, but I think it is  
> possible). I
> run the test again.
>
> What do you think of this approach?
>
> If I use v.select, would that return me 0 or 1 (or yes or no), when  
> I try to
> overlap one point with the vector map?
>
> Or do you think it would be better to use R?
>
> Or would it be better to prepare a vector map for each species with  
> all the
> sites, and overlap species by species instead of point by point?
>
> I apologise for my questions, but I am trying to use GRASS for the  
> first time.
> I would like to switch from ArcGIS and convince also the other  
> people in the
> research group (there is at least two of us campaigning now).
>
> Thanks!



More information about the grass-user mailing list