title: Check whether point coordinate lies within polygon
body: <p>I'm new to spatial data and need some help. I have a set of 1million points and would like to identify which of those are located within one of 5 polygons. Once identified, I would like to delete the entire row of that point.</p>
  <p>The polygons are found within a kml file and the points in a csv. After reading the data, I did the following:</p>
  <pre><code>library(sf)
  library(dplyr)
  
  #create sf of lat long
  heat_df$point &lt;- heat_df[,5:6] %&gt;% 
    as.data.frame %&gt;% 
    st_as_sf(coords = c(1,2)) %&gt;%
    st_set_crs(4326)
  
  #make planar
  heat_df$point &lt;- st_transform(heat_df$point, 2163)
  kml$geometry &lt;- st_transform(kml$geometry, 2163)
  
  #itterate through the following 5 times (once per polygon)
  heat_df$inter &lt;- st_intersects(heat_df$point, kml$geometry[1], sparse = FALSE)
  heat_df &lt;-  heat_df[!(heat_df$inter == TRUE),]
  </code></pre>
  <p>However, I couldnt find any points in those polygons, eventhough I know that there are points in those polygons. I checkt the data frames and noticed that the coordinates are apparently formated differently:</p>
  <pre><code>&gt; print(heat_df$point[1])
  [[1]]
  [1] 6407800 9211903
  attr(,&quot;class&quot;)
  [1] &quot;XY&quot;    &quot;POINT&quot; &quot;sfg&quot;  
  
  &gt; print(kml$geometry[1])
  [[1]]
  [[1]]
           [,1]    [,2] [,3]
   [1,] 4520903 5043254    0
   [2,] 4520945 5043244    0
   [3,] 4521016 5043207    0
   [4,] 4521029 5043312    0
   [5,] 4521027 5043325    0
   [6,] 4521016 5043341    0
   [7,] 4520962 5043405    0
   [8,] 4520926 5043388    0
   [9,] 4520903 5043254    0
  
  attr(,&quot;class&quot;)
  [1] &quot;XYZ&quot;     &quot;POLYGON&quot; &quot;sfg&quot;    
  </code></pre>
  <p>At least the coordinates in <code>heat_df$point[1]</code> are very different from the ones in <code>kml$geometry[1]</code>. All points and all polygons are located within 1km of each other. So I don't expect point coordinates like <code>[1] 6407800 9211903</code> and polygon coordinates like <code>[1,] 4520903 5043254    0</code>. But maybe I'm wrong. I haven't worked with spatial data before. Can you help me figure out what's wrong? I want to stick to the <code>sf</code> package, if possible.</p>