Creating a Mailing List in QGIS and R

[This article was first published on R – Real Data, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

My day job as a real estate agent requires a myriad of skills, ranging from accounting to negotiation to business analysis.  Frequently (about every three months) I whip out my marketing skills to advertise my business.  This time I decided to send out postcards to an entire neighborhood in which I had sold homes recently.  Typically, agents will buy a mail route from the post office and hand over their postcards.  In the spirit of frugality and proving a point, I cracked my knuckles and went hunting for data.

Get the shapefiles.  Wake County Open Data (or your local open data hub) has a wealth of county-level data including subdivision boundaries and individual address points.  Download both shapefiles and  load them into your favorite GIS program.  This step can probably be done in R, but I find using QGIS fairly intuitive and much faster at plotting large shapefiles.

Screen Shot 2017-02-15 at 11.07.05 AM.png     Screen Shot 2017-02-15 at 11.10.33 AM.png

Filter the addresses.  After loading the address and subdivision shapefiles into QGIS, clip the address shapefile using the subdivision shapefile to save the addresses of interest in a new layer.  Save that puppy as a .csv and we can load it up in R.

Screen Shot 2017-02-15 at 11.24.11 AM.png

Manipulate in R.  Now we’ve got the info we want.  A few lines of code will give us something the post office (or Excel) will understand.

screen-shot-2017-02-15-at-11-35-42-am

walden_creek <- read_csv("~/Desktop/walden creek.csv")
attach(walden_creek)
adds <- paste(FULLADDR, POSTAL_CIT, "NC", "27523", sep = ",")
detach(walden_creek)
write.table(adds, "adds.csv", sep = ",")

Short and sweet, but I thought this was an interesting way to use data for a practical purpose.  People seem to be using R in exciting ways these days – if you see any creative, different projects please share.

– Kiefer Smith


To leave a comment for the author, please follow the link and comment on their blog: R – Real Data.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)