Wolfram Data Repository
Immediate Computable Access to Curated Contributed Data
2015 Street Tree Census in New York City
| In[1]:= | ![ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: NYC Trees\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: NYC Trees-Input",
AutoDelete->True]\)]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/676e042dc37b840b.png) | 
| Out[1]= |  | 
Column keys and types:
| In[2]:= | ![ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: NYC Trees\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: NYC Trees-Input",
AutoDelete->True]\), "ColumnKeys"]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/034ae1c8d9178e70.png) | 
| Out[2]= |  | 
| In[3]:= | ![ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: NYC Trees\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: NYC Trees-Input",
AutoDelete->True]\), "ColumnTypes"]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/0b81da4c7d3bfc56.png) | 
| Out[3]= |  | 
Full tabular structure:
| In[4]:= | ![TabularStructure[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: NYC Trees\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: NYC Trees-Input",
AutoDelete->True]\)], All, All]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/6f1737637ba2838e.png) | 
| Out[4]= |  | 
Column descriptions:
| In[5]:= | ![ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: NYC Trees\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: NYC Trees-Input",
AutoDelete->True]\), "ColumnDescriptions"] // Dataset](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/4fd9235889e44f13.png) | 
| Out[5]= |  | 
Plot the histogram of the tree diameter at breast height:
| In[6]:= | ![Histogram[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: NYC Trees\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: NYC Trees-Input",
AutoDelete->True]\)] -> "tree_dbh", AxesLabel -> {"in"}]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/10ecceea0e6e1361.png) | 
| Out[6]= |  | 
Compute mean diameter at breast height for each tree species and reverse sort by the mean:
| In[7]:= | ![meandbh = ReverseSortBy[AggregateRows[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: NYC Trees\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: NYC Trees-Input",
AutoDelete->True]\)], "meandbh" -> Function[Mean[#"tree_dbh"]], "spc_common"], "meandbh"]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/611a577e70634048.png) | 
| Out[7]= |  | 
Compute the ratio of each mean to the mean of all the trees:
| In[8]:= | ![TransformColumns[meandbh, "ratio" -> Function[#meandbh/ColumnwiseValue[Mean[#meandbh]]]]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/12d59babf0ace95d.png) | 
| Out[8]= |  | 
Select the health and species columns, discard all rows with any number of missing (empty strings), and sort by name:
| In[9]:= | ![health = SortBy[Discard[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: NYC Trees\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: NYC Trees-Input",
AutoDelete->True]\)][All, {"spc_common", "health"}], Count[#, ""] > 0 &], "spc_common"]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/14838f3b9c6bd101.png) | 
| Out[9]= |  | 
Tally the health conditions for each species:
| In[10]:= | ![status = PivotTable[health, Function[Length[#health]], "spc_common", "health",
   IncludeGroupAggregates -> True]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/05b268620a729b7b.png) | 
| Out[10]= |  | 
Visualize the health conditions:
| In[11]:= | ![PieChart[Normal[status[-1, 2 ;; -2]], ChartLabels -> ColumnKeys[status][[2 ;; 4]], ColorFunction -> "SandyTerrain", ImageSize -> Small]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/27b1b04f6c7d5e56.png) | 
| Out[11]= |  | 
Visualize the tree species counts:
| In[12]:= | ![counts = AggregateRows[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: NYC Trees\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: NYC Trees-Input",
AutoDelete->True]\)], "count" -> Function[Length[#"spc_common"]], "spc_common"]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/452e078160d50fce.png) | 
| Out[12]= |  | 
Remove the missing and sort by count:
| In[13]:= | ![counts = SortBy[Discard[counts, Count[#, ""] > 0 &], "count"]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/3e14ee6f2c24ada5.png) | 
| Out[13]= |  | 
| In[14]:= | ![labels = Map[Style[# ~~ " ", 9] &, Normal[counts[All, "spc_common"]]];](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/2afc4aa4fb1e76a2.png) | 
| In[15]:= | ![BarChart[counts -> "count", ChartLabels -> labels, LabelingFunction -> (Placed[Style[#, 8], After] &), BarOrigin -> Left, ColorFunction -> "RoseColors", AspectRatio -> 2.5]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/6b02eef7a4ea2162.png) | 
| Out[15]= |  | 
Take a subset of columns including location information and remove rows with missing values:
| In[16]:= | ![tab = Discard[ResourceData[\!\(\*
TagBox["\"\<Sample Tabular Data: NYC Trees\>\"",
#& ,
BoxID -> "ResourceTag-Sample Tabular Data: NYC Trees-Input",
AutoDelete->True]\)][
   All, {"tree_id", "spc_latin", "spc_common", "borough", "latitude", "longitude"}], Count[#, ""] > 0 &]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/658f70617478f99b.png) | 
| Out[16]= |  | 
Select all the magnolias:
| In[17]:= | ![mags = Select[tab, StringContainsQ[#"spc_common", "magnolia"] &]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/5b311180b4805497.png) | 
| Out[17]= |  | 
Count the number of each magnolia species in each borough:
| In[18]:= | ![PivotTable[mags, Function[Length[#"spc_common"]], "spc_common", "borough"]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/5ad04c34002f5ac3.png) | 
| Out[18]= |  | 
Include summary counts:
| In[19]:= | ![PivotTable[mags, Function[Length[#"spc_common"]], "spc_common", "borough", IncludeGroupAggregates -> True]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/3d66c01ec7ab8f5d.png) | 
| Out[19]= |  | 
Visualize the magnolia tree locations:
| In[20]:= | ![GeoGraphics[{Purple, PointSize[Small], Point@GeoPosition@
    FromTabular[mags[All, {"latitude", "longitude"}], "Matrix"]}]](https://www.wolframcloud.com/obj/resourcesystem/images/d6e/d6ed0e10-af11-425c-a28c-b2dd6b9366f3/5f75ceaf6ba4e9f3.png) | 
| Out[20]= |  | 
Gosia Konwerska, "Sample Tabular Data: NYC Trees" from the Wolfram Data Repository (2024)