I am using the DistanceToPoints tool to make a raster where cell values contain the distance to the nearest point.
r <- raster('./Raster.tif')
s <- readOGR('./Shapefile.shp')
dfp <- distanceFromPoints(r, s)
It is giving me an error: Error in .pointsToMatrix(xy) : A points matrix should have 2 columns
Raster and Point layer are in the same projection.
> summary(s)
Object of class SpatialPointsDataFrame
Coordinates:
min max
coords.x1 4352987 5334474.056
coords.x2 2180706 2887232.448
coords.x3 0 1100.361
Is projected: TRUE
proj4string :
[+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs]
Number of points: 792668
Data attributes:
OBJECTID id
595 :416281 Min. : 0
18 : 92323 1st Qu.:1486
261 : 19468 Median :2972
463 : 17326 Mean :2972
472 : 12768 3rd Qu.:4457
596 : 11914 Max. :5943
(Other):222588 NA's :786724
As you can see in the picture, the raster is not one whole 'thing' but patchy. Do you think that could be the problem? The tool was working fine with another whole,'normal' raster.