How to map UK postcodes

  • I am new to geographic data in 2008R2 and have a couple of basic questions.

    1) I was wondering how to map UK postcodes to a map in SQL?

    2) Also is it possible to query to restrict the data returned to be with in 10 mile radius from another postcode?

  • There's nothing built in to do this. You'd need to use a CLR or SSIS script task or similar to connect to one of the Geocoding services; there are a few services that do UK Geocoding from postcodes, some free, some commercial.

    Once you've returned the latitude and longitude, you can then convert this to a geography data type. From this point, it's easy do all sorts of manipulation like distances between points etc. and plot on mapping tools.

    Depending on the level of accuracy you need, you could always just download a mapping table for the first part of the postcode and then just do a simple lookup (after splitting your postcode field) in SQL to get a rough geocode:

    http://www.freemaptools.com/download-uk-postcode-lat-lng.htm

  • You can also purchase a data table of postcodes directly from the Post Office that you can use in your application--no idea how much it costs, though, and it doesn't use the new geographic types to store the coordinates, so some work would be needed.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply