google maps

Happy Monday. Plans for Veterans Day Weekend. Election Day Next Week. Got Sick Last Week. Bright and Sunny Morning.

Good Morning! Happy Monday. So we go around in the grand circle of things. Next weekend, I will be downstate for work, but the following I am planning to take a trip to somewhere. Moose Plains, or maybe Central NY with a one day jaunt down to Pennsylvania for a visit some of the parks in Endless Mountain Country. A lot depends on weather, and whether or not they already have snow at Moose Plains.

Election Day Next Week. I will probably drive or take a bus up to the Board of Elections and vote by absentee ballot, and get it done. Your supposed to be out of the county during election day if you vote by absentee ballot, but if I happen to be in the county, I can either go and vote on lever machine or risk my ballot getting tossed out if I get hauled into court to testify about my whereabouts. The absentee rules in NY State are kind of dumb – they should allow everybody to participate in early voting if they so choose, by absentee ballot.

Got Really Sick Last Week. It just was a really bad cold. But tell that to somebody who is feels as sick  as dog. I slept most of Thursday and Friday, with a sore throat, aches, and dizziness. But so be it. Finally on Saturday, had enough energy to spend some of the day awake, working on some code, and then going down to the library to upload photos, and then finally, for my evening walk. At least it was just a cold, so once the virus let up, I didn’t have to go to doctor or spend money besides getting some soup and buying more nyquil, which will probably last most of the winter.

Through the Gulf

But A Nice Bright and Sunny Morning Today. It’s a Monday, and good to stay positive. To make sure I wouldn’t get hungry until mid-afternoon, I made a good breakfast up of hash browns from Empire Plaza farmers market potatoes, sweet peppers, and mushrooms, some crappy pre-cooked sausage, scrambled up a couple of eggs, and some cheese. Not to bad. Made the regular bus I normally catch with relative ease, and today the bus is a brand new Gillig Hybrid, a 4112H. Life is good.

Google Maps Added to the Blog. I have for some time been sharing Google Maps on the blog, but I never had a Google Maps of the Day feature. I built in hooks for the Google Maps of Day and full KML integration into the blog. There is still some minor bugs in the code, but I hope to post some many new and interesting maps over the cmoing months.

Where Do the Blanks in NY State Live?

In New York State, you have to register in a political party to be eligible to vote in primaries. You can’t vote in a Democratic primary, for example, if you are not a registered Democrat. The same is true with Republicans and all minor parties.

That said, in most parts of New York State, 15-25% of all voters choose to not register in a party. They may choose not to enroll in a party, as they don’t want to publicly identify with one side or another, or they do not feel comfortable with either party’s platform.

So where do the the voters who choose not to register in a party, aka blanks live? To answer that question, we take a look at Google Maps, using LATFOR voter registration data. Due to the limitations of Google Maps, we only included data at the municipal level, but it gives you a definate feel for enrollment patterns in different parts of state.

Next week we will take a look at actual “swing” voters on a state-wide basis at the MCD level. Swing voters are different from “blank” voters, as they are voters who choose to vote cross-lines, such a voting for a Democrat for President, then choosing to vote for a Republican for State Senate, and a Democrat for State Assembly. “Blank” voters might be enrolled in a party, but they may always consistently vote for Democrats and Republicans.

2010: Percentage of Blank Voters.


View Larger Map

2008: Percentage of Blank Voters.


View Larger Map

2006: Percentage of Blank Voters.


View Larger Map

Reviewing these maps, you will note that the Hudson Valley and Suffolk County have the highest percentage of blank voters in the electorate. Suburban areas also tend to have greater number of blank voters, compared to urban centers and rural areas.

So how has the number of blank voters changed in the state from 2006 through 2010? It varies widely based on region of state, but in general partisan enrollment is up in the state, except in some rural portions of the state that used to be more heavily Republican.

2006-2010 Municipalities with Decreases in Blank Enrollment.


View Larger Map

2006-2010 Municipalities with Increases in Blank Enrollment.


View Larger Map

Map: Junius Pond Unique Area
Map: Dunham Reservior

A Script to Make Pretty Political Google Maps

A while back I wrote I script for converting and styling KML files from ERSI Shapefiles, like you might download or export form a program like Quantum GIS. It requires you have the web programming language PHP 5 installed, along with the ogr2ogr command.

‘ ?>


View Larger Map ‘ ?>

This program extensively uses the PHP/DOM model, to read and write the XML file. I am not an expert programmer — it’s a hobby, but I am very happy with the results. You might consider using the LATFOR data and Census TIGER/Line for this if your a New York State resident.


#!/usr/bin/php -q
<?php
// POLITICAL STYLING FOR KML
// Converts a Shapefile with Election Results in Percentage
// 
// Input:
//      File_Title = Title for KML Name Field (as Seen in Google Maps)
//      District_Name = Field with District Name In It
//      Percent_as_Decimal = Election Result with Percent. 
//      0.00 - 0.49 = Shade of Red
//      0.50 = White
//      0.50 - 1.00 = Blue
//      Shapefile_Name = Path to Shapefile
//
// Output:
//      Google Maps KML File, Nicely Styled

if (!isset($argv[4])) {
        echo "usage: php politicalKML.php [File_Title] [District_Name] [Percent_as_Decimal]  [Shapefile_Name]\n";
        exit;
}

// required fields
$fileTitle = $argv[1];
$nameField = $argv[2];
$percentField = $argv[3];

// filename
$filename = $argv[4];
$KMLfileName = substr($filename,0,-4).'.kml';

// convert shapefile to kml using ogr2ogr
system("ogr2ogr -f \"KML\" -sql \"SELECT * FROM ". substr($filename,0,-4)." ORDER BY $fileTitle ASC\" $KMLfileName $filename -dsco NameField=$nameField -dsco DescriptionField=$percentField");

// load our new kml file
$doc = new DOMDocument();
$doc->load($KMLfileName);

// first let's replace the name field with a nicer one
$oldnode = $doc->getElementsByTagName('name')->item(0);
$node = $doc->createElement('name', $fileTitle);
$doc->getElementsByTagName('Folder')->item(0)->replaceChild($node, $oldnode);

// delete schema field to save space
$oldnode = $doc->getElementsByTagName('Schema')->item(0);
$doc->getElementsByTagName('Folder')->item(0)->removeChild($oldnode);


// load each placemark, search for maximum — used for making color judgements
foreach ($doc->getElementsByTagName('SimpleData') as $data) {
        if( $data->getAttribute('name') == $percentField) {
                $max[] = abs(substr($data->nodeValue,0)-0.5);
        }
}

// maximum in the political race
sort($max); $max = array_pop($max);
        
// calcuate multiplier for each race
$multiple = 255/$max;

// load each placemark, then set styling and percentage description
foreach ($doc->getElementsByTagName('Placemark') as $placemark) {
        foreach ($placemark->getElementsByTagName('SimpleData') as $data) {
                if( $data->getAttribute('name') == $percentField) {
                        $value = $data->nodeValue;
                        $color = substr($value,0);
                }
        }
        
        // decide if we want to do this blue or red, and then calculate
        // the amount of color versus white
        
        // republican leaning
        if ($color <= 0.5) {
                $colorStr = sprintf('%02x', 255-floor(abs($color-0.5)*$multiple));
                $colorStr = "a0{$colorStr}{$colorStr}ff";
        }
        
        // democratic leaning
        if ($color > 0.5) {
                $colorStr = sprintf('%02x', 255-floor(abs($color-0.5)*$multiple));
                $colorStr = "a0ff{$colorStr}{$colorStr}";
        }
        
        if ($color == 0) {
                $colorStr = '00ffffff';
        }
        
        // stylize the node based on color
        $node = $doc->createElement('Style');

        $linestyle = $doc->createElement('LineStyle');
        $node->appendChild($linestyle);
        $linestyle->appendChild($doc->createElement('width', 0.1));
        $linestyle->appendChild($doc->createElement('color', 'ffffffff'));
        
        $polystyle = $doc->createElement('PolyStyle');
        $node->appendChild($polystyle);
        $polystyle->appendChild($doc->createElement('color', $colorStr));       

        $oldnode = $placemark->getElementsByTagName('Style')->item(0); 
        
        $placemark->replaceChild($node, $oldnode);
                        
        // delete extended data to save KML space
        $data = $placemark->getElementsByTagName('ExtendedData')->item(0);
        $placemark->removeChild($data);
        
        // update the description
        $oldnode = $placemark->getElementsByTagName('description')->item(0); 
        $node = $doc->createElement('description', 'Recieved '.($color*100).'% of the vote.');
        $placemark->replaceChild($node, $oldnode); 
}

// finally write to the file
$doc->save($KMLfileName);

// calculate size in MB
$filesize = filesize($KMLfileName)/1024/1024;
if ( $filesize < 10) {
        $zipCommand = "zip ".substr($KMLfileName,0,-4).".kmz $KMLfileName";
        system($zipCommand);
        
        $kmzfilesize = filesize(substr($KMLfileName,0,-4).".kmz")/1024/1024;
        echo "KMZ is " .sprintf('%01.2f', $kmzfilesize)." MB, while the KML file is ".sprintf('%01.2f',$filesize)." MB.\n"; 
}
else {
        echo "Woah Horsey! The produced file is greater then 10 MB, at a size of ".sprintf('%01.2f',$filesize)." MB uncompressed. You need to simply your polygons before proceeding, otherwise Google Maps won't be able to read it. \n";
}

>
Map: Canaseraga State Forest
Map: Ossian State Forest

What God Sees When He Looks Down at New York

Note on the Re-run on May 14th: This continues to be one of my favorites Fodder essays to take a look at. New York State is a beautiful place! — Andy

‘; ?>

Adirondack Mountains.

Binghamton and
Confluence of Chenango and Susquehanna Rivers.

Catskill Mountains.

Cortland.

Finger Lakes.

Hudson Highlands.

New York City.

Orange County’s Black Dirt Country.

Western Catskills and
Country Near Delhi.

‘ ?>

Map: High Falls Reservior
Map: Snowy Mountain

Adirondack Northway’s Taken Forest Preserve Lands

The Adirondack Northway (I-87) routing through the Adirondacks was a wonder of mapping. It provided a full-interstate quality route through a mountainous route, while only requiring a 254 acre taking of forest preserve lands in 1959.

Heading Down the Gondolla

The Northway runs through three state forest preserve lands that had to be condemned to run the Adirondack Northway. Planners avoided this except where absolutely necessary to avoid having to level entire mountains.

Taylor Pond Wilderness /
Pok-O-Moonshine Mountain.

The Northway parallels Route 9 as it starts climbing into the Adirondacks, taking about 10 acres of the preserve.

Lincoln Pond Campground.

It follows along Lincoln Pond Road to a flat section known as Five Mile Meadows, probably originally cleared by logging. This probably is a 5-15 acres of taking.

Dix Mountain Wilderness /
Hammond Pond Wild Forest.

This is the largest taking around 200 acres, in a flat section of the Adirondacks around Underwood. Again, it’ parallels a section of US 9.

Other then these three parcels, no other land condemned in the Adirondacks where State Wild Forest. A remarkable routing!

Map: Mountain House Trail and North Mountain
Thematic Map: Albany Art