title: Why do terra::cellSize() and raster::area() produce different estimates of raster cell area?
body: <p>I just noticed that <code>terra::cellSize()</code> produces cell area estimates that do not match those produced by <code>raster::area()</code>.</p>
  <p>First, why do these two methods not provide the same answer? Second, which estimate is most accurate? See example below.</p>
  
  <pre class="lang-r prettyprint-override"><code>library(raster)
  #&gt; Loading required package: sp
  library(terra)
  #&gt; terra version 1.3.4
  
  # make test raster with raster::raster()
  a &lt;- raster::raster(ncols = 100, nrows = 100,
              xmn = -84, xmx = -83, 
              ymn = 42, ymx = 43)
  
  # make test raster with terra::rast()
  b &lt;- terra::rast(ncols = 100, nrows = 100, 
            xmin = -84, xmax = -83, 
            ymin = 42, ymax = 43)
  
  # calculate cell areas (km2)
  a_area &lt;- raster::area(a) # km by default
  b_area &lt;- terra::cellSize(b, unit = &quot;km&quot;)
  
  # sum across cells
  a_sum &lt;- raster::cellStats(a_area, &quot;sum&quot;)
  b_sum &lt;- terra::global(b_area, fun = &quot;sum&quot;)
  
  a_sum
  #&gt; [1] 9088.98
  b_sum
  #&gt;           sum
  #&gt; area 9130.795
  
  # note that this terra workflow yields the same answer as terra::expanse()
  terra::expanse(b, unit = &quot;km&quot;)
  #&gt; [1] 9130.795
  
  
  sessionInfo()
  #&gt; R version 4.0.2 (2020-06-22)
  #&gt; Platform: x86_64-apple-darwin17.0 (64-bit)
  #&gt; Running under: macOS  10.16
  #&gt; 
  #&gt; Matrix products: default
  #&gt; BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
  #&gt; LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
  #&gt; 
  #&gt; locale:
  #&gt; [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
  #&gt; 
  #&gt; attached base packages:
  #&gt; [1] stats     graphics  grDevices utils     datasets  methods   base     
  #&gt; 
  #&gt; other attached packages:
  #&gt; [1] terra_1.3-4  raster_3.4-5 sp_1.4-5    
  #&gt; 
  #&gt; loaded via a namespace (and not attached):
  #&gt;  [1] Rcpp_1.0.6        codetools_0.2-18  lattice_0.20-41   digest_0.6.27    
  #&gt;  [5] grid_4.0.2        magrittr_2.0.1    evaluate_0.14     highr_0.8        
  #&gt;  [9] rlang_0.4.10      stringi_1.5.3     rmarkdown_2.6     rgdal_1.5-19     
  #&gt; [13] tools_4.0.2       stringr_1.4.0     xfun_0.20         yaml_2.2.1       
  #&gt; [17] compiler_4.0.2    htmltools_0.5.1.1 knitr_1.31
  packageVersion(&quot;raster&quot;)
  #&gt; [1] '3.4.5'
  packageVersion(&quot;terra&quot;)
  #&gt; [1] '1.3.4'
  </code></pre>
  <p><sup>Created on 2021-07-08 by the <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex package</a> (v0.3.0)</sup></p>
  <p>I have been using <code>raster</code> (and loving it) for the last few years, and have recently been blown away by the speed and other improvements provided by the newer <code>terra</code> package. I am assuming that the area estimates provided by <code>terra::cellSize()</code> (or <code>terra::expanse()</code>, for that matter) are more accurate than <code>raster::area()</code>, but I'd love to know more about what changed before I update previous area estimates.</p>
  <p>Thanks for everything you do, <a href="https://github.com/rspatial" rel="nofollow noreferrer">https://github.com/rspatial</a>!</p>