More shapefiles and postcodes

I thought I was done with this but I’m not. Time to have more of a play in R with Land registry data and the National Statistics Postcode Lookup (NSPL). You never know maps and networks might also be involved.

In previous posts I’ve played with these sources and made a lookup file. This time I actually might do something after I’ve processed the data. But let’s be honest, I probably won’t. The code to make the lookup file is here and that’s what I’ll talk through first.

First job, import the NSPL file. Which is all well and nice. The problem is that this file is just full of lookups, not the actual names. Who has any idea what ttwa=E30000029 means. I want it to say Halifax as I know that’s a place. So time for some super repetitive code. Please write a comment/submit a change to Github if you think you can do it in a less boring way, with an apply function or loop or something.

The next step is to get the land registry data. Last time I just looked at average price. This time there is a whole slew of factors I’ve added in, such as number and average price of flats or new builds.

And after making that, and it taking far too long, it’s time to add it onto the shape file from the previous post and draw some pictures. That’s what we do here, draw pictures and waste time. Updated code.

Plot of total sales by postcode

That’s a bit sparse so we need to move up to the larger areas we have just merged on.

The shape files can be dissolved using this code, shamelessly taken from various places across the internet (see the comments in the code). This means I can now plot over any shape made of postcodes. Some examples (there would be more but R started playing up so I had to stop):

 

Hmm, R is still being silly. These will be added in later

Leave a Reply

Your email address will not be published. Required fields are marked *