aboutsummaryrefslogtreecommitdiff
path: root/content/posts/2022-11-11-census-geocoder-released.md
blob: 11f9740fa639b573e005d0e4afe22c9b834f50f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
slug: census-geocoder-released
title: "Census Geocoder Released"
date: "2022-11-11T11:34:25-04:00"
---
A couple weeks ago I released [census-geocoder][git], a [Go][] wrapper
for the [Census Geocoding Services API][census-api].

### Example

Here's an example application which geocodes the command-line argument
and then prints the normalized address from the geocoding result of each
address to standard output:

```go
package main

import (
  "fmt"
  "log"
  "os"
  "pablotron.org/census-geocoder/geocoder"
)

func main() {
  for _, arg := range(os.Args[1:]) {
    // get address matches
    matches, err := geocoder.Locations(arg)
    if err != nil {
      log.Fatal(err)
    }

    // print matches
    for _, match := range(matches) {
      fmt.Println(match)
    }
  }
}
```
 

### Links

* [Git repository][git]
* [Documentation][doc]

[go]: https://go.dev/
  "Go programming language"
[git]: https://github.com/pablotron/census-geocoder
  "census-geocoder git repository"
[doc]: https://pkg.go.dev/pablotron.org/census-geocoder/geocoder
  "census-geocoder package documentation"
[census-api]: https://geocoding.geo.census.gov/geocoder/Geocoding_Services_API.html
  "Census Geocoding Services API"