Group Abstract Group Abstract

Message Boards Message Boards

Add contour lines on a map?

Hi,

I would like to know how I can add Contour lines on the map?

X = {1, 2, 4, 5, 7, 9};

Y = {3, 8, 9, 2, 6, 3};

Z = {100, 110, 120, 60, 90, 70};

T = Transpose[{X, Y, Z}];

ListContourPlot[T1, ColorFunction -> "BlueGreenYellow", 
 PlotLegends -> Automatic]

enter image description here

Thanks for your help.

POSTED BY: M.A. Ghorbani
8 Replies

Please - do not call here your polygon data simple data, because it will break my code. The area itself now is most obviously not convex, but a general polygon. Let polyData be the points describing the area (which already are in correct order!), then:

xData = {52, 128, 300, 375, 510, 693};
yData = {228, 451, 624, 173, 419, 214};
zValues = {100, 110, 120, 60, 90, 70};
data = MapThread[{{#1, #2}, #3} &, {xData, yData, zValues}];
poly = Polygon[polyData];
fT = Quiet@Interpolation[data, InterpolationOrder -> 1];
ContourPlot[fT[x, y], {x, y} \[Element] poly, 
 ColorFunction -> "BlueGreenYellow", PlotLegends -> Automatic, 
 Epilog -> {Red, PointSize[.03], Point[Thread[{xData, yData}]]}]

enter image description here

POSTED BY: Henrik Schachner

Well, then you have to create a polygon or region representing you map, call it poly and repeat the above ContourPlot command.

POSTED BY: Henrik Schachner

Hello Prof. Ghorbani,

this gives more or less exactly the graphic you were showing:

xData = {1, 2, 4, 5, 7, 9};
yData = {3, 8, 9, 2, 6, 3};
zValues = {100, 110, 120, 60, 90, 70};

data = MapThread[{{#1, #2}, #3} &, {xData, yData, zValues}];
poly = ConvexHullMesh[Thread[{xData, yData}]];
fT = Quiet@Interpolation[data, InterpolationOrder -> 1];
ContourPlot[fT[x, y], {x, y} \[Element] poly, 
 ColorFunction -> "BlueGreenYellow", PlotLegends -> Automatic]

Regards -- Henrik

EDIT:

Because we can have here only linear interpolation we can extent the area, maybe this makes some sense too:

polyS = RegionResize[poly, Scaled[1.3]];
ContourPlot[fT[x, y], {x, y} \[Element] polyS, 
 ColorFunction -> "BlueGreenYellow", PlotLegends -> Automatic, 
 Epilog -> {Red, PointSize[.03], Point[Thread[{xData, yData}]]}]

enter image description here

POSTED BY: Henrik Schachner

Wow. Thanks Henrik :)

POSTED BY: M.A. Ghorbani

Maybe like so (the exact relation/reference of a graphic with an image is always problematic ...):

mapImg = ImageCrop[
   Import["https://community.wolfram.com//c/portal/getImageAttachment?\
filename=6501Untitled.png&userId=943918"]];

imgDim = ImageDimensions[mapImg];

cp = ImageResize[
   Image[ContourPlot[fT[x, y], {x, y} \[Element] poly, 
     ColorFunction -> "BlueGreenYellow", PlotLegends -> None, 
     Epilog -> {Red, PointSize[.03], Point[Thread[{xData, yData}]]}, 
     ContourShading -> None, Frame -> True, FrameTicks -> None, 
     PlotRangePadding -> None, ImageSize -> Large]], imgDim];

Show[mapImg, cp]

enter image description here

POSTED BY: Henrik Schachner

Now we are in an important point, and it is overlain two images.It is not interesting.!

m = ContourPlot[fT[x, y], {x, y} \[Element] poly, 
  ContourShading -> None, ImageSize -> 500, 
  Epilog -> {Red, PointSize[.03], Point[Thread[{xData, yData}]]}]

enter image description here

enter image description here

POSTED BY: M.A. Ghorbani
POSTED BY: M.A. Ghorbani

Dear Henrik,

Many thanks for the solution.

But I want to plot contour lines on the below map. How do I plot it? enter image description here

POSTED BY: M.A. Ghorbani
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard