Giter VIP home page Giter VIP logo

Comments (2)

clhenrick avatar clhenrick commented on June 11, 2024

This likely due to the fact that the map sql query has to select geometries that aren't null, while the stats sql query selects all rows regardless of whether or not it has a geometry.

Example stats query:

--- filter where pedestrians_killed > 0
SELECT COUNT(c.cartodb_id) as total_crashes, 
SUM(CASE WHEN c.number_of_persons_injured > 0 THEN 1 ELSE 0 END) AS total_crashes_with_injury, 
SUM(CASE WHEN c.number_of_persons_killed > 0 THEN 1 ELSE 0 END) AS total_crashes_with_death, 
SUM(c.number_of_cyclist_injured) as cyclist_injured, 
SUM(c.number_of_cyclist_killed) as cyclist_killed, 
SUM(c.number_of_motorist_injured) as motorist_injured, 
SUM(c.number_of_motorist_killed) as motorist_killed, 
SUM(c.number_of_pedestrian_injured) as pedestrian_injured, 
SUM(c.number_of_pedestrian_killed) as pedestrian_killed, 
SUM(c.number_of_persons_injured) as persons_injured, 
SUM(c.number_of_persons_killed) as persons_killed 
FROM export2016_07 c  
WHERE (date_val <= date 'Aug 6, 2016') 
AND (date_val >= date 'Jul 1, 2016')  
AND ( number_of_pedestrian_killed > 0 )

Example map query:

--- filter where pedestrians > 0
SELECT c.the_geom, 
c.the_geom_webmercator, 
c.on_street_name, 
c.cross_street_name, 
COUNT(c.cartodb_id) as total_crashes, 
SUM(c.number_of_cyclist_injured) as cyclist_injured, 
SUM(c.number_of_cyclist_killed) as cyclist_killed, 
SUM(c.number_of_motorist_injured) as motorist_injured, 
SUM(c.number_of_motorist_killed) as motorist_killed, 
SUM(c.number_of_pedestrian_injured) as pedestrian_injured, 
SUM(c.number_of_pedestrian_killed) as pedestrian_killed, 
SUM(c.number_of_pedestrian_injured + c.number_of_cyclist_injured + c.number_of_motorist_injured) as persons_injured, 
SUM(c.number_of_pedestrian_killed + c.number_of_cyclist_killed + c.number_of_motorist_killed) as persons_killed 
FROM export2016_07 c  
WHERE (date_val <= date '2016-08-06') 
AND (date_val >= date '2016-07-01')  
AND ( number_of_pedestrian_killed > 0 )  
AND c.the_geom IS NOT NULL 
GROUP BY c.the_geom, c.the_geom_webmercator, c.on_street_name, c.cross_street_name

from nyc-crash-mapper.

clhenrick avatar clhenrick commented on June 11, 2024

Should explain this in the "about" or "about the data" section though as to not confuse users.

from nyc-crash-mapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.