title: Converting the Coordinate Reference System (CRS) to Create a Spatial Dataframe using SpatialPoints() in the SP Package
body: <p><strong>Issue:</strong></p>
  <p>I have a <strong>shapefile</strong> that I've imported into R and I selected the variables of interest for the analysis that I'm conducting. My ultimate aim is to <strong>interpolate the point data</strong> (dolphin IDs) to obtain <strong>sea surface temperature (SST)</strong> values from each individual raster file within a stack of <strong>70+ rasters</strong> from an object called ncin_SST. This object was created using the function stack::raster() from multiple <strong>Aqua Modis netCDF files</strong> contained in one folder and I downloaded the data from the <strong>'Ocean Color Project' from NASA</strong>. My goal is to extract the average SST per ID over the time period across all 70+ raster files from 2016-to 2021.</p>
  <pre><code>##Stack all the netCDF files and select the variable &quot;sst&quot; from the raster layers
  ncin_SST &lt;- raster::stack(filenames, varname = &quot;sst&quot;)
  </code></pre>
  <p>I imported my shapefile using the function shapefile() in the <strong>rgdal package</strong> and I want to extract <strong>three variables</strong> of interest involving <strong>variable 1 = ID, variable 2 = LONGITUDE, and variable 3 = LATITUDE</strong>. Before I can <strong>interpolate the IDs</strong> with the <strong>object ncin_SST</strong>, I need to produce a spatial data frame from coordinates using the <strong>SpatialPoints()</strong> function from the <strong>sp package</strong>.</p>
  <p>When I am attempting to transform the CRS to WG85/UTM 34N, I am getting this error message below.</p>
  <p>If anyone is able to help, then many thanks.</p>
  <p><strong>R-code</strong></p>
  <p>#Read our shapefile using the function shapefile() from the raster package</p>
  <pre><code>Points_shp &lt;- shapefile(&quot;.&quot;, point_ID.shp&quot;)
  </code></pre>
  <p><strong>Check variable headers</strong></p>
  <pre><code>head(Points_shp)
  </code></pre>
  <p><strong>Select the variables of interest</strong></p>
  <pre><code>coords = cbind(Points_shp$ID, Points_shp$LATITUDE, Points_shp$LONGITUDE)
  
  #Making a spatial data frame from coordinates
  #The IDs were documented in WG84/UTM 34N
  #Extract the project code for the CRS
  
  
  CRS(&quot;+init=epsg:32634&quot;)
  </code></pre>
  <p><strong>Results</strong></p>
  <pre><code>Coordinate Reference System:
  Deprecated Proj.4 representation:
   +proj=utm +zone=34 +datum=WGS84 +units=m +no_defs 
  WKT2 2019 representation:
  PROJCRS[&quot;WGS 84 / UTM zone 34N&quot;,
      BASEGEOGCRS[&quot;WGS 84&quot;,
          ENSEMBLE[&quot;World Geodetic System 1984 ensemble&quot;,
              MEMBER[&quot;World Geodetic System 1984 (Transit)&quot;],
              MEMBER[&quot;World Geodetic System 1984 (G730)&quot;],
              MEMBER[&quot;World Geodetic System 1984 (G873)&quot;],
              MEMBER[&quot;World Geodetic System 1984 (G1150)&quot;],
              MEMBER[&quot;World Geodetic System 1984 (G1674)&quot;],
              MEMBER[&quot;World Geodetic System 1984 (G1762)&quot;],
              ELLIPSOID[&quot;WGS 84&quot;,6378137,298.257223563,
                  LENGTHUNIT[&quot;metre&quot;,1]],
              ENSEMBLEACCURACY[2.0]],
          PRIMEM[&quot;Greenwich&quot;,0,
              ANGLEUNIT[&quot;degree&quot;,0.0174532925199433]],
          ID[&quot;EPSG&quot;,4326]],
      CONVERSION[&quot;UTM zone 34N&quot;,
          METHOD[&quot;Transverse Mercator&quot;,
              ID[&quot;EPSG&quot;,9807]],
          PARAMETER[&quot;Latitude of natural origin&quot;,0,
              ANGLEUNIT[&quot;degree&quot;,0.0174532925199433],
              ID[&quot;EPSG&quot;,8801]],
          PARAMETER[&quot;Longitude of natural origin&quot;,21,
              ANGLEUNIT[&quot;degree&quot;,0.0174532925199433],
              ID[&quot;EPSG&quot;,8802]],
          PARAMETER[&quot;Scale factor at natural origin&quot;,0.9996,
              SCALEUNIT[&quot;unity&quot;,1],
              ID[&quot;EPSG&quot;,8805]],
          PARAMETER[&quot;False easting&quot;,500000,
              LENGTHUNIT[&quot;metre&quot;,1],
              ID[&quot;EPSG&quot;,8806]],
          PARAMETER[&quot;False northing&quot;,0,
              LENGTHUNIT[&quot;metre&quot;,1],
              ID[&quot;EPSG&quot;,8807]],
          ID[&quot;EPSG&quot;,16034]],
      CS[Cartesian,2],
          AXIS[&quot;(E)&quot;,east,
              ORDER[1],
              LENGTHUNIT[&quot;metre&quot;,1,
                  ID[&quot;EPSG&quot;,9001]]],
          AXIS[&quot;(N)&quot;,north,
              ORDER[2],
              LENGTHUNIT[&quot;metre&quot;,1,
                  ID[&quot;EPSG&quot;,9001]]],
      USAGE[
          SCOPE[&quot;unknown&quot;],
          AREA[&quot;Between 18°E and 24°E, northern hemisphere between equator and 84°N, onshore and offshore. Albania. Belarus. Bosnia and Herzegovina. Bulgaria. Central African Republic. Chad. Croatia. Democratic Republic of the Congo (Zaire). Estonia. Finland. Greece. Hungary. Italy. Kosovo. Latvia. Libya. Lithuania. Montenegro. North Macedonia. Norway, including Svalbard and Bjornoys. Poland. Romania. Russian Federation. Serbia. Slovakia. Sudan. Sweden. Ukraine.&quot;],
          BBOX[0,18,84,24]]] 
  </code></pre>
  <p><strong>Finalising the spatial coordinate reference data frame</strong></p>
  <pre><code>points_spdf = SpatialPoints(coords, proj4string = crs(&quot;+proj=utm + zone=34 + datum=WGS84 + units=m + no_defs&quot;))
  </code></pre>
  <p><strong>Error Message</strong></p>
  <pre><code>Error in .local(obj, ...) : 
    cannot derive coordinates from non-numeric matrix
  </code></pre>