[R-sig-Geo] accessing polygons in SpatialPolygonDataFrame

Edzer Pebesma edzer.pebesma at uni-muenster.de
Sun Nov 13 21:15:33 CET 2011


Ralf, you could try

getData("GADM", country="ESP", level=1)-> sp_gadm
plot(sp_gadm[-c(13,14),])

On 11/13/2011 08:40 PM, Ralf Schäfer wrote:
> Dear list members
> 
> I would like to access polygons from a SpatialPolygonDataFrame in order to subset them based on the area
> 
> setwd("~/Desktop/")
> require(raster) 
> getData("GADM", country="ESP", level=0)-> sp_gadm
> str(sp_gadm at polygons) # I can see the single polygons, but I have trouble to access them.
> 
> What I would like to do is to delete all Polygons except for the first one to have only the mainland of Spain.
> 
> Perhaps there is also an easier way - but the dataframe of the object has only one row, hence I can not subset the dataframe:
> sp_gadm at data
> 
> Any help appreciated
> Best regards
> Ralf
> 
> ------------------------------------------------------------
> Prof. Dr. rer. nat. Ralf Bernhard Schäfer
> Juniorprofessor for Quantitative Landscape Ecology
> Environmental Scientist (M.Sc.)
> Institute for Environmental Sciences
> University Koblenz-Landau
> Fortstrasse 7
> 76829 Landau
> Germany
> Mail: schaefer-ralf at uni-landau.de
> Phone: ++49 (0) 6341 280-31536
> Web: http://tinyurl.com/6dnpxna
> 
> 
> 	[[alternative HTML version deleted]]
> 
> 
> 
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list