I'm importing the NGA ASAM piracy database into Mathematica for analysis.
asamjson=Import["http://msi.nga.mil/MSI_JWS/ASAM_JSON/getJSON?typename=\
DateRange_AllRefNumbers&fromDate=19900101&toDate=20140801",
"JSON"];
Needs["GeneralUtilities`"]
asamdataset = Dataset[ToAssociations@asamjson];
piracyLocations =
Map[GeoPosition[ ToExpression@{#["lat"], #["lng"] }] &,
asamdataset];
I can import the data fine, and get lat/longs (for some reason they're included twice in the ASAM data). I can then draw them with GeoListPlot and get map of all the piracy events.
GeoListPlot[Take[piracyLocations, 300]]
However, when I then go to make a heat map histogram things fall apart. What displayed nicely now shows up with a wildly out of skew map. It looks like I need to choose some different form of projection, but which?
dat = Map[ ToExpression@{#["lat"], #["lng"]}&,Take[asamdataset, 4000]];
histo = SmoothDensityHistogram[dat, .3,
ColorFunction -> "SunsetColors", PlotPoints -> 150, Mesh -> 20,
MeshStyle -> Opacity[.1], PlotRange -> All];
Show[histo,
Graphics[{FaceForm[], EdgeForm[Directive[White, Opacity[.7]]],
CountryData["World", "Polygon"]}]]
How do I project my heatmap of piracy events correctly onto the world?
EDIT: My first problem is that Geoposition and related functions take Lat/Long pairs. Which is Y/X, whereas other Mathematica functions take X/Y pairs.
In[1079]:= Position[Normal@piracyLocations,null]
Out[1079]= {{4335,1,2},{4391,1,1}}
These cause the plot to freeze. $\endgroup$