CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • Legislative Districts Progress?
Pages: 1 [2]

Author Topic: Legislative Districts Progress?  (Read 9793 times)

Blake

  • I post occasionally
  • **
  • Posts: 36
  • Karma: 5
    • LinkedIn Profile
Re: Legislative Districts Progress?
July 07, 2009, 12:02:13 pm
@korzen: Keep us posted on your progress.

korzen

  • Guest
Re: Legislative Districts Progress?
December 13, 2009, 06:57:28 pm
Sorry for the late reply, folks...

It's true that some zips straddle more than one legislative district, but the vast majority don't (some states only have one district).

I couldn't see where the Activism Sunlight integration has been released yet, so I'm attaching is a script that will populate a field of your choice in the civicrm_contact table with a legislative district state and number (e.g. "CO1", "NY12").  This uses the Sunlight Labs API's getDistrictsFromZip function.  It's a total hack, but it works in a pinch.

To use:

- Register for a Sunlight Labs API key:  http://services.sunlightlabs.com/api/register/.
- Set the variables in the attached file.  For $target_field I've used legal_identifier, but any blank field will do.
- Drop this on your web server and rename with a .php extension (preferably in a password-protected dir).
- Open the file in your web browser or wget from the command line.

Once you've populated all the records for which you have zips, you might need to run some queries to add contacts living in the districts you want to hit to separate groups; then you send email blasts to these groups.  Yes, you'll have to requery each time you want to do legislative district-focused emails.  And yes, for big lists this will take a long time.

Warnings:

-  Don't use this unless you know what you're doing.
-  Back up your db first!

Areas for Improvement:

-  Sunlight has a query that returns results by latitude/longitude.  That would perhaps be more accurate than a zip code when used with geocoded records.
-  Sunlight also has a getZipsFromDistrict function.  This would be useful if you only want to tag records for targeted districts, rather than updating your entire list.
-  If only targeting a few districts it would be easy to programmatically drop these records right into groups.  (If you're a national org, you wouldn't want 538 separate groups muddling up your db!)

We've also got some code that creates a nice little tool to allow users to look up their legislators by zip.  The result links right through to the legislators' online contact forms.  If folks are interested I can post that too.

Activism module folks:  we've got some other code we're running that effectively creates civicrm-integrated online petitions; we're going to be integrating this with some neat-o e-mail functions.  Would love to work with you on maybe building some of this into your next release.

Enjoy!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Legislative Districts Progress?
December 14, 2009, 07:00:23 am

hey gill:

would be great if you could blog about this in detail and also attach your code (or a link to your code), released under an open source license (http://civicrm.org/licensing)

I've given you blogging privileges at: http://civicrm.org/blog/5135/

Would also be good to describe in detail some of the stuff you've done with the activism module and some of the changes you are planning on
doing

cool to see you step up and tackle the below issues. More and more folks are asking for them :)

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Denver Dave

  • Ask me questions
  • ****
  • Posts: 471
  • Karma: 9
Re: Legislative Districts Progress?
December 14, 2009, 10:29:21 am
In Colorado, 9 digit zips define political districts, but 5 digit zips frequently span.

gill korzen

  • Guest
Re: Legislative Districts Progress?
December 14, 2009, 10:38:36 am
Yeah, the more I think of it Geocode really is the way to go, since that functionality already exists in CiviCRM.  I'll take a look at making that tweak and getting it up on the blog (thanks Donald).

Dave:  hello from Summit County!

BE55Roberts

  • Guest
Re: Legislative Districts Progress?
June 10, 2010, 06:50:55 am
How about Zipcode Plus 4? Seems like that would further isolate an address down to the cluster of street level. Would that not then map to a particular legislative district?

Denver Dave

  • Ask me questions
  • ****
  • Posts: 471
  • Karma: 9
Re: Legislative Districts Progress?
June 10, 2010, 07:52:05 am
In Colorado the 9 digit zipcode is the way to go and then interface into a service like
VoteSmart.com
http://www.votesmart.org/search_zipcode.php?search=80209-4621&go=Vote-Smart+Info

or this service for Colorado
http://capwiz.com/thenationalcouncil/co/directory/statedir.tt?lvl=state&state=CO&action=myreps&myzip=80209&submit=GO

With the 2010 Census and redistricting.  The political district assignment will have to all be re-done.

BE55Roberts

  • Guest
Re: Legislative Districts Progress?
June 19, 2010, 02:13:08 am
What about ZipCode+4 values? As I understand it, the 9 digits take you down to the carrier route level, which may be a single street or neighborhood. Would that not be sufficient to identify a specific legislative district? Of course, this would vary from state to state, depending on the gerrymandering at work. But on the whole, I would expect that it would be a reasonable way to identify the district information. Obviously, you would then need a zipcode lookup table and some code to read it. However, the performance should be pretty good, since you would only have to do a single lookup to get the districts to display. Anybody tried this approach?

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • Legislative Districts Progress?

This forum was archived on 2017-11-26.