title: convert shapefile of multiple polygons to raster in R
body: <p>I am in a big trouble in converting polygons to raster in R. What I wanted to do is: I have shapefile (i.e. polygons) of 574 species. That is in attribute table it has 574 rows (i.e., FID is between 0 to 573). A subset of data can be found here: <a href="https://drive.google.com/file/d/1AdTChjerCXopE1-PZIAPp5ZXISdq45i8/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1AdTChjerCXopE1-PZIAPp5ZXISdq45i8/view?usp=sharing</a></p>
  
  <p>I wanted convert it to raster. In the output raster I see that the minimum and maximum values are 1 and 574. What I suspect is: it is getting field ID in the cell as pixel value that should not. Cell values should come from covering polygons. Any help will be highly appreciated. Below is the sample code:</p>
  
  <pre><code>library(raster)
  library(rgdal)
  library(maptools)
  
  
  # define porjection
  projection1 &lt;- CRS ("+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs")
  
  # load species polygons for all 574 species
  # already in the home directory
  
  sp &lt;- readShapePoly("AllP574sp.shp", proj4string = projection1)
  
  # load a raster file to use as a mirror for rasterize
  raster1 &lt;- raster("/data/projects/MeanTemp2050rcp45_BCC_CSM1_1.tif")
  
  
  r.sp &lt;- rasterize(sp, raster1) # rasterize our species polygon to the same resoluton of loaded raster
  
  writeRaster(r.sp, "/data/projects/all574spRaster", format = "GTiff", overwrite = TRUE)
  </code></pre>
  
  <p>The properties of output raster is given below:</p>
  
  <pre><code>class       : RasterLayer 
  dimensions  : 18000, 43200, 777600000  (nrow, ncol, ncell)
  resolution  : 0.008333333, 0.008333333  (x, y)
  extent      : -180, 180, -60, 90  (xmin, xmax, ymin, ymax)
  coord. ref. : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs 
  data source : E:\all574spRaster.tif 
  names       : all574spRaster 
  values      : 1, 574  (min, max)
  </code></pre>