0

This is my first time on here and I am really stumped on this one.

So I have a file of bay area housing prices (here called SAMPLE3.csv) and shapefiles of Bay Area zip codes. I am able to match the two and use fortify to melt the zip codes, as well as able to plot the data on the map, but cannot adjust the color scheme correctly to make a heat map (using, for instance, heat.colors). Here is my code:

houseprices <-  read.csv("~/DigitalFlyer/GIS/bayarea/SAMPLE3.csv", header=T)
bayarea <- USA[USA$city == 'bayarea',]
sf = fortify(bayarea, region="ZCTA5CE10")
sf$score <- engagement[match(sf$id, houseprices$zip, nomatch=NA), 2]

I can get a nice google map as a base layer using

qmap('oakland, ca', zoom=10,maptype='hybrid')+
geom_polygon(aes(x=long, y=lat, group=group), data=sf, colour="white", fill=sf$score, alpha=.5, size=.3)

I can get a nice heat map with qmap using

qplot(long, lat, data=sd, group=group , fill= score, geom="polygon"), 

but then cannot layer that on the google map.

Here is what I get with each: 1) https://i.stack.imgur.com/vJOHe.jpg 2) https://i.stack.imgur.com/bCeG4.jpg

Thank you for your help in advance!!!

1 Answers1

0

I can't test this because I don't have your data frame sf but the problem with your first code is that fill= should be places inside the aes() of geom_polygon() to ensure that fill values are according to score values of your data frame.

qmap('oakland, ca', zoom=10,maptype='hybrid') + 
     geom_polygon(aes(x=long, y=lat, group=group, fill=score), 
                     data=sf, colour="white",alpha=.5, size=.3)
Didzis Elferts
  • 95,661
  • 14
  • 264
  • 201
  • Hi Didzis. Thank you so much for this response it worked beautifully! Is there a way to upload the data frames so that in the future I can give users all of the information? – user3082069 Dec 09 '13 at 15:48
  • Read [this question](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and answer about reproducible question – Didzis Elferts Dec 09 '13 at 15:51