Wednesday, April 5, 2017

Voting Districts Day 9: Back to Python for Mapping

Because of the large size of the resulting JSON file, I don't think I'm going to be able to use the leafletjs javascript module to create a map.  I think that Python is my best bet.  

Mapping in Python might not be so bad anyway.  Matplotlib has a bunch of tools available, particularly modules Basemap and pyplot.  

This page has a lot of great examples that I can use to better understand what's going on.  The trick, though, is getting my shapefile read into it...

Looking at the documentation, I have to figure out some way of dealing with projections again.  My voter district shapefile isn't the standard lat/long values. 
Pyproj has a great method where you can set the inverse property and spit out lat long coordinates from the weird NC coordinates.  So, I'll create a big list of all the coordinates of all the shapes after running them through this method.

import shapefile
from pyproj import Proj

vote = shapefile.Reader('ncsbe\\Precincts.shp') #creates an instance that has the lists of data we want.

shapes = vote.shapes() #create lists of coordinates making up the shape for each voting district.
#for each shape in the shapefile...
for x in range(0,len(shapes)):
    #for each point in the shape...
    for y in range(0,len(shapes[x].points)):

        lon, lat = nc(shapes[x].points[y][0], shapes[x].points[y][1], inverse=True) #convert the shape file points into traditional lat/long coords.

and that's going to give me some data that I can plot according to the documentation in matplotlib (I think).

2 comments:

terry james said...

I'm very excited to inform everyone that I'm completely cured from my HSV 1&2 recently. I have used Oregano oil, Coconut oil, Acyclovir, Val acyclovir, Famciclovir , and some other products and it's really help during my outbreaks but I totally got cured from my HSV 2 with a strong and active herbal medicine ordered from a powerful herbalist and it completely fought the virus from my nervous system and I was tested negative after three weeks of usage. I'm here to let y'all know that HSV 1& 2 has a complete cure, I got rid of mine with the help of Dr Moses Buba and his herbal exploit, AFTER I engage with other wrong doctors. Contact him via email: buba.herbalmiraclemedicine@gmail.com or Call/WhatsApp him at +2349060529305
thank you..







I'm very excited to inform everyone that I'm completely cured from my HSV 1&2 recently. I have used Oregano oil, Coconut oil, Acyclovir, Val acyclovir, Famciclovir , and some other products and it's really help during my outbreaks but I totally got cured from my HSV 2 with a strong and active herbal medicine ordered from a powerful herbalist and it completely fought the virus from my nervous system and I was tested negative after three weeks of usage. I'm here to let y'all know that HSV 1& 2 has a complete cure, I got rid of mine with the help of Dr Moses Buba and his herbal exploit, AFTER I engage with other wrong doctors. Contact him via email: buba.herbalmiraclemedicine@gmail.com or Call/WhatsApp him at +2349060529305
thank you..















I'm very excited to inform everyone that I'm completely cured from my HSV 1&2 recently. I have used Oregano oil, Coconut oil, Acyclovir, Val acyclovir, Famciclovir , and some other products and it's really help during my outbreaks but I totally got cured from my HSV 2 with a strong and active herbal medicine ordered from a powerful herbalist and it completely fought the virus from my nervous system and I was tested negative after three weeks of usage. I'm here to let y'all know that HSV 1& 2 has a complete cure, I got rid of mine with the help of Dr Moses Buba and his herbal exploit, AFTER I engage with other wrong doctors. Contact him via email: buba.herbalmiraclemedicine@gmail.com or Call/WhatsApp him at +2349060529305
thank you..

Florence said...


I started on COPD Herbal treatment from Ultimate Life Clinic, the treatment worked incredibly for my lungs condition. I used the herbal treatment for almost 4 months, it reversed my COPD. My severe shortness of breath, dry cough, chest tightness gradually disappeared. Reach Ultimate Life Clinic via their website www.ultimatelifeclinic.com . I can breath much better and It feels comfortable!