# How to specify Log10 bin height scale in GeoHistogram function?

I have some data that is heavy tailed (density of geocoded entities), and I want to use the GeoHistogram function to plot it, but with a log scale. Data can be found here.

When plotted normally, the graph looks like this:

geoState = WolframAlpha["state of New York", "Result"];

Show[
GeoGraphics[{GeoStyling["OutlineMap"],GeoStyling[Lighter[Orange, 0.5]],
Opacity[0.05],EdgeForm[{Thin,Gray}],Polygon[geoState]},
GeoScaleBar -> "Miles"],
GeoHistogram[geoData,600 sq mi, GeoBackground -> None,
ColorFunction -> "TemperatureMap", PlotLegends -> Automatic]
]


I would like a Log10 scale for the bin height (hspec). The function description for GeoHistogram says that the format GeoHistogram[*data, bspec, hspec]* should work. I can't seem to find the proper format for hspec to get log-scaled bin heights.

I have tried "Log",, {"Log", 20}, and Log10[#]& with no joy. The documentation lists the syntax as GeoHistogram[*locs*,*bspec*,*hspec*] with the following options for *hspec*: "Count", "probability", "Intensity", "PDF", and fh, but does not specify the form of fh. Taking an example from Histogram and defining fh[bins_,counts_]:=Log10[counts_] does not work either. Unlike the Histogram function, the GeoHistogram hspec documentation does not list the form of {"Log",hspec} or option of "LogCounts".

• I think this is a bug. – chuy Aug 29 '16 at 22:05
• Is it sufficient to have them colored appropriately? – rcollyer Sep 1 '16 at 20:53
• They should be colored appropriately and the scale bar labeled correctly. – GraphMan Sep 1 '16 at 21:51
• Please provide sample data for geoState and geoData. – bbgodfrey Sep 1 '16 at 22:50
• My reading of the documentation is that hspec takes two arguments. You might try something like Log10[#2] & or Log10[Last@#] & – bbgodfrey Sep 2 '16 at 0:27

This is a bit of a hack but you may be able to get what you want down this path. Instead of taking the Log10 of the data I'll try to change the color scale via the ColorFunction

The base for the color function

Clear[cf]
cf[x_, min_, max_] := (Log10[x] - Log10[min])/(
Log10[max] - Log10[min]);


I use the function with the ColorFunction option

min = 1;
max = 2000;
steps = Round[10^#  & /@ Subdivide[Log10[min], Log10[2 max], 10]];
obj = GeoHistogram[geoData, Quantity[600, ("Miles")^2],
GeoBackground -> None,
ColorFunctionScaling -> False,
ColorFunction ->
Function[{z}, ColorData["TemperatureMap"][cf[z, min, max]]],
PlotLegends -> BarLegend[{
Function[{z}, ColorData["TemperatureMap"][cf[z, min, max]]], {min,
max}},
steps]]


You will want to play with the min and max values and possibly hand edit your steps for the scale.

• Very close! I still would like the scale to be something like {1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000} and log spaced. I am also trying to check that the color bar scaling reflects the bin values. Hard, since I can't extract the actual bin counts from the graph. – GraphMan Sep 3 '16 at 5:06
• You can hand edit the steps array to have whatever numbers you want. To validate you can use the color scale "Rainbow" and check the popup numbers against the scale. – c186282 Sep 3 '16 at 11:02

Modification of c186282's answer that shows Log10 scaling, with custom step intervals given, intermediate tics, and use of Blend to specify custom color function.

geoState = WolframAlpha["state of New York", "Result"];

cf3 = Function[{z},
Blend[{Lighter[Blue, 0.9], Lighter[Blue, 0.6], Red, Yellow},
cf[z, min, max]]];

min = 1;

steps = Sort[Flatten[{#* 10^Range[min - 1, decades] & /@ {1, 5}}]];

plt = GeoHistogram[geoData, Quantity[600, ("Miles")^2], "Count",
GeoBackground -> None,