Subscribe to this thread
Home - General / All posts - Geocoding accuracy
bleys212 post(s)
#11-May-18 22:11

Hi everyone, long time Manifold user, just getting my feet wet in version 9. One of the things that was really cool in version 9 was being able to potentially script/automate geocoding of student addresses for school boundaries (I work for a school district.) I've followed the examples, and I'm using Bing, since we have an API key, and their limits are more reasonable than Google's, and it works well...except for identifying addresses it can't quite place, and putting them in the center of that city/town. In my current setup, I've been using Manifold 8, and an Excel sheet that queries Bing, and returns the Lat/Long, and a field called Confidence. Anything that shows "High" confidence, I can trust that Bing located the actual building for that address. I toss the results of everything else, and manually deal with those. I've dug through the docs, and through M9, and can't find any reference to whether the Geom that is created when the Geocode function is called actually records the Confidence result that Bing provides, or whether it just discards it (Bing's results page is here, if interested: https://msdn.microsoft.com/en-us/library/ff701725.aspx ) It would be awesome if I could query that Confidence result in some way, as I could sort the results on the fly as they're being geocoded.

Anyway, just curious if anyone knows...if not, I can still do the same process on M9 as I was on M8.

Thanks!

adamw


10,447 post(s)
#14-May-18 13:36

You can get the entire JSON string (or XML or whatever) returned by the server for a geocoding match by using SQL, see GeocodeAddressMatches.

This geocodes an address and returns a record for each match with Name and Confidence for each:

--SQL9

SELECT

  StringJsonValue([value]'name', true) AS [name],

  StringJsonValue([value]'confidence', true) AS [confidence]

FROM CALL GeocodeAddressMatches([bing]'New York, Park Ave, 4');

This does the same and adds coordinates returned for each match as well with the lat/lon values and CalculationMethod:

--SQL9

FUNCTION decodeMatches(matches NVARCHARTABLE AS (

  SELECT

    [index],

    CAST (StringJsonValue([value]'coordinates', false) AS FLOAT64X2)

      AS [coord],

    StringJsonValue([value]'calculationMethod', true) AS [method]

  FROM CALL StringToJsonArrayValues(matches)

END;

SELECT

  StringJsonValue([value]'name', true) AS [name],

  StringJsonValue([value]'confidence', true) AS [confidence],

  SPLIT CALL decodeMatches(StringJsonArray([value]'geocodePoints'))

FROM CALL GeocodeAddressMatches([bing]'New York, Park Ave, 4');

Hope this helps.

Dimitri


7,413 post(s)
#14-May-18 16:07

A quick reminder: to use the Bing geocoder you need an API key. I think they're still free.

bleys212 post(s)
#14-May-18 22:17

Thanks a lot, that looks like it will do the trick! I've got a new group of test data to run, so I'm going to try it shortly, and see how it goes...

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.