Note that there are some explanatory texts on larger screens.

plurals
  1. POR extract raster function not working
    primarykey
    data
    text
    <p>I am having trouble with the extract function in the raster package. The raster is not empty, but when I perform the extract function all the values come back as NAs. I can plot the points over the raster fine and they show up in the same location. </p> <pre><code>library(dismo) library(raster) #Import CSV File file &lt;- paste("C:/Michelle/Michelle/R/CuskPA_Sept12_2013_1.csv", sep=" ") #read file cusk &lt;- read.table(file, header=TRUE, sep=',') cusks&lt;- subset(cusks, SlongDD!=0 &amp; SlatDD!=0) cuskll &lt;-cusks[,24:25] #import raster salvar &lt;- raster("C:/Michelle/Michelle/R/Variables/salvar") ext &lt;-extent(-67.6, -64.9, 41.0, 44.7453) salvarc &lt;-crop(salvar, ext) #extract from raster psalvar &lt;- extract(salvarc, cuskll) </code></pre> <p>This is what I get when I'm finished the extraction</p> <pre><code>head(psalvar) [1] NA NA NA NA NA NA summary(psalvar) Mode NA's logical 3859 </code></pre> <p>The raster does not show up as empty.</p> <pre><code>&gt; salvar class : RasterLayer dimensions : 334, 240, 80160 (nrow, ncol, ncell) resolution : 0.01121539, 0.01121539 (x, y) extent : -67.59662, -64.90493, 41.00048, 44.74642 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs data source : in memory names : salvar values : 0.01655413, 2.137321 (min, max) </code></pre> <p>Here is an example of the lat/longs in the file</p> <pre><code>head(cuskll) SlatDD SlongDD 1 44.41533 -66.07883 2 44.41167 -66.07733 3 44.44883 -66.07433 4 44.47067 -66.01217 5 44.47050 -66.01183 6 44.47633 -66.01450 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload