# How can I draw a ListDensityPlot or ListContourPlot on geo coastline maps? [duplicate]

I want to know the specific spatial pattern of certain variables. I have tried to set the listdensityplot as background and add some transparency, but it's not working very well.

How can I draw the densityplot/contourplot directly on just the coast lines to show the position of each value?

Thanks a lot for your attention.

• How did you generate the image you show? Can you show us the data and code you have so far? – MarcoB Feb 14 '17 at 19:28
• I was using a NetCDF plot tool named Panoply. – Baoxiang Pan Feb 14 '17 at 22:55

It seems that I got an ugly but working solution for this question.

Firstly, we have a 2D plot of some variables, like this:

(* Import data *)
data=Import["myfile.nc",{"Datasets","var name"}]
(* ArrayPlot or ListDensityPlot or any other 2D plot here *)
image=ArrayPlot[data,
PlotRange->Full,
ColorFunction->Hue,
Frame->False,
PlotLegends->Automatic]


With the image as background, we can further add coastlines of Geo objects we need, using the following code:

With[{bounds = {{-90, 90}, {0, 360}}},
Legended[GeoGraphics[
{{GeoStyling[{"GeoImage", image[[1]]},
GeoRange -> bounds],
GeoBoundsRegion[bounds]},  (* image background stretched within bound area *)
{FaceForm[],EdgeForm[Black],Polygon[Entity["GeographicRegion","NorthAmerica"]]},
{FaceForm[],EdgeForm[Black],Polygon[Entity["GeographicRegion","SouthAmerica"]]},
{FaceForm[],EdgeForm[Black],Polygon[Entity["GeographicRegion","Antarctic"]]},
{FaceForm[],EdgeForm[Black],Polygon[Entity["GeographicRegion","Asia"]]},
{FaceForm[],EdgeForm[Black],Polygon[Entity["GeographicRegion","Australia"]]},
{FaceForm[],EdgeForm[Black],Polygon[Entity["GeographicRegion","Africa"]]},
{FaceForm[],EdgeForm[Black],Polygon[Entity["GeographicRegion","Europe"]]},
{FaceForm[],EdgeForm[Black],Polygon[Entity["Country","New Zealand"]]}},
GeoProjection -> "WinkelTripel",
GeoGridLines -> True,
ImageSize -> Medium],
image[[2]]]]


Then we have: