[R-sig-Geo] generate & plot elevation contour lines
Edzer J. Pebesma
e.pebesma at geo.uu.nl
Thu Jun 29 09:28:40 CEST 2006
karl.sommer at dpi.vic.gov.au wrote:
> karl.sommer at dpi.vic.gov.au wrote:
>> my understanding is that adding the "contour = TRUE" will add the contour
>> lines for kriged zinc concentration in the present example.
>> However, what I am after is to superimpose contour lines of elevation in
>> meters above sea level on top of an interpolated variable that is not
>> elevation, eg zinc concentration or some other variable.
>> I have interpolated maps of an electromagnetic survey (EM38) of a field
>> and I would like to overlay a plot of contour lines to visualize surface
>> drainage patterns.
> In that case you could pass them as a SpatialLinesDataFrame
> object in the sp.layout list. It will not automatically print the
> contour values, but you may be able to use colour; the corresponding
> legend will be the next issue, then.
> I have tried unsuccessfully to generate a SpatialLinesDataFrame object for
> passing in sp.layout
> I was trying to use the contourLines() function without success, probably I
> didn't get the syntax right
> I tried to use the function on an object of class SpatialPixelsDataFrame
> (topo.idw) which I generated from a set of elevation measurements
>  "SpatialPixelsDataFrame"
>  "sp"
> running the function contourLines() directly I get the following error
> Error in contourLines(topo.idw["var1.pred"]) :
> no proper 'z' matrix specified
> running the function contour(topo.idw["var1.pred"]) I get a correct plot of
> the contour lines
> when I am trying to combine contourLines2SLDF() and contour() I get the
> following error message
>> CL <- contourLines2SLDF(contour(topo.idw["var1.pred"]))
> Error in contourLines2SLDF(contour(topo.idw["var1.pred"])) :
> cL too short
> I am not sure how to progress from here
contourLines is base graphics in R, so it needs arguments the
same way contour and image (in base) need them; read their
help pages, and it is especially important that you get x, y and
z right for the contourlines to have the right topology. But hey,
I believe I wrote a function as.image.SpatialGridDataFrame
in sp which does this for you.
More information about the R-sig-Geo