I'm trying to create a map of US shale basins and I'm very new to creating maps. I have downloaded the shapefiles from the US Energy Information Administration (EIA). I have also, been able to created a basic map with the bases plotted (please see code below). I would like to add labels etc. to this map. I believe these would be in the other files downloaded outside the shapefile.

shapLocation<- "C:/shapfile/shalegasbasin/"
pcontorta <- readShapePoly(paste(shapLocation,"US_ShaleBasins_EIA_May2011.shp",sep=""))
plot(pcontorta, add=TRUE,  col=adjustcolor("black", alpha.f = 0.6),  border=FALSE) 

Shapefile from: http://www.eia.gov/maps/layer_info-m.cfm

Description of a shapefile: http://en.wikipedia.org/wiki/Shapefile

1 Answer 1


Take a look at ?text. You can place the labels using the polygon coordinates which will return approximate polygon centroids.

Sr1 = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2)))
Sr2 = Polygon(cbind(c(5,4,2,5),c(2,3,2,2)))
Sr3 = Polygon(cbind(c(4,4,5,10,4),c(5,3,2,5,5)))
Srs1 = Polygons(list(Sr1), "1")
Srs2 = Polygons(list(Sr2), "2")
Srs3 = Polygons(list(Sr3), "3")
SpP = SpatialPolygons(list(Srs1,Srs2,Srs3), 1:3)
SpP = SpatialPolygonsDataFrame(SpP, data.frame(ID=1:3))

# Plot polygons and place text based on polygon centroids
text(coordinates(SpP)[,1], coordinates(SpP)[,2], paste("p",SpP$ID,sep="-"))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.