Skip to content

Instantly share code, notes, and snippets.

@kgryte
Last active August 29, 2016 02:19
Show Gist options
  • Select an option

  • Save kgryte/5566151 to your computer and use it in GitHub Desktop.

Select an option

Save kgryte/5566151 to your computer and use it in GitHub Desktop.

Revisions

  1. kgryte revised this gist Jul 4, 2013. No changes.
  2. kgryte revised this gist Jul 3, 2013. 1 changed file with 0 additions and 6706 deletions.
    6,706 changes: 0 additions & 6,706 deletions thumbnail.png
    0 additions, 6,706 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
  3. kgryte revised this gist May 13, 2013. 1 changed file with 6706 additions and 0 deletions.
    6,706 changes: 6,706 additions & 0 deletions thumbnail.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  4. kgryte revised this gist May 13, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ### D3 Visualization: Places Traveled

    This gist was originally created to illustrate the data scrubbing process, and all files are associated with my <a href="http://www.kgryte/blog/d3-visualization-places-traveled/">blog post</a> under the same name.
    This gist was originally created to illustrate the data scrubbing process, and all files are associated with my <a href="http://www.kgryte.com/blog/d3-visualization-places-traveled/">blog post</a> under the same name.

    The file progression proceeds from <code>data.txt</code>, a simple text document which contains a list of places, to formatting this original data set as GeoJSON, <code>data.geojson</code>.

  5. kgryte revised this gist May 13, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,6 @@

    This gist was originally created to illustrate the data scrubbing process, and all files are associated with my <a href="http://www.kgryte/blog/d3-visualization-places-traveled/">blog post</a> under the same name.

    The file progression proceeds from <code>data.txt</code>, a simple text document which contains a list of places, to formatting this original data set as GeoJSON, <code>data.geojson<code>.
    The file progression proceeds from <code>data.txt</code>, a simple text document which contains a list of places, to formatting this original data set as GeoJSON, <code>data.geojson</code>.

    Once formatted as GeoJSON, we use <a href="http://www.d3js.org">D3.js</a> to visualize the data, drawing inspiration from similar visualizations utilizing the same framework.
  6. kgryte revised this gist May 13, 2013. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    ### D3 Visualization: Places Traveled

    A gist for all files associated with my <a href="http://www.kgryte/blog/d3-visualization-places-traveled/">blog post</a> under the same name.
    This gist was originally created to illustrate the data scrubbing process, and all files are associated with my <a href="http://www.kgryte/blog/d3-visualization-places-traveled/">blog post</a> under the same name.

    The file progression proceeds from <code>data.txt</code>, a simple text document which contains a list of places, to formatting this original data set as GeoJSON, <code>data.geojson<code>.

    Once formatted as GeoJSON, we use <a href="http://www.d3js.org">D3.js</a> to visualize the data, drawing inspiration from similar visualizations utilizing the same framework.
  7. kgryte created this gist May 13, 2013.
    3 changes: 3 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    ### D3 Visualization: Places Traveled

    A gist for all files associated with my <a href="http://www.kgryte/blog/d3-visualization-places-traveled/">blog post</a> under the same name.
    66 changes: 66 additions & 0 deletions data.csv
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,66 @@
    "original address","returned address",latitude,longitude
    "London, UK","London, UK",51.5112139,-0.1198244
    "Brooklyn, New York","Brooklyn, NY, USA",40.65,-73.95
    "321 West 37th Street, Manhattan, New York, USA","321 West 37th Street, New York, NY 10018, USA",40.7545443,-73.9930957
    "San Francisco, USA","San Francisco, CA, USA",37.7749295,-122.4194155
    "Zurich, Switzerland","Zurich, Switzerland",47.3686498,8.5391825
    "Prague","Prague, Czech Republic",50.0755381,14.4378005
    "Nairobi, Kenya","Nairobi, Kenya",-1.2920659,36.8219462
    "Beijing","Beijing, China",39.90403,116.407526
    "Yellowstone National Park","Yellowstone National Park, WY 82190, USA",44.4225727,-110.5866674
    "OX1 3PU","Oxford, Oxfordshire OX1 3PU, UK",51.7599982,-1.256313
    "Saint Peter's University, Jersey City, NJ","Saint Peter's University, 2641 John F Kennedy Boulevard West, Jersey City, NJ 07306, USA",40.7266843,-74.0712895
    "Valencia, Spain","Valencia, Spain",39.4699075,-0.3762881
    "Barcelona, Spain","Barcelona, Spain",41.3850639,2.1734035
    "Milan, Italy","Milan, Italy",45.4654542,9.186516
    "Beersheva, Israel","Beersheba, Israel",31.252973,34.791462
    "Tel Aviv, Israel","Tel Aviv, Israel",32.066158,34.777819
    "Jerusalem, Israel","Jerusalem, Israel",31.768319,35.21371
    "Eliat, Israel","Eilat, Israel",29.557669,34.951925
    "Xi'an, China","Xi'an, Shaanxi, China",34.341568,108.940175
    "Warsaw, Poland","Warsaw, Poland",52.2296756,21.0122287
    "Krakow, Poland","Kraków, Poland",50.0646501,19.9449799
    "Negril, Jamaica","Negril, Jamaica",18.273979,-78.353142
    "Cancun, Mexico","Cancún, Quintana Roo, Mexico",21.158964,-86.845937
    "Ann Arbor, MI","Ann Arbor, MI, USA",42.2808256,-83.7430378
    "Madison, WI","Madison, WI, USA",43.0730517,-89.4012302
    "Minneapolis, MN","Minneapolis, MN, USA",44.983334,-93.26667
    "Lawrence, Kansas","Lawrence, KS, USA",38.9716689,-95.2352501
    "Kirksville, MO","Kirksville, MO 63501, USA",40.1947539,-92.5832496
    "St Louis, MO","St. Louis, MO, USA",38.6270025,-90.1994042
    "Kansas City, MO","Kansas City, MO, USA",39.0997265,-94.5785667
    "Jackson Hole, WY","Jackson, WY, USA",43.4799291,-110.7624282
    "Los Angeles, CA","Los Angeles, CA, USA",34.0522342,-118.2436849
    "San Diego, CA","San Diego, CA, USA",32.7153292,-117.1572551
    "Los Altos, CA","Los Altos, CA, USA",37.3852183,-122.1141298
    "Columbus, OH","Columbus, OH, USA",39.9611755,-82.9987942
    "Coco Beach, FL","Cocoa Beach, FL, USA",28.3200067,-80.6075513
    "Orlando, FL","Orlando, FL, USA",28.5383355,-81.3792365
    "Atlanta, GA","Atlanta, GA, USA",33.7489954,-84.3879824
    "Arkadelphia, AR","Arkadelphia, AR, USA",34.1209292,-93.0537839
    "Philadelphia, PA","Philadelphia, PA, USA",39.952335,-75.163789
    "Jersey City, NJ","Jersey City, NJ, USA",40.7281575,-74.0776417
    "Manchester, UK","Manchester, UK",53.479251,-2.247926
    "Paris, France","Paris, France",48.856614,2.3522219
    "Honolulu, HI","Honolulu, HI, USA",21.3069444,-157.8583333
    "Rovinj, Croatia","Rovinj, Croatia",45.0811661,13.6387067
    "St Gallen, Switzerland","St. Gallen, Switzerland",47.4166667,9.3666667
    "Amsterdam, The Netherlands","Amsterdam, The Netherlands",52.3702157,4.8951679
    "Istanbul, Turkey","Istanbul, Turkey",41.00527,28.97696
    "Olympus, Turkey","Uludağ, 16370 Bursa Province, Turkey",40.0736111,29.2177777
    "Troy, Turkey","Troia, Tevfikiye Köyü, 17060 İntepe/Çanakkale Province, Turkey",39.9575,26.2388889
    "Dallas, Texas","Dallas, TX, USA",32.7801399,-96.8004511
    "Arlington, Texas","Arlington, TX, USA",32.735687,-97.1080656
    "Ithaca, New York","Ithaca, NY, USA",42.4439614,-76.5018807
    "Lewes, Delaware","Lewes, DE, USA",38.7745565,-75.1393498
    "Washington, DC","Washington, DC, USA",38.8951118,-77.0363658
    "State College, PA","State College, PA, USA",40.7933949,-77.8600012
    "Chicago, IL","Chicago, IL, USA",41.8781136,-87.6297982
    "Door County, WI","Door, WI, USA",44.8341302,-87.3770488
    "Laax, Switzerland","Laax, Switzerland",46.8058842,9.258219
    "Lake Tahoe, CA","Lake Tahoe, United States",39.1100901,-120.0316916
    "Sunrise Beach, MO","Sunrise Beach, MO, USA",38.1758645,-92.7843553
    "Boston, MA","Boston, MA, USA",42.3584308,-71.0597732
    "Dayton, OH","Dayton, OH, USA",39.7589478,-84.1916069
    "Pittsburgh, PA","Pittsburgh, PA, USA",40.4406248,-79.9958864
    "New Orleans, LA","New Orleans, LA, USA",29.9510658,-90.0715323
    850 changes: 850 additions & 0 deletions data.geojson
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,850 @@
    {
    "type": "FeatureCollection",
    "features": [
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-0.1198244",
    "51.5112139"
    ]
    },
    "properties": {
    "name": "London, UK"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-73.95",
    "40.65"
    ]
    },
    "properties": {
    "name": "Brooklyn, NY, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-73.9930957",
    "40.7545443"
    ]
    },
    "properties": {
    "name": "321 West 37th Street, New York, NY 10018, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-122.4194155",
    "37.7749295"
    ]
    },
    "properties": {
    "name": "San Francisco, CA, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "8.5391825",
    "47.3686498"
    ]
    },
    "properties": {
    "name": "Zurich, Switzerland"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "14.4378005",
    "50.0755381"
    ]
    },
    "properties": {
    "name": "Prague, Czech Republic"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "36.8219462",
    "-1.2920659"
    ]
    },
    "properties": {
    "name": "Nairobi, Kenya"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "116.407526",
    "39.90403"
    ]
    },
    "properties": {
    "name": "Beijing, China"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-110.5866674",
    "44.4225727"
    ]
    },
    "properties": {
    "name": "Yellowstone National Park, WY 82190, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-1.256313",
    "51.7599982"
    ]
    },
    "properties": {
    "name": "Oxford, Oxfordshire OX1 3PU, UK"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-74.0712895",
    "40.7266843"
    ]
    },
    "properties": {
    "name": "Saint Peter's University, 2641 John F Kennedy Boulevard West, Jersey City, NJ 07306, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-0.3762881",
    "39.4699075"
    ]
    },
    "properties": {
    "name": "Valencia, Spain"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "2.1734035",
    "41.3850639"
    ]
    },
    "properties": {
    "name": "Barcelona, Spain"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "9.186516",
    "45.4654542"
    ]
    },
    "properties": {
    "name": "Milan, Italy"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "34.791462",
    "31.252973"
    ]
    },
    "properties": {
    "name": "Beersheba, Israel"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "34.777819",
    "32.066158"
    ]
    },
    "properties": {
    "name": "Tel Aviv, Israel"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "35.21371",
    "31.768319"
    ]
    },
    "properties": {
    "name": "Jerusalem, Israel"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "34.951925",
    "29.557669"
    ]
    },
    "properties": {
    "name": "Eilat, Israel"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "108.940175",
    "34.341568"
    ]
    },
    "properties": {
    "name": "Xi'an, Shaanxi, China"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "21.0122287",
    "52.2296756"
    ]
    },
    "properties": {
    "name": "Warsaw, Poland"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "19.9449799",
    "50.0646501"
    ]
    },
    "properties": {
    "name": "Kraków, Poland"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-78.353142",
    "18.273979"
    ]
    },
    "properties": {
    "name": "Negril, Jamaica"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-86.845937",
    "21.158964"
    ]
    },
    "properties": {
    "name": "Cancún, Quintana Roo, Mexico"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-83.7430378",
    "42.2808256"
    ]
    },
    "properties": {
    "name": "Ann Arbor, MI, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-89.4012302",
    "43.0730517"
    ]
    },
    "properties": {
    "name": "Madison, WI, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-93.26667",
    "44.983334"
    ]
    },
    "properties": {
    "name": "Minneapolis, MN, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-95.2352501",
    "38.9716689"
    ]
    },
    "properties": {
    "name": "Lawrence, KS, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-92.5832496",
    "40.1947539"
    ]
    },
    "properties": {
    "name": "Kirksville, MO 63501, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-90.1994042",
    "38.6270025"
    ]
    },
    "properties": {
    "name": "St. Louis, MO, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-94.5785667",
    "39.0997265"
    ]
    },
    "properties": {
    "name": "Kansas City, MO, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-110.7624282",
    "43.4799291"
    ]
    },
    "properties": {
    "name": "Jackson, WY, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-118.2436849",
    "34.0522342"
    ]
    },
    "properties": {
    "name": "Los Angeles, CA, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-117.1572551",
    "32.7153292"
    ]
    },
    "properties": {
    "name": "San Diego, CA, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-122.1141298",
    "37.3852183"
    ]
    },
    "properties": {
    "name": "Los Altos, CA, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-82.9987942",
    "39.9611755"
    ]
    },
    "properties": {
    "name": "Columbus, OH, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-80.6075513",
    "28.3200067"
    ]
    },
    "properties": {
    "name": "Cocoa Beach, FL, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-81.3792365",
    "28.5383355"
    ]
    },
    "properties": {
    "name": "Orlando, FL, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-84.3879824",
    "33.7489954"
    ]
    },
    "properties": {
    "name": "Atlanta, GA, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-93.0537839",
    "34.1209292"
    ]
    },
    "properties": {
    "name": "Arkadelphia, AR, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-75.163789",
    "39.952335"
    ]
    },
    "properties": {
    "name": "Philadelphia, PA, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-74.0776417",
    "40.7281575"
    ]
    },
    "properties": {
    "name": "Jersey City, NJ, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-2.247926",
    "53.479251"
    ]
    },
    "properties": {
    "name": "Manchester, UK"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "2.3522219",
    "48.856614"
    ]
    },
    "properties": {
    "name": "Paris, France"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-157.8583333",
    "21.3069444"
    ]
    },
    "properties": {
    "name": "Honolulu, HI, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "13.6387067",
    "45.0811661"
    ]
    },
    "properties": {
    "name": "Rovinj, Croatia"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "9.3666667",
    "47.4166667"
    ]
    },
    "properties": {
    "name": "St. Gallen, Switzerland"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "4.8951679",
    "52.3702157"
    ]
    },
    "properties": {
    "name": "Amsterdam, The Netherlands"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "28.97696",
    "41.00527"
    ]
    },
    "properties": {
    "name": "Istanbul, Turkey"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "29.2177777",
    "40.0736111"
    ]
    },
    "properties": {
    "name": "Uludağ, 16370 Bursa Province, Turkey"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "26.2388889",
    "39.9575"
    ]
    },
    "properties": {
    "name": "Troia, Tevfikiye Köyü, 17060 İntepe/Çanakkale Province, Turkey"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-96.8004511",
    "32.7801399"
    ]
    },
    "properties": {
    "name": "Dallas, TX, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-97.1080656",
    "32.735687"
    ]
    },
    "properties": {
    "name": "Arlington, TX, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-76.5018807",
    "42.4439614"
    ]
    },
    "properties": {
    "name": "Ithaca, NY, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-75.1393498",
    "38.7745565"
    ]
    },
    "properties": {
    "name": "Lewes, DE, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-77.0363658",
    "38.8951118"
    ]
    },
    "properties": {
    "name": "Washington, DC, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-77.8600012",
    "40.7933949"
    ]
    },
    "properties": {
    "name": "State College, PA, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-87.6297982",
    "41.8781136"
    ]
    },
    "properties": {
    "name": "Chicago, IL, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-87.3770488",
    "44.8341302"
    ]
    },
    "properties": {
    "name": "Door, WI, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "9.258219",
    "46.8058842"
    ]
    },
    "properties": {
    "name": "Laax, Switzerland"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-120.0316916",
    "39.1100901"
    ]
    },
    "properties": {
    "name": "Lake Tahoe, United States"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-92.7843553",
    "38.1758645"
    ]
    },
    "properties": {
    "name": "Sunrise Beach, MO, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-71.0597732",
    "42.3584308"
    ]
    },
    "properties": {
    "name": "Boston, MA, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-84.1916069",
    "39.7589478"
    ]
    },
    "properties": {
    "name": "Dayton, OH, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-79.9958864",
    "40.4406248"
    ]
    },
    "properties": {
    "name": "Pittsburgh, PA, USA"
    }
    },
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    "-90.0715323",
    "29.9510658"
    ]
    },
    "properties": {
    "name": "New Orleans, LA, USA"
    }
    }
    ]
    }
    392 changes: 392 additions & 0 deletions data.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,392 @@
    [
    {
    "original address": "London, UK",
    "returned address": "London, UK",
    "latitude": "51.5112139",
    "longitude": "-0.1198244"
    },
    {
    "original address": "Brooklyn, New York",
    "returned address": "Brooklyn, NY, USA",
    "latitude": "40.65",
    "longitude": "-73.95"
    },
    {
    "original address": "321 West 37th Street, Manhattan, New York, USA",
    "returned address": "321 West 37th Street, New York, NY 10018, USA",
    "latitude": "40.7545443",
    "longitude": "-73.9930957"
    },
    {
    "original address": "San Francisco, USA",
    "returned address": "San Francisco, CA, USA",
    "latitude": "37.7749295",
    "longitude": "-122.4194155"
    },
    {
    "original address": "Zurich, Switzerland",
    "returned address": "Zurich, Switzerland",
    "latitude": "47.3686498",
    "longitude": "8.5391825"
    },
    {
    "original address": "Prague",
    "returned address": "Prague, Czech Republic",
    "latitude": "50.0755381",
    "longitude": "14.4378005"
    },
    {
    "original address": "Nairobi, Kenya",
    "returned address": "Nairobi, Kenya",
    "latitude": "-1.2920659",
    "longitude": "36.8219462"
    },
    {
    "original address": "Beijing",
    "returned address": "Beijing, China",
    "latitude": "39.90403",
    "longitude": "116.407526"
    },
    {
    "original address": "Yellowstone National Park",
    "returned address": "Yellowstone National Park, WY 82190, USA",
    "latitude": "44.4225727",
    "longitude": "-110.5866674"
    },
    {
    "original address": "OX1 3PU",
    "returned address": "Oxford, Oxfordshire OX1 3PU, UK",
    "latitude": "51.7599982",
    "longitude": "-1.256313"
    },
    {
    "original address": "Saint Peter's University, Jersey City, NJ",
    "returned address": "Saint Peter's University, 2641 John F Kennedy Boulevard West, Jersey City, NJ 07306, USA",
    "latitude": "40.7266843",
    "longitude": "-74.0712895"
    },
    {
    "original address": "Valencia, Spain",
    "returned address": "Valencia, Spain",
    "latitude": "39.4699075",
    "longitude": "-0.3762881"
    },
    {
    "original address": "Barcelona, Spain",
    "returned address": "Barcelona, Spain",
    "latitude": "41.3850639",
    "longitude": "2.1734035"
    },
    {
    "original address": "Milan, Italy",
    "returned address": "Milan, Italy",
    "latitude": "45.4654542",
    "longitude": "9.186516"
    },
    {
    "original address": "Beersheva, Israel",
    "returned address": "Beersheba, Israel",
    "latitude": "31.252973",
    "longitude": "34.791462"
    },
    {
    "original address": "Tel Aviv, Israel",
    "returned address": "Tel Aviv, Israel",
    "latitude": "32.066158",
    "longitude": "34.777819"
    },
    {
    "original address": "Jerusalem, Israel",
    "returned address": "Jerusalem, Israel",
    "latitude": "31.768319",
    "longitude": "35.21371"
    },
    {
    "original address": "Eliat, Israel",
    "returned address": "Eilat, Israel",
    "latitude": "29.557669",
    "longitude": "34.951925"
    },
    {
    "original address": "Xi'an, China",
    "returned address": "Xi'an, Shaanxi, China",
    "latitude": "34.341568",
    "longitude": "108.940175"
    },
    {
    "original address": "Warsaw, Poland",
    "returned address": "Warsaw, Poland",
    "latitude": "52.2296756",
    "longitude": "21.0122287"
    },
    {
    "original address": "Krakow, Poland",
    "returned address": "Kraków, Poland",
    "latitude": "50.0646501",
    "longitude": "19.9449799"
    },
    {
    "original address": "Negril, Jamaica",
    "returned address": "Negril, Jamaica",
    "latitude": "18.273979",
    "longitude": "-78.353142"
    },
    {
    "original address": "Cancun, Mexico",
    "returned address": "Cancún, Quintana Roo, Mexico",
    "latitude": "21.158964",
    "longitude": "-86.845937"
    },
    {
    "original address": "Ann Arbor, MI",
    "returned address": "Ann Arbor, MI, USA",
    "latitude": "42.2808256",
    "longitude": "-83.7430378"
    },
    {
    "original address": "Madison, WI",
    "returned address": "Madison, WI, USA",
    "latitude": "43.0730517",
    "longitude": "-89.4012302"
    },
    {
    "original address": "Minneapolis, MN",
    "returned address": "Minneapolis, MN, USA",
    "latitude": "44.983334",
    "longitude": "-93.26667"
    },
    {
    "original address": "Lawrence, Kansas",
    "returned address": "Lawrence, KS, USA",
    "latitude": "38.9716689",
    "longitude": "-95.2352501"
    },
    {
    "original address": "Kirksville, MO",
    "returned address": "Kirksville, MO 63501, USA",
    "latitude": "40.1947539",
    "longitude": "-92.5832496"
    },
    {
    "original address": "St Louis, MO",
    "returned address": "St. Louis, MO, USA",
    "latitude": "38.6270025",
    "longitude": "-90.1994042"
    },
    {
    "original address": "Kansas City, MO",
    "returned address": "Kansas City, MO, USA",
    "latitude": "39.0997265",
    "longitude": "-94.5785667"
    },
    {
    "original address": "Jackson Hole, WY",
    "returned address": "Jackson, WY, USA",
    "latitude": "43.4799291",
    "longitude": "-110.7624282"
    },
    {
    "original address": "Los Angeles, CA",
    "returned address": "Los Angeles, CA, USA",
    "latitude": "34.0522342",
    "longitude": "-118.2436849"
    },
    {
    "original address": "San Diego, CA",
    "returned address": "San Diego, CA, USA",
    "latitude": "32.7153292",
    "longitude": "-117.1572551"
    },
    {
    "original address": "Los Altos, CA",
    "returned address": "Los Altos, CA, USA",
    "latitude": "37.3852183",
    "longitude": "-122.1141298"
    },
    {
    "original address": "Columbus, OH",
    "returned address": "Columbus, OH, USA",
    "latitude": "39.9611755",
    "longitude": "-82.9987942"
    },
    {
    "original address": "Coco Beach, FL",
    "returned address": "Cocoa Beach, FL, USA",
    "latitude": "28.3200067",
    "longitude": "-80.6075513"
    },
    {
    "original address": "Orlando, FL",
    "returned address": "Orlando, FL, USA",
    "latitude": "28.5383355",
    "longitude": "-81.3792365"
    },
    {
    "original address": "Atlanta, GA",
    "returned address": "Atlanta, GA, USA",
    "latitude": "33.7489954",
    "longitude": "-84.3879824"
    },
    {
    "original address": "Arkadelphia, AR",
    "returned address": "Arkadelphia, AR, USA",
    "latitude": "34.1209292",
    "longitude": "-93.0537839"
    },
    {
    "original address": "Philadelphia, PA",
    "returned address": "Philadelphia, PA, USA",
    "latitude": "39.952335",
    "longitude": "-75.163789"
    },
    {
    "original address": "Jersey City, NJ",
    "returned address": "Jersey City, NJ, USA",
    "latitude": "40.7281575",
    "longitude": "-74.0776417"
    },
    {
    "original address": "Manchester, UK",
    "returned address": "Manchester, UK",
    "latitude": "53.479251",
    "longitude": "-2.247926"
    },
    {
    "original address": "Paris, France",
    "returned address": "Paris, France",
    "latitude": "48.856614",
    "longitude": "2.3522219"
    },
    {
    "original address": "Honolulu, HI",
    "returned address": "Honolulu, HI, USA",
    "latitude": "21.3069444",
    "longitude": "-157.8583333"
    },
    {
    "original address": "Rovinj, Croatia",
    "returned address": "Rovinj, Croatia",
    "latitude": "45.0811661",
    "longitude": "13.6387067"
    },
    {
    "original address": "St Gallen, Switzerland",
    "returned address": "St. Gallen, Switzerland",
    "latitude": "47.4166667",
    "longitude": "9.3666667"
    },
    {
    "original address": "Amsterdam, The Netherlands",
    "returned address": "Amsterdam, The Netherlands",
    "latitude": "52.3702157",
    "longitude": "4.8951679"
    },
    {
    "original address": "Istanbul, Turkey",
    "returned address": "Istanbul, Turkey",
    "latitude": "41.00527",
    "longitude": "28.97696"
    },
    {
    "original address": "Olympus, Turkey",
    "returned address": "Uludağ, 16370 Bursa Province, Turkey",
    "latitude": "40.0736111",
    "longitude": "29.2177777"
    },
    {
    "original address": "Troy, Turkey",
    "returned address": "Troia, Tevfikiye Köyü, 17060 İntepe/Çanakkale Province, Turkey",
    "latitude": "39.9575",
    "longitude": "26.2388889"
    },
    {
    "original address": "Dallas, Texas",
    "returned address": "Dallas, TX, USA",
    "latitude": "32.7801399",
    "longitude": "-96.8004511"
    },
    {
    "original address": "Arlington, Texas",
    "returned address": "Arlington, TX, USA",
    "latitude": "32.735687",
    "longitude": "-97.1080656"
    },
    {
    "original address": "Ithaca, New York",
    "returned address": "Ithaca, NY, USA",
    "latitude": "42.4439614",
    "longitude": "-76.5018807"
    },
    {
    "original address": "Lewes, Delaware",
    "returned address": "Lewes, DE, USA",
    "latitude": "38.7745565",
    "longitude": "-75.1393498"
    },
    {
    "original address": "Washington, DC",
    "returned address": "Washington, DC, USA",
    "latitude": "38.8951118",
    "longitude": "-77.0363658"
    },
    {
    "original address": "State College, PA",
    "returned address": "State College, PA, USA",
    "latitude": "40.7933949",
    "longitude": "-77.8600012"
    },
    {
    "original address": "Chicago, IL",
    "returned address": "Chicago, IL, USA",
    "latitude": "41.8781136",
    "longitude": "-87.6297982"
    },
    {
    "original address": "Door County, WI",
    "returned address": "Door, WI, USA",
    "latitude": "44.8341302",
    "longitude": "-87.3770488"
    },
    {
    "original address": "Laax, Switzerland",
    "returned address": "Laax, Switzerland",
    "latitude": "46.8058842",
    "longitude": "9.258219"
    },
    {
    "original address": "Lake Tahoe, CA",
    "returned address": "Lake Tahoe, United States",
    "latitude": "39.1100901",
    "longitude": "-120.0316916"
    },
    {
    "original address": "Sunrise Beach, MO",
    "returned address": "Sunrise Beach, MO, USA",
    "latitude": "38.1758645",
    "longitude": "-92.7843553"
    },
    {
    "original address": "Boston, MA",
    "returned address": "Boston, MA, USA",
    "latitude": "42.3584308",
    "longitude": "-71.0597732"
    },
    {
    "original address": "Dayton, OH",
    "returned address": "Dayton, OH, USA",
    "latitude": "39.7589478",
    "longitude": "-84.1916069"
    },
    {
    "original address": "Pittsburgh, PA",
    "returned address": "Pittsburgh, PA, USA",
    "latitude": "40.4406248",
    "longitude": "-79.9958864"
    },
    {
    "original address": "New Orleans, LA",
    "returned address": "New Orleans, LA, USA",
    "latitude": "29.9510658",
    "longitude": "-90.0715323"
    }
    ]
    65 changes: 65 additions & 0 deletions data.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,65 @@
    London, UK
    Brooklyn, New York
    321 West 37th Street, Manhattan, New York, USA
    San Francisco, USA
    Zurich, Switzerland
    Prague
    Nairobi, Kenya
    Beijing
    Yellowstone National Park
    OX1 3PU
    Saint Peter's University, Jersey City, NJ
    Valencia, Spain
    Barcelona, Spain
    Milan, Italy
    Beersheva, Israel
    Tel Aviv, Israel
    Jerusalem, Israel
    Eliat, Israel
    Xi'an, China
    Warsaw, Poland
    Krakow, Poland
    Negril, Jamaica
    Cancun, Mexico
    Ann Arbor, MI
    Madison, WI
    Minneapolis, MN
    Lawrence, Kansas
    Kirksville, MO
    St Louis, MO
    Kansas City, MO
    Jackson Hole, WY
    Los Angeles, CA
    San Diego, CA
    Los Altos, CA
    Columbus, OH
    Coco Beach, FL
    Orlando, FL
    Atlanta, GA
    Arkadelphia, AR
    Philadelphia, PA
    Jersey City, NJ
    Manchester, UK
    Paris, France
    Honolulu, HI
    Rovinj, Croatia
    St Gallen, Switzerland
    Amsterdam, The Netherlands
    Istanbul, Turkey
    Olympus, Turkey
    Troy, Turkey
    Dallas, Texas
    Arlington, Texas
    Ithaca, New York
    Lewes, Delaware
    Washington, DC
    State College, PA
    Chicago, IL
    Door County, WI
    Laax, Switzerland
    Lake Tahoe, CA
    Sunrise Beach, MO
    Boston, MA
    Dayton, OH
    Pittsburgh, PA
    New Orleans, LA
    231 changes: 231 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,231 @@
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <style>
    body {
    width: 100%;
    height: 100%;
    margin: 0;
    }

    .geo-globe {
    fill: rgba(0,0,0,0.1);
    }

    .geo-path {
    fill: #132A50;
    stroke: #FFFFFF;
    stroke-width: 0.2;
    }

    .geo-path:hover {
    fill: #3B5998;
    }

    .geo-node {
    stroke-width: 0.0;
    stroke: rgba(255, 0, 10, 0.66);
    fill: rgba(255, 0, 10, 0.66);

    cursor: pointer;
    }

    .geo-node:hover {
    stroke: #a00;
    fill: #a00;
    }
    </style>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
    </head>
    <body>
    <script>
    // Initialize some variables:
    var element = 'body',
    width = $(document).width(),
    height = $(document).height();

    var radius = 10, // px
    hoverRadius = 20; // px

    var features, circles;

    // Define the type of map projection we want: (see https://github.com/mbostock/d3/wiki/Geo-Projections)
    var projection = d3.geo.orthographic()
    .scale(250) // scale the map
    .translate([width / 2, height / 2]) // set the center of the map to be the center of the canvas
    .clipAngle(90);

    // Save the path generator for the current projection:
    var path = d3.geo.path()
    .projection(projection)
    .pointRadius( function(d,i) {
    return radius;
    });

    // Define the longitude and latitude scales, which allow us to map lon/lat coordinates to pixel values:
    var lambda = d3.scale.linear()
    .domain([0, width])
    .range([-180, 180]);

    var phi = d3.scale.linear()
    .domain([0, height])
    .range([90, -90]);

    // Create the drawing canvas:
    var svg = d3.select("body").append("svg:svg")
    .attr("width", '100%')
    .attr("height", '100%');

    //Create a base circle: (could use this to color oceans)
    var backgroundCircle = svg.append("svg:circle")
    .attr('cx', width / 2)
    .attr('cy', height / 2)
    .attr('r', 0)
    .attr('class', 'geo-globe');

    // Make a <g> tag to group all our countries, which is useful for zoom purposes. (child elements belong to a 'group', which we can zoom all-at-once)
    var world = svg.append('svg:g');
    var zoomScale = 1; // default

    // Create the element group to mark individual locations:
    var locations = svg.append('svg:g')
    .attr('id', 'locations');

    // Having defined the projection, update the backgroundCircle radius:
    backgroundCircle.attr('r', projection.scale() );


    // Construct our world map based on the projection:
    d3.json('data/world-countries.json', function(collection) {

    features = world.selectAll('path')
    .data(collection.features)
    .enter()
    .append('svg:path')
    .attr('class', 'geo-path')
    .attr('d', path);

    features.append('svg:title')
    .text( function(d) { return d.properties.name; });

    }); // end FUNCTION d3.json()

    // Load our location data:
    d3.json('data/data.geojson', function(collection) {

    // Plot the positions on the map:
    circles = locations.selectAll('path')
    .data(collection.features)
    .enter()
    .append('svg:path')
    .attr('class', 'geo-node')
    .attr('d', path)
    .on('mouseover', mouseover)
    .on('mouseout', mouseout);

    circles.append('svg:title')
    .text( function(d) { return d.properties.name; } );

    }); // end FUNCTION d3.json()

    // Specify a few event handlers to allow globe rotation:
    d3.select(window)
    .on("mousemove", mousemove)
    .on("mouseup", mouseup);

    svg.on('mousedown', mousedown);

    // Setup zoom behavior:
    var zoom = d3.behavior.zoom(true)
    .scale( projection.scale() )
    .scaleExtent([100, 800])
    .on("zoom", globeZoom);

    svg.call(zoom)
    .on('dblclick.zoom', null);


    // MOUSE EVENTS //

    var mousePos;

    function mouseover(d, i) {

    path.pointRadius( function(d,i) {
    return hoverRadius;
    });

    // Increase the circle radius, so the user knows she is hovering over this node:
    d3.select(this).attr('d', path);

    }; // end FUNCTION mouseover(d,i)

    function mouseout(d, i) {

    path.pointRadius( function(d,i) {
    return radius;
    });

    // Reduce the circle radius to its pre-mouseover state:
    d3.select(this).attr('d', path);

    }; // end FUNCTION mouseout(d,i)

    function mousedown() {

    // Determine mouse pixel coordinates:
    mousePos = [d3.event.pageX, d3.event.pageY];

    // Prevent the default behavior for mouse down events:
    d3.event.preventDefault();

    }; // end FUNCTION mousedown()

    function mousemove() {

    // Has the mouse button been released?
    if (mousePos) {

    var p = d3.mouse(svg[0][0]);
    projection.rotate([lambda(p[0]), phi(p[1])]);
    svg.selectAll("path").attr("d", path);

    };

    }; // end FUNCTION mousemouse()

    function mouseup() {

    // Do we have mouse coordinates?
    if (mousePos) {

    // Yes, so update the map based on the final mouse coordinates and clear the mouse position:
    mousemove();
    mousePos = null;

    };

    }; // end FUNCTION mouseup()



    // Helper functions //

    function globeZoom() {
    if (d3.event) {
    var _scale = d3.event.scale;

    projection.scale(_scale);
    backgroundCircle.attr('r', _scale);
    path.pointRadius( radius );

    features.attr('d', path);
    circles.attr('d', path);

    }; // end IF
    };
    </script>
    </body>
    </html>
    179 changes: 179 additions & 0 deletions world-countries.json
    179 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.