Vote up to Idea API extension for query across hierarchy Vote down to Idea API extension for query across hierarchy

Rank93

Idea#213

This idea is active.
API Technical Discussions »

API extension for query across hierarchy

Hi All,

The API has incredible functionality for query/results within the nested US Census Bureau Geography (e.g. getting data for all the tracts in a county or all the block groups within a track).

However, it does not appear to support queries that run across the same geography very well.

For instance It does not appear to allow me to query the same parameter (e.g. race) in Tract A within County B and Tract C within County D.

In using the API, it does not appear to recognize two items in the "in" statement. So for instance in=state:04,05&for=county:* will only return AZ counties, not AZ & AR counties.

Comment

Submitted by dgcatanzaro 5 months ago

Vote Activity

  1. Approved
    4 months ago

Events

  1. The idea was posted
    5 months ago

Comments (3)

  1. dgcatanzaro Idea Submitter

    I forgot to mention *why* this is important. The key is that when I want to query two Tracts that are geographically next to each other but in different Counties.

    If I wanted to do that query via the API, I believe it is two queries, not one.

    5 months ago
  2. dgcatanzaro,

    Hi. Thanks for your feedback. Your assessment is correct that one must currently submit two queries to get the value of a variable for tracts in two different counties. The ``in'' clause does not currently allow wildcards or multiple values for individual geography parts. One of our initial design goals for the API was to keep a simple URL grammar while providing very low per-query latency, which should limit the overhead of submitting two queries.

    We do plan to allow wildcards inside ``in'' clauses for certain geography hierarchies, however, allowing multiple values for individual geography parts is a bit tricky. Let's look at your tract example. Here are two queries for two tracts in separate counties:

    http://api.census.gov/data/2010/sf1?get=P0010001&for=tract:400600&in=state:06+county:001

    http://api.census.gov/data/2010/sf1?get=P0010001&for=tract:000103&in=state:06+county:007

    Notice that each query uses the ``in'' clause to fully qualify the specific tract from the ``for'' clause. Combining these into a single query is difficult because it would become ambiguous which county is used to fully qualify each tract. Now imagine that the states could also be different (different tracts from different counties in different states), and you'll see the problem becomes more difficult as the depth of the hierarchy increases.

    The best solution to this is to use fully qualified geography IDs. GNIS does exactly this, though only for a limited number of datasets and geography hierarchies.

    We have this feature request in our feature/bug tracking database. I suspect that we will add a query mechanism, at some later time, which will support multiple fully qualified FIPS codes. However, that is just speculation; I can't give you a timeframe. For now please just submit two separate queries.

    4 months ago
  3. dgcatanzaro Idea Submitter

    Hi Dave,

    Thanks for confirming what I had thought.

    I personally think that your fully qualified geography IDs has the most merit. I had hoped to do that using GNIS but unfortunately the geography I am interested in (tract) is not supported in GNIS.

    I think one way of supporting this type of query is to concatenate the state/county FIPS codes with the tract to obtain that unique number so if you supported tract=06001400600 and tract=06007000103 then a query such as:

    http://api.census.gov/data/2010/sf1?get=P0010001&cengeo=tract:06001400600,06007000103

    would work !

    4 months ago