title: Create topographic map in R
body: <p>I am trying to create a script that will generate a 2d topographic or contour map for a given set of coordinates. My goal is something similar to what is produced by</p>
  
  <p><code>contour(volcano)</code></p>
  
  <p>but for any location set by the user. This has proved surprisingly challenging! I have tried:</p>
  
  <pre><code>library(elevatr)
  library(tidyr)
  
  # Generate a data frame of lat/long coordinates.
  ex.df &lt;- data.frame(x=seq(from=-73, to=-71, length.out=10), 
                         y=seq(from=41, to=45, length.out=10))
  
  # Specify projection.
  prj_dd &lt;- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
  
  # Use elevatr package to get elevation data for each point.
  df.sp &lt;- get_elev_point(ex.df, prj = prj_dd, src = "epqs")
  
  # Convert from spatial to regular data frame, remove extra column.
  # Use tidyr to convert to lat x lon table with elevation as fill.
  # Sorry for the terrible code, I know this is sloppy.
  df &lt;- as.data.frame(df.sp)
  df$elev_units &lt;- NULL
  df.w &lt;- df %&gt;% spread(y, elevation)
  df.w &lt;- as.matrix(df.w)
  </code></pre>
  
  <p>This creates a matrix similar to the <code>volcano</code> dataset but filled with <code>NA</code>s except for the 10 lat/lon pairs with elevation data. <code>contour</code> can handle <code>NA</code>s, but the result of <code>contour(df.w)</code> has only a single tiny line on it. I'm not sure where to go from here. Do I simply need more points? Thanks in advance for any help--I'm pretty new to R and I think I've bitten off more than I can chew with this project.</p>