[Talk-GB] UPRN Locations Map

Nick nick at foresters.org
Thu Jul 2 22:16:59 UTC 2020


Hi Peter

re: "I am still not clear how best to use the data available" - I have 
written a simple bit of VBA that enables address data to be retrieved 
for a given UPRN (I attach the VBA used in a form for Excel) - this only 
works for Scotland but may be available elsewhere. Using the concept you 
can use Python (a friend has done some preliminary work) or similar. 
This is not elegant but is perhaps a first step in enabling a whole lot 
of development?

Cheers

Nick


On 02/07/2020 18:38, Peter Neale via Talk-GB wrote:
> Hi Robert,
>
> Many thanks for producing that map.
>
> I was able to look at my street and see a blue pin in each of the 
> building outlines that I had mapped from aerial imagery, so that gave 
> me a warm, smug feeling :)
>
> I too noticed some not-yet-there properties in a nearby development 
> that had UPRNs assigned - Not a problem really (IMHO).  There is also 
> one allocated to a pond near me; I didn't know that was "addressable"!
>
> However, I am still not clear how best to use the data available, if 
> you can't use it to look up the address of the property.  Similarly, I 
> am not sure how a data consumer could use the data, if we laboriously 
> edited every property in OSM to include a "ref:GB:UPRN=" tag (or 
> similar; other tags are available.....).
>
> Sorry not to be able to contribute something more useful... :(
>
> Regards,
> Peter
>
>
>
> On Thursday, 2 July 2020, 17:40:51 BST, Robert Whittaker (OSM lists) 
> <robert.whittaker+osm at gmail.com> wrote:
>
>
> I'm not completely sure if/how we can best make use of the new OS
> OpenData (UPRNs, USRNs and related links) in OpenStreetMap, but as a
> first step I've set up a quick slippy map with the UPRN locations
> shown:
>
> https://osm.mathmos.net/addresses/uprn/ 
> <https://osm.mathmos.net/addresses/uprn/ >(zoom in to level 16 to show 
> the data)
>
> The UPRN dataset literally just contains the UPRN number and its
> coordinates (both OS National Grid and WGS lat/lon). There are some
> additional linking datasets that link these ids to other ids (e.g.
> USRNs, TOIDs). But no address information is available directly. (You
> may be able to get street names by matching to OS Open Roads via TOIDs
> though. Coupled with Code-Point Open, you might be able to assign
> quite a few postcodes in cases where there's only one unit for a whole
> street.)
>
> The UPRN data has already helped me find a mapping error I made
> locally though -- it looks like I'd accidentally missed drawing a
> house outline from aerial imagery, and also classified a large garage
> a few doors down as a house. The two errors cancelled out when the
> houses were numbered sequentially, so I didn't notice until now. Today
> though I spotted a UPRN marker over some blank space on the map, and
> no marker over the mapped house that's probably a garage.
>
> Now a few initial thoughts on the data that I've explored so far:
>
> I believe that the UPRNs are assigned by local authorities, so
> conventions may vary from place to place. I don't know who actually
> assigns the coordinates (authority or OS). Looking at those for rows
> of houses around me, they don't seem to have been automatically given
> coordinates from the house footprint, it looks more like someone
> manually clicking on a map.
>
> The UPRN dataset should include all addressable properties. It is also
> ahead of reality in some places, as it includes locations for houses
> on a new development near me that have yet to be built yet. For blocks
> of apartments/flats, the UPRN nodes may all have the same coordinates
> or may be displaced from each other, possibly in an artificial manner.
>
> Other objects also appear to have UPRNs. Likely things I've noticed so
> far include: car parks, post boxes, telephone boxes (even after
> they've been removed), electricity sub-stations, roads and recorded
> footpaths (the UPRN locations seem to be at one end of the street, so
> usually lie at a junction), recreation grounds / play areas,
> floodlight poles (around sports pitches), and allotments. There's no
> information about the object type in the UPRN data unfortunately.
>
> Anyway, I hope some of this is useful / interesting. I hope to be on
> the OSMUK call on Saturday to discuss things further. Best wishes,
>
> Robert.
>
> -- 
> Robert Whittaker
> https://osm.mathmos.net/
>
> _______________________________________________
> Talk-GB mailing list
> Talk-GB at openstreetmap.org <mailto:Talk-GB at openstreetmap.org>
> https://lists.openstreetmap.org/listinfo/talk-gb
>
> _______________________________________________
> Talk-GB mailing list
> Talk-GB at openstreetmap.org
> https://lists.openstreetmap.org/listinfo/talk-gb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/talk-gb/attachments/20200702/8a8bd6ae/attachment.htm>
-------------- next part --------------
Private Sub CommandButton1_Click()
    On Error GoTo ErrorHandler
    
 Dim wBk As Workbook
 Dim wSht As Worksheet
 Dim r As Long
  Set wBk = ActiveWorkbook
  Set wSht = wBk.Worksheets("UPRN")
  r = wSht.Range("A" & wSht.Rows.Count).End(xlUp).Row
  r = r + 1

Dim UPRN As String
 If IsNumeric(Me.TextBox1.Value) = False Then
  MsgBox "UPRN must be numeric"
  Exit Sub
 End If
 
 If Len(Me.TextBox1.Value) > 12 Then
  MsgBox "UPRNs are integers that can be up to 12 digits in length"
  Exit Sub
 End If
 
 UPRN = VBA.Trim(Me.TextBox1.Value)
 
Dim strURL
 strURL = "https://osg.scot/portal/index.jsp?uprn=" & UPRN

    Dim strError As String
    strError = ""
    Dim oXMLHTTP As MSXML2.XMLHTTP
    Set oXMLHTTP = New MSXML2.XMLHTTP
    Dim strResponse As String
    strResponse = ""
    Dim myStr As String
    myStr = ""
    Dim startPos As Long
    Dim endPos As Long
    Dim Result() As String
    Dim i As Long
    Dim subStr As String
    Dim subPos As Long
    Dim subLen As Long
    
    With oXMLHTTP
        .Open "GET", strURL, False
        .send ""
        If .Status <> 200 Then
            strError = .statusText
            GoTo CleanUpAndExit
        Else
            'If .getResponseHeader("Content-type") <> "text/html" Then
             '   strError = "Not an HTML file"
             '   GoTo CleanUpAndExit
            'Else
                strResponse = .responseText
            'End If
        End If
    End With
    
CleanUpAndExit:
    On Error Resume Next
    Set oXMLHTTP = Nothing
    If Len(strError) > 0 Then
        MsgBox strError
    Else
        startPos = InStr(strResponse, "document.getElementById('add')")
        endPos = InStr(strResponse, "var markers")
        myStr = Mid(strResponse, startPos, endPos - startPos)
        Result = Split(myStr, "var ")

        For i = LBound(Result()) + 1 To UBound(Result()) - 1
         subStr = Result(i)
         subPos = InStr(subStr, "=")
         subLen = Len(subStr)
         subStr = Right(subStr, subLen - subPos)
         subStr = Replace(subStr, ";", "")
         subStr = Replace(subStr, "'", "")
         wSht.Cells(r, i) = subStr
        Next i
    End If
   
Me.TextBox1.Value = ""
Me.Hide
Exit Sub
    
ErrorHandler:
    strError = Err.Description
    Resume CleanUpAndExit
End Sub



More information about the Talk-GB mailing list