Exceptional Circumstances
The Unmappable Fake Street
Now we have to deal with the problem of bad street addresses—either the Sheriff office enters a typo or our parser lets a bad street address pass: http://local.yahooapis.com/MapsService/V1/geocode?appid=YD-9G7bey8_JXxQP6rxl.fBFGgCdNjoDMACQA--&street=1+Fake+St&city=Philadelphia&state=PA.
From the Yahoo documentation—when confronted with an address that cannot be mapped, the geocoder will return coordinates pointing to the center of the city. Note the “precision” attribute of the result is “zip” instead of address and there is a warning attribute as well.
<?xml version="1.0"?> <ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:maps" xsi:schemaLocation= "urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd"> <Result precision="zip" warning="The street could not be found. Here is the center of the city."> <Latitude>39.952270</Latitude> <Longitude>-75.162369</Longitude> <Address> </Address> <City>Philadelphia</City> <State>PA</State> <Zip></Zip> <Country>US</Country> </Result> </ResultSet>
Paste in the following:
> street<-"1 Fake St"> requestUrl<-paste("http://local.yahooapis.com/MapsService/V1/geocode?appid=",appid,"&street=",URLencode(street),"&city=Philadelphia&state=PA",sep="")
We need to get a hold of the attribute tags within <Result> to distinguish bad geocoding events, or else we could accidentally record events in the center of the city as foreclosures. By ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access