1

I have approx. 4800 lat/lon points with a noise level, that I would like to draw contours on (e.g. 50dB, 55dB, ...). You can have a look at the data here: https://pastebin.com/LkfWYwJe

When I run

ggplot(
  data,
  aes(x =Lat, Lon, z = Value)
) + stat_contour(binwidth = 10)

I receive a

Warning message:
Not possible to generate contour data 

Unfortunately I don't have any idea why this happens. Derived from other questions here, I tried less data, but this did not have an effect.

Any hint/advice/remark is higly appreciated. Thanks!


Edit: The problem seems to be unrelated to data not building a grid. I uploaded new sample data, which forms a perfect grid. https://pastebin.com/F4c7hWcY This dataset shows the very same issue as described above.

Axeman
  • 32,068
  • 8
  • 81
  • 94
Marvin
  • 13
  • 5
  • Possible duplicate of [R - ggplot - stat\_contour not able to generate contour lines](https://stackoverflow.com/questions/19065290/r-ggplot-stat-contour-not-able-to-generate-contour-lines) – psychOle Jun 15 '17 at 08:44

1 Answers1

1

Your data file doesn't seem to have pairs of values for each possible combination of Lat and Long - instead, every Lat value is only present one time in the data.frame. The same holds true for the Lon varibale:

data[data$Lat == data$Lat[1],]

results in

#    X      Lat      Lon DayNoise
# 1 98 12.69871 52.49891 31.70291

When you round the data it kind of works:

data$Lat <- round(data$Lat,digits = 3)
data$Lon <- round(data$Lon,digits = 3)
ggplot(data,   aes(x=Lat, y=Lon, z=Value)) + 
  stat_contour(binwidth=10)
psychOle
  • 1,054
  • 9
  • 19
  • Thanks for the advice. My example dataset above is derived from a perfectly evenly spaced grid. Unfortunately I'm not able to compute the whole set as this kills my RAM. But I created a small part from my original dataset, which shows the very same problem with ggplot while being perfectly evenly spaced. https://pastebin.com/F4c7hWcY Nevertheless, thanks herbaman! – Marvin Jun 15 '17 at 09:12
  • Hm, you're right, I misinterpreted something. See my updated anwser. – psychOle Jun 15 '17 at 09:51
  • It seems, that my "grid" is somewhat convex. I guess this is related to the map projection used in my simulation software. Taking https://stackoverflow.com/questions/19065290/r-ggplot-stat-contour-not-able-to-generate-contour-lines into account I was able to draw a contour. Thanks for your advice, that pointed me into the right direction! – Marvin Jun 15 '17 at 16:22