[R-sig-Geo] how to filter a shapefile ?

Mayeul KAUFFMANN mayeul.kauffmann at jrc.ec.europa.eu
Thu Sep 16 13:59:43 CEST 2010


You can read your shapefile with:
library(rgdal)
countries_spdf <- readOGR(dsn=root_path, "countries_file_without_extension")
#You'll have a spatial point data frame with marks. Look at str(countries_spdf).
Try:
plot(countries_spdf[countries_spdf at data$AREA>1000])
Mayeul
_____________________________________________________
Dr. Mayeul KAUFFMANN, Conflict Specialist
European Commission, Joint Research Centre (JRC)
Institute for the Protection and Security of the Citizen (IPSC)
Global Security and Crisis Management - ISFEREA
Via E. Fermi 2749 - I-21027 Ispra (VA), ITALY
Phone: (+39) 033278 5071
http://isferea.jrc.ec.europa.eu/Staff/Pages/Kauffmann-Mayeul.aspx

(Office: building 48c, 1st floor, room 123. TP: 483)

_____________________________________________________
Dr. Mayeul KAUFFMANN, Conflict Specialist
European Commission, Joint Research Centre (JRC)
Institute for the Protection and Security of the Citizen (IPSC)
Global Security and Crisis Management - ISFEREA
Via E. Fermi 2749 - I-21027 Ispra (VA), ITALY
Phone: (+39) 033278 5071
http://isferea.jrc.ec.europa.eu/Staff/Pages/Kauffmann-Mayeul.aspx

(Office: building 48c, 1st floor, room 123. TP: 483)


-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Arnald Marcer
Sent: Thursday, September 16, 2010 12:58 PM
To: r-sig-geo
Subject: [R-sig-Geo] how to filter a shapefile ?

Hi,

Can anyone give me a hint on how to extract/filter/subset
polygons from a shapefile based on an attribute of its dbf
table ?

Example:

shapefile: world.shp
attributes of its dbf table: ID, AREA, COUNTRY, ...

How can I plot a shapefile with only countries above a certain AREA value ?

Thank you very much,

Arnald Marcer
CREAF

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list