Re: [R] maptools: Test if point is in polygon
Renaud Lancelot renaud.lancelot at gmail.com writes: See function pip (point in polygon) in package splancs. Renaud 2009/2/5 Rainer M Krug r.m.krug at gmail.com On Thu, Feb 5, 2009 at 3:21 PM, Aleksandr Andreev aleksandr.andreev at gmail.com wrote: In R's maptools package, is there a built-in function to test if a given point is inside a given polygon on the map? The map was loaded from an ESRI Shapefile. The point's latitude and longitude are known. The initial question was not put clearly. The pip function in splancs will work for a two-column matrix of points, but not for the object in question, if it was read in from a shapefile using readShapeSpatial(). In that case, the object is a SpatialPolygonsDataFrame as defined in the sp package, and the overlay() methods in sp should be the place to look - see ?overlay-methods. Typically, one would define the query point(s) as a SpatialPoints object, and overlay it on the input object. The output is a vector of indices, showing which Polygons object the points lie in, or NA if they do not. Roger Bivand PS. These kinds of questions typically get more focussed response on the R-sig-geo list; further, RSiteSearch() with 'point polygon' does show many useful avenues. If everything else fails, convert the shape file into a raster and drill down at the location of the points. Rainer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] maptools: Test if point is in polygon
Hi, You may want to check the package sp. There is one function called point.in.polygo that might do what you want. Good luck, Monica - Message: 32 Date: Thu, 5 Feb 2009 14:51:36 + From: baptiste auguie Subject: Re: [R] maptools: Test if point is in polygon To: Aleksandr Andreev Cc: r-help@r-project.org Message-ID: Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes I don't know about the maptools package but one general way to do this would be to compute the convex hull (?chull) of the augmented set of points and test if the point belongs to it. Hope this helps, baptiste On 5 Feb 2009, at 13:21, Aleksandr Andreev wrote: In R's maptools package, is there a built-in function to test if a given point is inside a given polygon on the map? The map was loaded from an ESRI Shapefile. The point's latitude and longitude are known. Thank you! Aleks -- Aleksandr Andreev Fulbright Fellow Graduate School of Management St Petersburg State University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] maptools: Test if point is in polygon
I don't know about the maptools package but one general way to do this would be to compute the convex hull (?chull) of the augmented set of points and test if the point belongs to it. Hope this helps, baptiste On 5 Feb 2009, at 13:21, Aleksandr Andreev wrote: In R's maptools package, is there a built-in function to test if a given point is inside a given polygon on the map? The map was loaded from an ESRI Shapefile. The point's latitude and longitude are known. Thank you! Aleks -- Aleksandr Andreev Fulbright Fellow Graduate School of Management St Petersburg State University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] maptools: Test if point is in polygon
On Thu, Feb 5, 2009 at 3:21 PM, Aleksandr Andreev aleksandr.andr...@gmail.com wrote: In R's maptools package, is there a built-in function to test if a given point is inside a given polygon on the map? The map was loaded from an ESRI Shapefile. The point's latitude and longitude are known. If everything else fails, convert the shape file into a raster and drill down at the location of the points. Rainer Thank you! Aleks -- Aleksandr Andreev Fulbright Fellow Graduate School of Management St Petersburg State University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Faculty of Science Natural Sciences Building Private Bag X1 University of Stellenbosch Matieland 7602 South Africa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] maptools: Test if point is in polygon
See function pip (point in polygon) in package splancs. Renaud 2009/2/5 Rainer M Krug r.m.k...@gmail.com On Thu, Feb 5, 2009 at 3:21 PM, Aleksandr Andreev aleksandr.andr...@gmail.com wrote: In R's maptools package, is there a built-in function to test if a given point is inside a given polygon on the map? The map was loaded from an ESRI Shapefile. The point's latitude and longitude are known. If everything else fails, convert the shape file into a raster and drill down at the location of the points. Rainer Thank you! Aleks -- Aleksandr Andreev Fulbright Fellow Graduate School of Management St Petersburg State University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Faculty of Science Natural Sciences Building Private Bag X1 University of Stellenbosch Matieland 7602 South Africa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Renaud LANCELOT Département Systèmes Biologiques du CIRAD CIRAD, Biological Systems Department Campus International de Baillarguet TA 30 / B F34398 Montpellier Tel +33 (0)4 67 59 37 17 Secr. +33 (0)4 67 59 37 37 Fax +33 (0)4 67 59 37 95 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.