none
Missing county in boundary polygon result RRS feed

  • Question

  • In v8 some county boundary polygons do not show correctly (i.e. show all counties in state of New Hampshire).  For New Hampshire the result leaves out Merrimack County.  If I just request Merrimack County, it shows the correct polygon.  I'll be glad to show the code but is this a geocoding glitch in geocoding in v8?  The same thing happens if I request certain MSAs (try Greensboro, NC with 3 counties-all three polygons are drawn but one is in wrong location, Rockingham County.

    By the way request all counties in Vermont and they all show correctly.

    Thanks for any suggestions

    David

    Sunday, July 10, 2016 8:51 PM

Answers

  • I've tried your code and am seeing a result for Merrimack, NH every time.

    However, I don't suspect this is the boundary you are expecting. The issue is that there is also a city called Merrimack, NH which has a higher rank in the geocoder. As such it's coordinate is being used to retrieve the country boundary that it intersects. However, changing your query to "Merrick County, NH" retrieves the boundary you are likely looking for:


    [Blog] [twitter] [LinkedIn]


    • Edited by Ricky_Brundritt Tuesday, July 12, 2016 2:43 PM
    • Proposed as answer by Ricky_Brundritt Tuesday, July 12, 2016 2:43 PM
    • Marked as answer by dcmap2 Tuesday, July 12, 2016 10:25 PM
    Tuesday, July 12, 2016 2:38 PM
  • There could be a couple of different reasons for the results. The GeoData API figures out what polygon to retrieve from the system by taking a coordinate and finding which polygon intersects with it. A lot of boundary data consists of multiple polygons and the geocoded coordinate for them is often placed in the geographic center of this boundary. Unfortunately, this location may not be within any of the polygons themselves. This could be one of the issues. There is an update to the geocoder coming soon which will likely resolve a lot of issues related to this.

    Also, by default only the first polygon is returned, if your boundary has multiple polygons, this could appear to be an issue. You can resolve this in the GeoData options.

    If however a boundary is being found when you do a search for it on it's own but it isn't found when searching multiple boundaries, then it is likely an issue with the request. Can you provide more details around how to making this request (sample code to reproduce).


    [Blog] [twitter] [LinkedIn]


    Monday, July 11, 2016 6:24 PM
  • When you use the GeoData API it doesn't use the EntityType value when searching. The entity value is only used for selecting which polygon to retrieve that intersects the coordinates of the geocoded location. This is useful if for example you want the boundary of an entity type that is different from your query, for example get the city boundary for a zip code.

    [Blog] [twitter] [LinkedIn]

    Tuesday, July 12, 2016 10:49 PM

All replies

  • There could be a couple of different reasons for the results. The GeoData API figures out what polygon to retrieve from the system by taking a coordinate and finding which polygon intersects with it. A lot of boundary data consists of multiple polygons and the geocoded coordinate for them is often placed in the geographic center of this boundary. Unfortunately, this location may not be within any of the polygons themselves. This could be one of the issues. There is an update to the geocoder coming soon which will likely resolve a lot of issues related to this.

    Also, by default only the first polygon is returned, if your boundary has multiple polygons, this could appear to be an issue. You can resolve this in the GeoData options.

    If however a boundary is being found when you do a search for it on it's own but it isn't found when searching multiple boundaries, then it is likely an issue with the request. Can you provide more details around how to making this request (sample code to reproduce).


    [Blog] [twitter] [LinkedIn]


    Monday, July 11, 2016 6:24 PM
  • The relevant code is shown below. It seems to work OK in that it does retrieve the county boundary polygons. As I said, Vermont works fine, New Hampshire not so fine.  Any chance the system will use FIPS codes as county an id (as they are unique for each county, i.e. Orange County, CA = 06059).

    Input List of NH counties retrieved from a ListBox and collected into one long string

    Belknap, NH| Carroll, NH| Cheshire, NH| Coos, NH| Grafton, NH| Hillsborough, NH| Merrimack, NH| Rockingham, NH| Strafford, NH| Sullivan, NH

    List after using split statement in javascript  (which turns string into array using  ,  as separator)

    Belknap, NH, Carroll, NH, Cheshire, NH, Coos, NH, Grafton, NH, Hillsborough, NH, Merrimack, NH, Rockingham, NH, Strafford, NH, Sullivan, NH

    Merrimack, NH - the missing polygon county

    The code

       //Loop through all the counties
                  var geoDataRequestOptions = {
                      entityType: 'AdminDivision2'
                  };
                  var returnStr = '<%=strCounties%>';
                  var countyCodes =  returnStr.split("|");   
                document.getElementById('Textbox_strCounties0').value = countyCodes;
                  map = new Microsoft.Maps.Map(document.getElementById('myMap'), { credentials: 'My Bing Maps Key' });
                  var lat = parseFloat(document.getElementById('Latitude').value);
                  var long = parseFloat(document.getElementById('Longitude').value);
                  var z2 = parseFloat(document.getElementById('Zoom').value);
                  map.setView({ zoom: z2, center: new Microsoft.Maps.Location(lat, long) });
                  Microsoft.Maps.loadModule('Microsoft.Maps.SpatialDataService', function () {
                      //Use the GeoData API manager to get the boundary
                      Microsoft.Maps.SpatialDataService.GeoDataAPIManager.getBoundary(countyCodes, geoDataRequestOptions, map, function (data) {
                          if (data.results && data.results.length > 0) {
                              map.entities.push(data.results[0].Polygons);                 
                          }
                      });
           
                  });


    • Edited by Ricky_Brundritt Tuesday, July 12, 2016 2:35 PM removed bing maps key
    Monday, July 11, 2016 10:47 PM
  • I've tried your code and am seeing a result for Merrimack, NH every time.

    However, I don't suspect this is the boundary you are expecting. The issue is that there is also a city called Merrimack, NH which has a higher rank in the geocoder. As such it's coordinate is being used to retrieve the country boundary that it intersects. However, changing your query to "Merrick County, NH" retrieves the boundary you are likely looking for:


    [Blog] [twitter] [LinkedIn]


    • Edited by Ricky_Brundritt Tuesday, July 12, 2016 2:43 PM
    • Proposed as answer by Ricky_Brundritt Tuesday, July 12, 2016 2:43 PM
    • Marked as answer by dcmap2 Tuesday, July 12, 2016 10:25 PM
    Tuesday, July 12, 2016 2:38 PM
  • Adding 'County' after the county name is what I will try next.  Great suggestion.

    Odd to me that the geocoder rank doesn't automatically search only counties when 'AdminDivision2' is used.

    Thanks for the help.

    Tuesday, July 12, 2016 10:28 PM
  • When you use the GeoData API it doesn't use the EntityType value when searching. The entity value is only used for selecting which polygon to retrieve that intersects the coordinates of the geocoded location. This is useful if for example you want the boundary of an entity type that is different from your query, for example get the city boundary for a zip code.

    [Blog] [twitter] [LinkedIn]

    Tuesday, July 12, 2016 10:49 PM
  • Your suggestions work great.  Thank you for your help.
    Wednesday, July 13, 2016 12:43 AM