none
Count of shape provide by using census data is proper or not RRS feed

Answers

All replies

  • Hi Vikas,

    I am not sure what is being asked here.  Can you clarify the programming problem you are having?  The Census Data is provided to Microsoft by the US Census department so you have a question on Census data, you probably want to reach out to them.

    Sincerely,

    IoTGirl

    Friday, February 22, 2019 7:36 PM
    Owner
  • The reason for what you’re getting is that you have taken sample code that was for US states boundaries and just replaced query URL with other data sources.
    If you look at the top property of the QueryAPIOptions object you will see that it has value 52, and this is what you getting now for other US Census data.
    Note that there are 435 congressional districts, around 3,200 counties and around 32,000 ZIP Code Tabulation Areas (ZCTAs).
    The Query API allows a maximum of 250 results to be returned in a single request. To get more data you can use skip parameter, this is documented here: https://docs.microsoft.com/en-us/bingmaps/v8-web-control/modules/spatial-data-service-module/queryapioptions-object.

    Check following code samples:
    http://bingmapsv8samples.azurewebsites.net/#Load%20all%20results%20(parallel)
    http://bingmapsv8samples.azurewebsites.net/#Load%20all%20results%20(recursive)

    Also loading all 32,000 ZCTAs for whole country might not be good idea as it will be slow.


    Friday, February 22, 2019 9:43 PM
    Moderator
  • Thanks for the great answer S1mon_!
    Saturday, February 23, 2019 1:02 AM
    Owner
  • Except shapes count for states, other numbers are way off from what I'm getting when I tested it, for example for counties I'm getting 3282 shapes.

    It looks like issue is somewhere on your side, are you using code from samples that I've shared before or your own code? Also check in browsers developer’s tool network tab if you see any failed calls.

    Tuesday, February 26, 2019 7:41 AM
    Moderator
  • hi,

    we are using below sample code:

    https://www.bing.com/api/maps/sdk/mapcontrol/isdk#sdsChoroplethMap+JS

    In above code below link use for USA census data 

    https://spatial.virtualearth.net/REST/v1/data/755aa60032b24cb1bfb54e8a6d59c229/USCensus2010_States/States

    Count of Shape :- 132

    Thanks!

    Tuesday, February 26, 2019 9:59 AM
  • Hi S1mon,

    Thanks for your reply.

    We have checked code sample on below link

    http://bingmapsv8samples.azurewebsites.net/#Load%20all%20results%20(parallel)

    With the help of that we are only able to plot the area shown below

    but we want whole area of US. We tried to change the center properties and other filter but it did not shown proper result.

    Can you please let us know how to plot whole US zipcode.

    Waiting for your reply.

    Thanks! 


    Balasaheb

    Wednesday, February 27, 2019 7:26 AM
  • Can you post your code with changes that you've mentioned.

    For such big number of polygons I would use recursive sample, and I already mentioned that this will be slow.
    I tested it and it was more than 40MB of data.
    Also note that ZCTAs are not the same as ZIP codes: https://en.wikipedia.org/wiki/ZIP_Code_Tabulation_Area.


    Wednesday, February 27, 2019 3:52 PM
    Moderator
  • Hi S1mon,

    Thanks for your reply.

    We have used below code 

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta charset="utf-8" />
        <script type='text/javascript'>
        var map;
        //Query URL to the 2010 US Census Zip Code tabulation areas data source
        var sdsDataSourceUrl = 'https://spatial.virtualearth.net/REST/v1/data/f42cab32d0ee41738d90856badd638d3/USCensus2010_ZCTA5/ZCTA5';
        function GetMap() {
            map = new Microsoft.Maps.Map('#myMap', {
                center: new Microsoft.Maps.Location(40.10, -82.80),
                zoom: 7
            });
            var _results = [];
            var worldBounds = Microsoft.Maps.LocationRect.fromEdges(90, -180, -90, 180);
            //Load the Bing Spatial Data Services module.
            Microsoft.Maps.loadModule('Microsoft.Maps.SpatialDataService', function () {
                //Create a query to get zip code tabulation areas in view.
                var query = {
                    queryUrl: sdsDataSourceUrl,
                    inlineCount: true,
                    skip: 0,
                    top: 250,
                    spatialFilter: {
                        spatialFilterType: 'intersects',
                        intersects: worldBounds
                    }
                };
                //Trigger an initial search.
                try {
                    Microsoft.Maps.SpatialDataService.QueryAPIManager.search(query, map, function (data, inlineCount) {
                        // var results = data;
                        var pages = Math.ceil(inlineCount / query.top);
                        var pagesLoaded = 1;
                        //Now that we know how may results there are, make multiple requests in parallel.
                        for (var i = 1; i < pages; i++) {
                            Microsoft.Maps.SpatialDataService.QueryAPIManager.search({
                                queryUrl: sdsDataSourceUrl,
                                inlineCount: true,
                                skip: 250 * i,
                                top: 250,
                                spatialFilter: {
                                    spatialFilterType: 'intersects',
                                    // intersects: map.getBounds()
                                    intersects: worldBounds
                                }
                            }, map, function (data, inlineCount) {
                                pagesLoaded++;
                                //Concatenate the results
                                _results = _results.concat(data);
                                //Check to see if all result pages have been loaded.
                                if (pagesLoaded == pages) {
                                    //Add all the results to the map.
                                    map.entities.push(_results);
                                }
                            });
                        }
                    });
                } catch (e) {
                    alert(e.message);
                }
            });
        }
        </script>
        <script type='text/javascript' src='https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key= Our bing map key ' async defer></script>
    </head>
    <body>
        <div id="myMap" style=";width:800px;height:600px;"></div>    
    </body>
    </html>

    We are getting below error in console.

    Is it possible to send your sample code. Did you got above error and you have solution for above error.

    Waiting for your reply.

    Thanks!



    Balasaheb

    Thursday, February 28, 2019 5:54 AM
  • I've used recursive sample: http://bingmapsv8samples.azurewebsites.net/#Load%20all%20results%20(recursive)
    Thursday, February 28, 2019 4:02 PM
    Moderator
  • Hi S1mon,

    Thanks for your reply. We are able to plot the whole zipcode of US.

    Thanks!


    Balasaheb

    Friday, March 1, 2019 10:15 AM