Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. "Beautiful In the Fall"
  2. SELECT * FROM tree_export WHERE plot__address_zip = 19103 AND species__fall_conspicuous = TRUE
  3.  
  4. "Count Trees Per Neighborhood"
  5. SELECT
  6. hoods.mapname,
  7. hoods.the_geom_webmercator,
  8. hoods.cartodb_id,
  9. COUNT(trees.cartodb_id) AS tree_count
  10. FROM tree_export AS trees
  11. JOIN neighborhoods_philadelphia AS hoods
  12. ON ST_Intersects(trees.the_geom_webmercator, hoods.the_geom_webmercator)
  13. GROUP BY hoods.mapname, hoods.the_geom_webmercator, hoods.cartodb_id
  14.  
  15. "Trees per Square Mile Per Neighborhood"
  16. SELECT
  17. hoods.cartodb_id,
  18. hoods.the_geom_webmercator,
  19. hoods.mapname,
  20. COUNT(trees.cartodb_id) / (hoods.shape_area / 5280 / 5280) AS trees_mi2
  21. FROM tree_export AS trees
  22. JOIN neighborhoods_philadelphia AS hoods
  23. ON ST_Intersects(trees.the_geom_webmercator, hoods.the_geom_webmercator)
  24. GROUP BY hoods.mapname, hoods.cartodb_id, hoods.the_geom_webmercator
  25.  
  26. "Widest Tree per Species by Neighborhood"
  27. SELECT *
  28. FROM tree_export,
  29. (SELECT
  30. MAX(trees.cartodb_id) AS treeid,
  31. MAX(trees.diameter) AS tree_diam
  32. FROM tree_export AS trees
  33. JOIN neighborhoods_philadelphia AS hoods
  34. ON ST_Intersects(trees.the_geom_webmercator, hoods.the_geom_webmercator)
  35. GROUP BY hoods.mapname, trees.species__common_name) AS sub
  36. WHERE tree_export.cartodb_id = sub.treeid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement