All Projects → datadesk → kobe-every-shot-ever

datadesk / kobe-every-shot-ever

Licence: other
A Los Angeles Times analysis of Every shot in Kobe Bryant's NBA career

Programming Languages

Jupyter Notebook
11667 projects

Projects that are alternatives of or similar to kobe-every-shot-ever

Homeless Arrests Analysis
A Los Angeles Times analysis of arrests of the homeless by the LAPD
Stars: ✭ 53 (-19.7%)
Mutual labels:  news, journalism, data-analysis
django-calaccess-raw-data
A Django app to download, extract and load campaign finance and lobbying activity data from the California Secretary of State's CAL-ACCESS database
Stars: ✭ 61 (-7.58%)
Mutual labels:  news, journalism, data-journalism
civic-scraper
Tools for downloading agendas, minutes and other documents produced by local government
Stars: ✭ 21 (-68.18%)
Mutual labels:  news, journalism, data-journalism
Notebooks
All of our computational notebooks
Stars: ✭ 292 (+342.42%)
Mutual labels:  news, journalism, data-analysis
California Coronavirus Data
The Los Angeles Times' independent tally of coronavirus cases in California.
Stars: ✭ 188 (+184.85%)
Mutual labels:  news, journalism, pandas
Startr
A template for data journalism in R
Stars: ✭ 69 (+4.55%)
Mutual labels:  news, journalism, data-analysis
census-error-analyzer
Analyze the margin of error in U.S. census data
Stars: ✭ 15 (-77.27%)
Mutual labels:  news, journalism, data-journalism
tutorials
All of our code examples and tutorials
Stars: ✭ 62 (-6.06%)
Mutual labels:  news, journalism, data-journalism
los-angeles-police-killings-data
The Los Angeles Times' database of people killed by local police in Los Angeles County.
Stars: ✭ 14 (-78.79%)
Mutual labels:  news, journalism, data-journalism
Census Data Downloader
Download U.S. census data and reformat it for humans
Stars: ✭ 149 (+125.76%)
Mutual labels:  news, journalism, pandas
california-electricity-capacity-analysis
A Los Angeles Times analysis of California's costly power glut
Stars: ✭ 17 (-74.24%)
Mutual labels:  news, journalism, data-journalism
django-anss-archive
A Django application to archive real-time earthquake notifications from the USGS's Advanced National Seismic System
Stars: ✭ 14 (-78.79%)
Mutual labels:  news, journalism, data-journalism
census-map-downloader
Easily download U.S. census maps
Stars: ✭ 31 (-53.03%)
Mutual labels:  news, journalism, data-journalism
Localradio
📻 LocalRadio is "Radio for Cord-Cutters" – a Software-Defined Radio (SDR) app for your Mac and mobile devices. With an inexpensive RTL-SDR USB device, LocalRadio provides a casual, home-based radio listening experience for your favorite local frequencies - FM broadcasts/free music/news/sports/weather/public safety & aviation scanner/etc.
Stars: ✭ 269 (+307.58%)
Mutual labels:  news, sports
Chir.py
twitter news bot that builds followers, posts, and bitcoin via ppc links
Stars: ✭ 10 (-84.85%)
Mutual labels:  news, sports
nayn.cli
nayn.co cli news
Stars: ✭ 17 (-74.24%)
Mutual labels:  news, journalism
Census Data Aggregator
Combine U.S. census data responsibly
Stars: ✭ 28 (-57.58%)
Mutual labels:  news, journalism
pastpages.org
The news homepage archive
Stars: ✭ 81 (+22.73%)
Mutual labels:  news, journalism
Awesome Newsroom Tech
List of newsrooms around the world that are using software engineering, data science, osint, and various tech to elevate reporting.
Stars: ✭ 77 (+16.67%)
Mutual labels:  news, journalism
Web Publisher
Superdesk Publisher - the next generation publishing platform for journalists and newsrooms.
Stars: ✭ 82 (+24.24%)
Mutual labels:  news, journalism

kobe-every-shot-ever

The code behind http://graphics.latimes.com/kobe-every-shot-ever/

This graphic uses data from stats.nba.com to plot all the shots Kobe Bryant ever took during NBA games (except two shots that are mysteriously missing). It uses Pandas, Matplotlib, CartoDB and Leaflet to scrape and display the data.

The Python code is in a Jupyter notebook in this repository. You can view it here on Github or run it yourself if you have Jupyter installed. To install all the necessary libraries:

$ pip install -r requirements.txt

Once we scraped the data, we exported a csv and translated the x and y coordinates to latitude and longitude.

#####Learn from our mistakes

We did a very simple translation from X and Y coordinates to latitude and longitude. We opened the data in Excel and added two extra columns that added the X and Y values (divided by 1000) to the latitude and longitude of the Staples Center.

This solution is what we came up with on a deadline — and it worked. But next time, we'd do it differently. Here's why:

• One degree of latitude does not cover the same distance as one degree of longitude. So our court ended up slightly stretched vertically.

• Opening the data in Excel is a non-programmatic step that is hard to automate. It would have been a lot easier to just add the new columns in Pandas.

• It's fun to center the hoop on the Staples Center, but in our case it added nothing to the project. We should have just centered the map at 0,0 to make it easier to work with.

#####Get it in CartoDB After adding lat and lon, we uploaded the data to CartoDB. Then it was time to display it in Leaflet. Here's the magic snippet:

cartodb.createLayer(mapchart, {
    id:"6eadec2c-0204-11e6-865f-0e674067d321",
    user_name: 'latimes',
    type: 'cartodb',
    cartodb_logo: false,
    sublayers: [{
      sql: "SELECT * FROM kobe_all_shots_geocoded_final_merge ORDER BY priority,event_type DESC",
      layer_name: "allshots",
      cartocss: cssString,
      interactivity: "combined_shot_type,action_type,season,event_type,shot_distance,playoffs,opponent,game_date",
      attribution: "Source: stats.nba.com"
    }]

  });

cartodb.createLayer is a method of cartodb.js that lets you quickly create a leaflet layer from a CartoDB dataset. It uses CartoCSS for styling. Here's an example of that:

var cssString = "#kobe_all_shots_geocoded_final_merge{\
    marker-fill-opacity: 0.4;\
    marker-line-color: #FFF;\
    marker-line-width: 1;\
    marker-line-opacity: 0;\
    marker-placement: point;\
    marker-type: ellipse;\
    marker-width: 10;\
    [event_type = 'Made Shot']{\
        marker-fill: #6a3a89;\
    }\
      [event_type = 'Missed Shot']{\
        marker-fill: #F5D05E;\
        marker-line-width: 0.5;\
        marker-fill-opacity: 0.5;\
        marker-line-color: #cacaca;\
        marker-line-opacity: 0.6\
    }\
    marker-allow-overlap: true;\
     [zoom = 16] { \
       marker-width: " + baseMarkerWidth * 24 +"; \
     } \
    [zoom = 15] { \
       marker-width: " + baseMarkerWidth * 17 +"; \
     } \
    [zoom = 14] { \
       marker-width: " + baseMarkerWidth * 10 +"; \
     } \
     [zoom = 13] { \
       marker-width: " + baseMarkerWidth * 6 +"; \
     } \
     [zoom = 12] { \
       marker-width: " + baseMarkerWidth * 4 + "; \
     } \
    [zoom = 11] { \
       marker-width: " + baseMarkerWidth * 2 + "; \
     } \
    [zoom = 10] { \
       marker-width: " + baseMarkerWidth + "; \
     } \
}";
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].