I am trying to make a topographic map using different density points for density cells in a retina. The example of volcano3d
is really nice and it gave me the idea so I think I will phrase my question according to this example.
My question is if I have the contour of an island with x,y coordinates plotted like geom_path
is it possible to construct a contour map inside the path only?
I tried to do it but r tells me that the problem is that my x and y axis are not continuous.
This is the first points in my data to give you an example, x and y are coordinates and freq should be z axis. Sorry for not putting the whole data but the contour has over 3000 points and then I have around 250 samplings inside so it is a long data set.
p <- ggplot(data = contour.xy, aes(x = x, y = y)) +
geom_path(data = contour.xy, aes(x = x, y = y)) +
geom_path(data = opticnerve.xy, aes(x = x, y = y)) +
geom_contour(data = counts, aes(x = "x", y = "y", z = "freq")) +
coord_equal()
I tried to put an image but I am a new user so because anti spam regulations I can't attach pics.
Finally after doing some research found a package that helps me do exactly what I was looking for. It is spatstat written by Adrian Baddeley and he very kindly help me with a part of the script. Basically what it does is to create a window with an irregular shape, in this case my "island" and then all the points that I need to analyse fall inside the window. To create the window I used the following code using x vector as xp and y vector as yp: map <- owin(poly=list(x=xp, y=yp)) plot(map)
Then I can create all the points as point pattern (ppp)
Really appreciate all your help but in special to Adrian Baddeley for his support