Answers.Body: <p>Google’s Civic Information API returns information about federal, state, local governments, school districts, etc. It takes as input an address string (not a lat/long pair). An API key is needed, but it’s free to obtain and use. In what little experimenting I’ve done recently, average latency has been ~350 ms. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-02T02:12:14.087Z
Answers.Text: I wanted to make sure you're aware of the CiviCRM extension that provides Google Civic API integration: https://github.com/josephlacey/com.jlacey.electoral
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-01T22:14:58.867Z
Answers.LastActivityDate: 2019-03-01T22:14:58.867Z
Answers.UserDisplayName: Steve Hirby
Answers.Body: <p>I can share some experience from such a project a few years back. It required a fair bit of custom code implemented for that site, but ultimately your task would boil down to something like:</p>
  
  <ul>
  <li>Identify contacts who you want to look up (eg, <em>contacts with a state of VA and who don't already have custom data in custom field "District"</em>).</li>
  <li>For each contact, ensure they meet minimum criteria (eg try geocoding the address first, do what you need to handle contacts whose address does not)</li>
  <li>Once you have lat/long for the contact, look them up in a service capable of returning a value for the district. Options here vary - we used <a href="https://koordinates.com/about/" rel="nofollow noreferrer">Koordinates</a> originally (accepts KML, lets you query against it), but there are other options and that project eventually switched to an SQL approach.</li>
  <li>Store the results of this lookup against the contact.</li>
  </ul>
  
  <p>Other considerations -</p>
  
  <ul>
  <li>How fast do you need to look up all the voters, and how performant is the lookup method? Do you need to invest time up front in mapping addresses to districts, or will a web service like Koordinates save you dev time/expense and let you work through the number of voter contacts required?</li>
  <li>Does every contact's default address map to their voter registered address / are there cases where you have an address on file that doesn't map to their voting district? How do you handle these?</li>
  <li>Do you want to permit "custom" values, eg "Bob is special, don't overwrite the district he's associated with because he chairs a neighbouring district" etc.</li>
  <li>What happens when district boundaries change?</li>
  </ul>
  
  <p>This isn't a built-in functionality and I'm not aware of a published extension.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-17T21:51:36.073Z
Answers.Text: `<promo>` If you want to discuss implementation, I'm sure you can track me or my employer [Fuzion](https://fuzion.co.nz) down :) ... if anyone finds _this comment_ too advertorial, downvote it and I'll remove it ASAP!
Answers.UserDisplayName: Chris Burgess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-17T21:50:28.643Z
Answers.LastActivityDate: 2017-01-17T21:50:28.643Z
Answers.UserDisplayName: Chris Burgess
Body: <p>we use civicrm for a political org, and I'm trying to find out how to add voter district information to contacts in database. </p>
  
  <p>The state doesn't have a public API from what I can tell. They have this website: <a href="http://whosmy.virginiageneralassembly.gov/" rel="noreferrer">http://whosmy.virginiageneralassembly.gov/</a>, but getting the info out of this site would require some python scripting, and I don't know how to automate the export and reimport of the contact records. </p>
  
  <p>There are KML files available from the census (<a href="https://www.census.gov/geo/maps-data/data/kml/kml_sld.html" rel="noreferrer">https://www.census.gov/geo/maps-data/data/kml/kml_sld.html</a>) that provide the boundaries for the districts. I'm wondering if anyone has advice on modules or approaches to take a contact's geocode address and determine which district boundary it falls in. </p>
  
  <p>Thanks, </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-18T03:42:42.437Z
Comments.Text: I found an API that will return legislators based on geocode search. I think we'll work with this, but there's so much more to figure out.
  
  http://docs.openstates.org/api/legislators.html#legislator-geo
Comments.UserDisplayName: dahifi
Tags: <contacts>
Title: Identifying contact voting district from KML data or from state website
ThreadText: # Identifying contact voting district from KML data or from state website
  
  (Asked by: username_0 on 2017-01-17)
  
  we use civicrm for a political org, and I'm trying to find out how to add voter district information to contacts in database.
  
  The state doesn't have a public API from what I can tell. They have this website: <http://whosmy.virginiageneralassembly.gov/>, but getting the info out of this site would require some python scripting, and I don't know how to automate the export and reimport of the contact records.
  
  There are KML files available from the census (<https://www.census.gov/geo/maps-data/data/kml/kml_sld.html>) that provide the boundaries for the districts. I'm wondering if anyone has advice on modules or approaches to take a contact's geocode address and determine which district boundary it falls in.
  
  Thanks,
  
  **Tags:** contacts
  
  > **Comments:**
  > **username_0**: I found an API that will return legislators based on geocode search. I think we'll work with this, but there's so much more to figure out.  http://docs.openstates.org/api/legislators.html#legislator-geo  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-03-01. Score: 3
  
  Google’s Civic Information API returns information about federal, state, local governments, school districts, etc. It takes as input an address string (not a lat/long pair). An API key is needed, but it’s free to obtain and use. In what little experimenting I’ve done recently, average latency has been ~350 ms.
  
  > **Comments:**
  > **username_2**: I wanted to make sure you're aware of the CiviCRM extension that provides Google Civic API integration: https://github.com/josephlacey/com.jlacey.electoral  
  
  ---
  
  ### Answer by username_3 on 2017-01-17. Score: 1
  
  I can share some experience from such a project a few years back. It required a fair bit of custom code implemented for that site, but ultimately your task would boil down to something like:
  
  * Identify contacts who you want to look up (eg, *contacts with a state of VA and who don't already have custom data in custom field "District"*).
  * For each contact, ensure they meet minimum criteria (eg try geocoding the address first, do what you need to handle contacts whose address does not)
  * Once you have lat/long for the contact, look them up in a service capable of returning a value for the district. Options here vary - we used [Koordinates](https://koordinates.com/about/) originally (accepts KML, lets you query against it), but there are other options and that project eventually switched to an SQL approach.
  * Store the results of this lookup against the contact.
  
  Other considerations -
  
  * How fast do you need to look up all the voters, and how performant is the lookup method? Do you need to invest time up front in mapping addresses to districts, or will a web service like Koordinates save you dev time/expense and let you work through the number of voter contacts required?
  * Does every contact's default address map to their voter registered address / are there cases where you have an address on file that doesn't map to their voting district? How do you handle these?
  * Do you want to permit "custom" values, eg "Bob is special, don't overwrite the district he's associated with because he chairs a neighbouring district" etc.
  * What happens when district boundaries change?
  
  This isn't a built-in functionality and I'm not aware of a published extension.
  
  > **Comments:**
  > **username_3**: `<promo>` If you want to discuss implementation, I'm sure you can track me or my employer [Fuzion](https://fuzion.co.nz) down :) ... if anyone finds _this comment_ too advertorial, downvote it and I'll remove it ASAP!  
  
  ---
  
  