[R] Map of UK Counties - to use in R

Roger Bivand Roger.Bivand at nhh.no
Thu Aug 13 12:37:04 CEST 2009


If your csv file has points, you can read into a data.frame using 

df <- read.csv(<file name>) 

in the usual way (watch the decimal sign and use read.csv2() if need be),
and coerce to a SpatialPointsDataFrame by saying 

coordinates(df) <- c("long", "lat")

where "long", "lat" are the names of the data.frame columns with the
geographical coordinates. 

points(df) 

on the county boundary basemap will then display the points, your choice of
pch=. Do do summary(df) and check that your coordinates do fall inside the
county basemap! If west of Greenwich are large numbers <= 360, subtract 360
from all longitude values over 180 (untried, but does happen, so worth
checking).

If your csv file has extra data for the county entities, you'll need to
identify which are which in order to make thematic maps. 

Roger



Raoul wrote:
> 
> Thanks a million Roger! This works well. All I now need to do is to figure
> how I can plot data from a csv file onto the map. I really appreciate your
> assistance!
> Regards,
> Raoul
> 
> 
> Roger Bivand wrote:
>> 
>> The illustration you show is for the so-called traditional or historical
>> counties of England, which may be available somewhere. There are
>> non-georeferenced PNG files on Wikipedia, which might be used, but as far
>> as I can see, only UK-based academics can register for access to the
>> edina UK borders datasets.
>> 
>> One possibility is to use the 2006 NUTS boundaries shapefile from
>> GISCO/EUROSTAT at:
>> 
>> http://epp.eurostat.ec.europa.eu/portal/page/portal/gisco/geodata/reference
>> 
>> http://epp.eurostat.ec.europa.eu/cache/GISCO/geodatafiles/NUTS_03M_2006_SH.zip
>> 
>> and in R using something like:
>> 
>> library(rgdal)
>> RG <- readOGR(".", "NUTS_RG_03M_2006")
>> names(RG)
>> UK <- grep("^UK", RG$NUTS_ID)
>> RG_UK <- RG[UK,]
>> plot(RG_UK, axes=TRUE)
>> summary(RG_UK)
>> 
>> You'll then need to find the regions you want, possibly from:
>> 
>> http://www.statistics.gov.uk/geography/nuts.asp
>> 
>> so that you can retain only England, and choose the NUTS* boundaries that
>> suit your "counties" - which are not presently well-defined because of
>> boundary and administrative changes. The GISCO shapefile is in
>> geographical coordinates, so you'll be able to overplot points by
>> longitude and latitude.
>> 
>> Hope this helps,
>> 
>> Roger Bivand
>> 
>> 
>> Raoul wrote:
>>> 
>>> Hi,
>>> Can anyone help me with either of these:
>>> 1) Map of the UK counties that I could use in R?
>>> 2) How could I use an existing map for example, a map from here
>>> http://www.itraveluk.co.uk/maps/england.html - in R. I need to use a UK
>>> map to plot locations on it by lat & long.
>>> 
>>> Would appreciate help on any of these.
>>> Thanks,
>>> Raoul
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Map-of-UK-Counties---to-use-in-R-tp24930435p24952627.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list