Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. zip = Take[EntityValue[Entity["AdministrativeDivision", {"NewYork", "UnitedStates"}],
  2. EntityProperty["AdministrativeDivision", "ZIPCodes"]], 10];
  3. list = {#, EntityValue[#, {"Polygon", "Population"}]} & /@ zip;
  4.  
  5. list2 = Complement[list,
  6. Cases[list, {_, {Missing["NotApplicable"], _}}]] /.
  7. GeoPosition -> Sequence;
  8. list2[[All, 2, 1]] = First[#] & /@ list2[[All, 2, 1]];
  9. centroids =
  10. RegionCentroid[DiscretizeGraphics[#]] & /@ list2[[All, 2, 1]]
  11. (*{{41.2703, -71.9886}, {40.7505, -73.9974}, {40.716, -73.9865},
  12. {40.7317, -73.9891}, {40.6944, -74.0158}, {40.7061, -74.0086},
  13. {40.7096, -74.013}, {40.7137, -74.0083}}*)
  14.  
  15. data = {centroids[[#, 1]], centroids[[#, 2]],
  16. QuantityMagnitude[list2[[#, 2, 2]]]} & /@ Range@Length@centroids;
  17. clusters = FindClusters[%];
  18. ListPointPlot3D[clusters, PlotStyle -> PointSize[Large]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement