I am trying to make a kernel density plot of a points shapefile like so:


points <- readOGR(dsn = "C:\\Documents",
                  layer = "points")

points$X <-  coordinates(points)[,1]
points$Y <-  coordinates(points)[,2]

aoi <- readOGR(dsn = "C:\\Documents",
                  layer = "aoi")

W <- as.owin.SpatialPolygons(aoi)

pp <- ppp(points$X, points$Y, W = W)

but this returns:

Warning message:
7978 points were rejected as lying outside the specified window 

which is the number of rows in points. Both projections for aoi and points are:

"+proj=utm +zone=14 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0"

And when I plot:

plot(points, add=T)

enter image description here

So my points do overlay, however I'm not sure why I get the error.


The best explanation I could suggest looking into is similar to this response I found in a different forum, Warning message: points were rejected as lying outside the specified window.

These points are rejected because they lie outside the window that you have specified. If you want them not to be deemed "rejects" you have change your window. Or possibly move these points slightly. Both of these strategies are really "cheating" and therefore dubious.

Polygons provided as map boundaries by GIS facilities are almost always problematic. The boundaries are generally very messy --- that's the nature of reality. .... You should identify the two points that are causing the difficulty and figure out why the problem is arising.

Plot your pattern that has the rejects and examine the rejects. Figure out if there is something weird about them, or about the map boundary near where they lie.

I know you mentioned that both your polygon and points share the same projection however, there may be an extent issue of your bounding box for your polygon that may be causing the issue.

  • The extent of points is class : Extent xmin : 117382 xmax : 696513.6 ymin : 4785378 ymax : 5436320 and for aoi it is class : Extent xmin : 88099.56 xmax : 709931.6 ymin : 4706116 ymax : 5439735 which should put all the points in the aoi I think. – Stefano Potter Oct 9 '17 at 20:08
  • What about the extent of the aoi? – whyzar Oct 9 '17 at 20:10
  • Thats the second extent listed. – Stefano Potter Oct 9 '17 at 20:20
  • If i'm not mistaken it appears that your point extent are exceeding your aoi extent. That would explain your issue, why you are receiving that error. As is referred to my answer that I found. – whyzar Oct 9 '17 at 20:27
  • Ahh, yea maybe I interpreted them backwards. I will look into how to change the extent of points to match aoi. Thank you. – Stefano Potter Oct 9 '17 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.