[R-sig-Geo] Determining in which polygon points lie
s6lihert at uni-bonn.de
Fri Jun 14 18:05:38 CEST 2013
You can download gadm files as R SpatialPolygonsDataFrame. Then using
load you can load them in your session.
You should keep only the column of interest for you (the N-region
identifiers) in the SpatialPolygons, you can then use the 'over'
function in the sp package to get for each polygons (region) the points
ID (usually their row number, but if you have a SpatialPointsDataFrame
the first column values).
On 14/06/2013 17:51, Dieter Vanderelst wrote:
> Dear List,
> I'm reading in a shapefile of a country with different subregions in
> the shapefile (the shapefile was downloaded from the GADM database of
> Global Administrative Areas). I also have a number of points.
> Therefore, my code looks like this (using the maptools package):
> Now, I want to know in which of the N regions of the country each of
> the spatial points lies? Is there an easy way to do this? I know there
> is a function points.in.poly in sp. But this functions seems
> incompatible with the objects created by the maptools functions. Also,
> this function requires looping over the regions in a set.
> Behavioural, Acoustic and Sensory Ecology Lab
> University Bristol, UK
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
More information about the R-sig-Geo