title: How can I extract values from one stars object using the extent of another stars object in R?
body: <p>I am new-ish to using the stars package in R and I am having trouble with figuring out how to create a stars object C that has the values from object A but the extent of object B. Specifically, I have a map of average spring temperatures in Europe (Object A) and I want to crop it using a separate stars object containing presence of deciduous broadleaf forests (Object B).</p>
  <p>Object A: <a href="https://i.stack.imgur.com/DQsZn.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/DQsZn.jpg</a></p>
  <pre><code>&gt; CRU.SpringT.2009.2018_EU
  stars object with 2 dimensions and 1 attribute
  attribute(s):
                                     Min.  1st Qu.   Median     Mean  3rd Qu.     Max.   NA's
  CRU.SpringT.2009.2018_EU.tif  -15.81895 1.201286 5.480992 4.979221 8.204463 17.55605 310479
  dimension(s):
    from   to offset      delta refsys point values x/y
  x    1 1440    -10  0.0416667 WGS 84 FALSE   NULL [x]
  y    1  672     65 -0.0416667 WGS 84 FALSE   NULL [y]
  </code></pre>
  <p>Object B: <a href="https://i.stack.imgur.com/6dons.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/6dons.jpg</a></p>
  <pre><code>&gt; Dec.BL_EU3
  stars_proxy object with 1 attribute in 1 file(s):
  $Consensus_reduced_class_3.tif
  [1] &quot;[...]/Consensus_reduced_class_3.tif&quot;
  
  dimension(s):
     from    to offset       delta                       refsys point values x/y
  x 20401 27600   -180  0.00833333 +proj=longlat +datum=WGS8... FALSE   NULL [x]
  y  3001  6360     90 -0.00833333 +proj=longlat +datum=WGS8... FALSE   NULL [y]
  call_list:
  [[1]]
  x[i = i, drop = drop, crop = crop]
  attr(,&quot;.Environment&quot;)
  &lt;environment: 0x000002a17a1ecac0&gt;
  
  [[2]]
  x[i = i, drop = drop, crop = crop]
  attr(,&quot;.Environment&quot;)
  &lt;environment: 0x000002a178d61dc0&gt;
  
  [[3]]
  e1/e2
  attr(,&quot;.Environment&quot;)
  &lt;environment: 0x000002a177987b10&gt;
  </code></pre>
  <p>Both objects are cropped using the same bbox. The goal is for the resulting object (Object C) to have the extent of B but with the temperature values from A.</p>
  <p>Dropbox links to tif files:</p>
  <p>Object A: <a href="https://www.dropbox.com/s/lwvdxnis7k38e18/CRU.SpringT.2009.2018_EU.tif?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/lwvdxnis7k38e18/CRU.SpringT.2009.2018_EU.tif?dl=0</a></p>
  <p>Object B: <a href="https://www.dropbox.com/s/uybxk40z853mu7a/EU%20Dec%20Broadleaf.tif?dl=0" rel="nofollow noreferrer">https://www.dropbox.com/s/uybxk40z853mu7a/EU%20Dec%20Broadleaf.tif?dl=0</a></p>