0% found this document useful (0 votes)
52 views7 pages

Census Geocoder API: Onelineaddress Example

The document describes a geocoding API that takes addresses as input and returns their corresponding latitude and longitude coordinates. It provides services for single address geocoding as well as batch geocoding of multiple addresses. The API response includes the geocoded location coordinates and optionally additional geographic context about locations.

Uploaded by

Steven Flood
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views7 pages

Census Geocoder API: Onelineaddress Example

The document describes a geocoding API that takes addresses as input and returns their corresponding latitude and longitude coordinates. It provides services for single address geocoding as well as batch geocoding of multiple addresses. The API response includes the geocoded location coordinates and optionally additional geographic context about locations.

Uploaded by

Steven Flood
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Geocoding Services

Web Application Programming Interface (API)


Last updated 07/2021
______________________________________________________________________________

Contents
Geocoding Definition............................................................................................................................... 1
Audience ................................................................................................................................................. 1
Single Record Geocoding Service Requests .............................................................................................. 1
Required Parameters ........................................................................................................................... 2
Optional Parameters ........................................................................................................................... 2
Geocoding Service Responses .................................................................................................................. 3
JSON Output Format............................................................................................................................ 3
Batch Geocoding ..................................................................................................................................... 5
Required Parameters ........................................................................................................................... 6
Example Shell Script Submission .......................................................................................................... 6
Geocoding Definition
Geocoding is the process of taking an address and returning an actual or calculated latitude/longitude
coordinate. Depending on the parts of the address that are provided, determines to what granularity it
is possible to geocode.

The current Geocoding Services engine requires a structure address be provided. The resulting lat/long
is calculated along an address range.

There are two entry points for the geocoding service – single record submission and batch.

The acceptable input address parts are:

• Structure number and street name (required)


• City name (optional)
• State (optional)
• ZIP code (optional)

The single record service allows for all of these parts to be submitted in a single line, or as separate
fields. The batch requires each field to exist (either with text or blank) in a delimited form, preceded by
a unique ID.

Audience
This document is intended for application, website, and mobile developers within the U.S. Census
Bureau and the general public who want to leverage the Geocoding Services capability.

This service is designed for coding a provided address, or file of addresses, to a latitude/longitude
coordinate based on data that’s been loaded into the geocoding engine from a MAF/TIGER benchmark
database.

The optional inclusion of the Geographic Lookup (geoLookup) adds information to the result relating to
various levels of geography that cover the aforementioned latitude/longitude coordinate. GeoLookup
results can also be obtained directly by searching on the latitude/longitude coordinates.

Single Record Geocoding Service Requests


A Geocoding Service API request must be in the following form:

[Link]

1
Required Parameters
• returntype – locations (to get just geocoding response) or geographies (to get geocoding
response as well as geoLookup)
• searchtype – onelineaddress OR address OR coordinates
• benchmark – A numerical ID or name that references what version of the locator should be
searched. This generally corresponds to MTDB data which is benchmarked twice yearly. A full
list of options can be accessed at [Link] The
general format of the name is DatasetType_SpatialBenchmark. The valid values for these
include:
o DatasetType
▪ Public_AR
o SpatialBenchmark
▪ Current
▪ ACS2021
▪ Census2020
So a resulting benchmark name could be “Public_AR_Current”, “Public_AR_ACS2021”, etc. Over
time, there will always be a “Current” benchmark. It will change as the underlying dataset
changes.
• vintage – a numerical ID or name that references what vintage of geography is desired for
the geoLookup (only needed when returntype = geographies). A full list of options for a given
benchmark can be accessed at
[Link] The general
format of the name is GeographyVintage_SpatialBenchmark. The SpatialBenchmark variable
should always match the same named variable in what was chosen for the benchmark
parameter. The GeographyVintage can be Current, ACS2021, etc. So a resulting vintage name
could be “ACS2021_Current”, “Current_ACS2021”, etc. Over time, there will always be a
“Current” vintage. It will change as the underlying dataset changes.
• address (searchtype = onelineaddress) – A single line containing the full address
to be searched
OR
• street, city, state, zip (searchtype = address) – The address split into
the parts indicated. Not all parts need to be specified.
• x,y (searchtype = coordinates) – The longitude and latitude represented as
decimal x/y values. Only returns geoLookup data. Can only be used with returntype =
geographies.

Optional Parameters
• format – The format to be used for returning the standardized output (json, html).
• layers – By default, State, County, Tract, and Block layers are displayed when “geographies”
is the chosen returntype. If additional or different layers are desired, they can be specified in a
comma delimited list by ID or name as listed in the TigerWeb WMS layers, for instance here:

2
[Link]
r
a valid entry could be: layers=14,16,18 OR layers=Unified School Districts,Secondary School
Districts,Elementary School Districts. Only layers without the word “Labels” are considered. If
all layers are desired, layers=all is an accepted entry.
In cases where the SpatialBenchmark selected is Census2020, the TIGERweb WMS needed is:
[Link]
Server

Geocoding Service Responses


Geocoding Services responses are returned in the format indicated by the format parameter value in
the URL request’s path.

JSON Output Format


In this example, Geocoding Services API requests a json response for the address “4600 Silver Hill Rd,
Washington, DC 20233”:

[Link]
l+Rd%2C+Washington%2C+DC+20233&benchmark=2020&format=json

Other valid examples:

[Link]
= Washington&state=DC&zip=20233&benchmark=Public_AR_Census2020&format=json

[Link]
=Washington&state=DC&benchmark=2020&format=json

The JSON returned by this request is shown below. Note the actual JSON may contain less whitespace.
You should not make assumptions about the amount or format of whitespace in requests.

{"result": {
"input": {
"address": {"address": "4600 Silver Hill Rd, Washington, DC 20233"},
"benchmark": {
"isDefault": false,
"benchmarkDescription": "Public Address Ranges - Census 2020 Benchmark",
"id": "2020",
"benchmarkName": "Public_AR_Census2020"

3
}
},
"addressMatches": [{
"tigerLine": {
"side": "L",
"tigerLineId": "76355984"
},
"coordinates": {
"x": -76.92744,
"y": 38.845985
},
"addressComponents": {
"zip": "20233",
"streetName": "SILVER HILL",
"preType": "",
"city": "WASHINGTON",
"preDirection": "",
"suffixDirection": "",
"fromAddress": "4600",
"state": "DC",
"suffixType": "RD",
"toAddress": "4700",
"suffixQualifier": "",
"preQualifier": ""
},
"matchedAddress": "4600 SILVER HILL RD, WASHINGTON, DC, 20233"
}]
}}

Examples using geoLookup:

[Link]
city=Washington&state=DC&benchmark=Public_AR_Census2020&vintage=Census2020_Census2020&la
yers=10&format=json

Additional JSON response data for geoLookup:

"geographies": {"Census Blocks": [{


"SUFFIX": "",
"POP100": "",
"GEOID": "240338024052004",
"CENTLAT": "+38.8516945",
"BLOCK": "2004",
"AREAWATER": 2970,
"STATE": "24",
"BASENAME": "2004",
"OID": 210701008482815,
"LSADC": "BK",
"FUNCSTAT": "S",

4
"INTPTLAT": "+38.8522266",
"NAME": "Block 2004",
"OBJECTID": 1679586,
"TRACT": "802405",
"CENTLON": "-076.9402961",
"BLKGRP": "2",
"AREALAND": 1745386,
"HU100": "",
"INTPTLON": "-076.9378719",
"MTFCC": "G5040",
"LWBLKTYP": "B",
"UR": "",
"COUNTY": "033"
}]}

Examples using geoLookup and benchmark Public_AR_Census2020 and vintage


Census2010_Census2020 to get 2010 blocks:

[Link]
hill+rd%2C+20233&benchmark=2020&vintage=2010&format=json

[Link]
hill+rd%2C+20233&benchmark=Public_AR_Census2020&vintage=Census2010_Census2020&format=jso
n

If a JSONP-formatted result is desired/required, the format=jsonp can be specified with a


corresponding Javascript callback method on the request.

Batch Geocoding
Geocoding can be accomplished in batch mode with submission of a .CSV, .TXT, .DAT, .XLS, or .XLSX
formatted file. The file needs to be included as part of the HTTP request.

The file must be formatted in the following way:

Unique ID, Street address, City, State, ZIP

If a component is missing from the dataset, it must still retain the delimited format with a null value.
Unique ID and Street address are required fields.

If there are commas that are part of one of the fields, the whole field needs to be enclosed in quote
marks for proper parsing.

There is currently an upper limit of 10,000 records per batch file.

The URL is as follows:

5
[Link] /addressbatch

Required Parameters
• returntype – locations (to get just geocoding response) or geographies (to get geocoding
response as well as geoLookup). Independent geoLookup (“coordinates” above) is not currently
an available batch option.
• benchmark – A numerical ID or name that references what version of the locator should be
searched. This generally corresponds to MTDB data which is benchmarked twice yearly. A full
list of options can be accessed at [Link] The
general format of the name is DatasetType_SpatialBenchmark. The valid values for these
include:
o DatasetType
▪ Public_AR
o SpatialBenchmark
▪ Current
▪ ACS2021
▪ Census2020
So a resulting benchmark name could be “Public_AR_Current”, “Public_AR_ACS2021”, etc. Over
time, there will always be a “Current” benchmark. It will change as the underlying dataset
changes.
• vintage – a numerical ID or name that references what vintage of geography is desired for
the geoLookup (only needed when returntype = geographies). A full list of options for a given
benchmark can be accessed at
[Link] The general
format of the name is GeographyVintage_SpatialBenchmark. The SpatialBenchmark variable
should always match the same named variable in what was chosen for the benchmark
parameter. The GeographyVintage can be Current, ACS2021, etc. So a resulting vintage name
could be “ACS2021_Current”, “Current_ ACS2021”, etc. Over time, there will always be a
“Current” vintage. It will change as the underlying dataset changes.
• addressFile – An input of type “file” containing the addresses to be coded

Example Shell Script Submission


curl --form addressFile=@[Link] --form benchmark=2020
[Link] --output [Link]

Common questions

Powered by AI

Batch geocoding requires a file input format, allowing up to 10,000 address records, while single record geocoding allows for online address input through a URL request. The batch input file must include a Unique ID and Street address for each record, whereas single record requests can use either a full address line or separate address components like street, city, state, and ZIP. In terms of output, batch geocoding is limited by its size constraint and does not support independent geoLookup through coordinates, unlike single record geocoding which can also return geoLookup results based on specific coordinates .

The API requires that all address components retain the correct delimited format even if some components are missing. For instance, in batch mode, a CSV file must maintain fields for the Unique ID, Street address, City, State, and ZIP, even if a field doesn't contain any information, it should be left blank to preserve the file structure. This ensures the parser functions correctly, avoiding errors in data interpretation during the geocoding process .

Both 'benchmark' and 'vintage' are necessary parameters because they independently define the dataset version used for spatial indexation and the timeframe of geographical data, respectively. The benchmark determines the larger dataset from which geocoding will search for matches based on the current or specific datasets, while the vintage decides the temporal context of the geographical boundaries used in geoLookup. They complement each other by ensuring that both the spatial and temporal aspects of the geocoding and geoLookup processes are aligned, ensuring that users can correlate location data with the corresponding geographical context effectively .

Optional parameters in the Geocoding Services API allow users to customize the format and extent of the output data. For example, the 'format' parameter dictates the structure of the output data (JSON or HTML), and the 'layers' parameter specifies the TIGERweb WMS layers to include when 'geographies' is the chosen returntype. These parameters offer flexibility, enabling users to tailor the results to meet specific needs, such as viewing additional geographical layers that are not displayed by default .

Challenges in submitting a request for batch processing include maintaining the correct file format, limited record numbers (max 10,000), and ensuring all necessary fields are present. Solutions involve using correct CSV formatting with delimiters properly placed even for missing data, splitting large datasets into smaller batches, and ensuring each record contains a Unique ID and Street address, as these are essential for processing. Attention to details like enclosing fields with extra commas in quotes and using a dedicated script or tool to handle HTTP requests can also prevent errors during the geocoding process .

The 'vintage' parameter specifies the desired version of geographical data for geoLookup results and is used in conjunction with the 'benchmark' parameter. It determines which historical or current data set to apply in the geoLookup, just as the benchmark defines the spatial dataset for geocoding. The vintage should match the SpatialBenchmark chosen in the benchmark parameter to ensure consistent and coherent results. For example, a vintage name might be 'ACS2021_Current', reflecting the alignment with the benchmark structure .

Using different 'layers' in geoLookup responses allows users to receive customized geographical data specific to their analysis needs. Each layer represents a different geographic dataset level, such as State or County, which can be specified in the API request. These layers can be critical for targeted geographic analyses, such as demographic studies or regional planning, by providing an additional context that can be cross-referenced with other datasets. Additionally, selecting the appropriate layers allows for data filtering, limiting excess data and focusing on areas pertinent to the user's project .

The 'benchmark' parameter in the Geocoding Services API specifies the version of the locator to be used when searching for geocoding results. It corresponds to the MTDB data, which is updated twice a year. The benchmark affects the geocoding results as it determines the underlying dataset that the geocoder uses to provide latitude and longitude coordinates for an address. Different benchmarks may reflect different datasets, leading to slight variations in the geocoding output. The format for specifying the benchmark is DatasetType_SpatialBenchmark, such as 'Public_AR_Current'. Over time, the 'Current' benchmark will change as the dataset is updated .

The JSON format is valuable for developers because it is a lightweight, widely recognized data interchange format that is easy to parse and manipulate using various programming languages. This makes it especially useful for integrating geocoding results into applications or websites. When processing JSON data, developers should consider the structure of the JSON response, handle data parsing errors, ensure the accuracy of data mapping to database fields or user interfaces, and account for variations in whitespace or data fields that could impact data integrity within the application .

The 'geoLookup' feature enhances geocoding results by providing additional geographical context and information about the location of the provided address. It adds data relating to various geographical levels, such as census blocks, tracts, and other administrative boundaries that cover the latitude/longitude obtained from geocoding. This feature is particularly useful for applications requiring detailed geographical analysis or integration with other geographic information systems, allowing for more comprehensive insights beyond just the coordinate data .

You might also like