Once your shapefile is loaded into R (see graph #168) you get a spdf format. You can choose to zoom on a specific part of the map. You can also access to informations using the slots of the spdf object. The slot @data is a dataframe that you can use like any dataframe. (to filter africa’s data for example)
# See graph #168 to understand how to upload a shapefile from the web.
download.file("http://thematicmapping.org/downloads/TM_WORLD_BORDERS_SIMPL-0.3.zip" , destfile="world_shape_file.zip")
my_spdf=readOGR( dsn= getwd() , layer="TM_WORLD_BORDERS_SIMPL-0.3")
# First we can plot the complete shape file that is under the spdf format
# The plot has usual coordinates that you can see doing:
# We can zoom on a part of the map (australia)
plot(my_spdf , xlim=c(115,160) , ylim=c(-45,-10) )
# There is always data associated with the spdf object. Have a look at them
# That means you can filter the data. For example, keep only Africa and plot it
africa=my_spdf[my_spdf@data$REGION==2 , ]
plot(africa , xlim=c(-20,60) , ylim=c(-40,35) )
Not what you are looking for ? Make a new search !