Hi Sven, Many thanks for the reply and my apologies for not posting any code. So far, I have been able to write this (but it's very basic and just getting me to the 'complicated' stage).
setwd("C:\\Users\\simon.tarr\\Documents\\GIS\\Test Data") require(raster) require(rgdal) revenue<-read.table("revenue.csv",header=T,row.names=1,sep=",") postcodes<-raster("C:\\Users\\simon.tarr\\Documents\\GIS\\Test Data\\rasters\\postcodes\\postcodes.img") trim(postcodes) plot(postcodes) I have attached a .csv file that contains my revenue data (this is actually just made up data- I wanted to make sure I could get the mapping to work before I start handling large quantities of real data). As I mentioned, the raster contains the same list of postcode names that appear in the CSV. So I need to somehow 'attach' the revenue figures to each postcode in the raster and then plot this. I hope this makes sense and apologies for the loose language...it's the only way I can think of to describe it. I'm trying hard to learn R and its syntax but sometimes I get stuck. I often know what needs to be done but struggle to write the necessary code to make it happen. All the best, Simon On 19 February 2015 at 20:37, Sven E. Templer <sven.temp...@gmail.com> wrote: > Without (example) code it is hard to follow... use ?dput to present > some data (subset). > But if it is data.frames you are dealing with (for sure with read.csv, > but not so sure at all with raster maps), give this a try: > > ?merge > > On 19 February 2015 at 17:44, Simon Tarr <simon.t...@adtrak.co.uk> wrote: > > Hello everyone, > > > > I need a little help with some R syntax to complete what (I think) is a > > fairly straightforward task- hopefully someone can assist! > > > > I have a raster map of the UK which is split into postcode areas (e.g. > DE, > > NG, NR etc. 127 postcodes in total). > > > > I have installed the package 'raster' and have successfully plotted the > > .img in R. All working and looks correct with the raster. > > > > I also have a comma delimited CSV file containing the same postcodes as > the > > raster with another column next to it containing revenue for each > postcode. > > > > *I was wondering if someone could help me merge/bind the revenue figures > > into the correct postcode in the raster so that I can plot revenue per > > postcode.* > > > > I feel I should be using cbind and reclassify to do this but I can't be > > sure. > > > > Any help would be appreciated. Thanks in advance! > > > > Simon > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.