-2

I am working with a polygon, and would like to identify the outermost point of the polygon (in my case it is in owin (spatstat) format but can be converted to any of the spatial formats.

For example here is my polygon: Owin

How would I go about identifying the coordinates of the "tip" of this polygon? I know I can use the minimum Y axis value, but I'm not sure how to get the X. The code is difficult to provide a sample of, but I can if need be.

1 Answers1

1

Using st_cast(.,"POINT"), st_coordinates() and the tip provided by @Allan_Cameron:

library(sf)
#reprex
yourshape.sfc <- st_geometry(st_read(system.file("shape/nc.shp",
                                                 package = "sf")))[1]
# Cast to points
yourpoints <- st_cast(yourshape.sfc, "POINT")

#Get unique coords
coords = as.data.frame(unique(st_coordinates(yourpoints)))

#Asses minimimun and unique
index <- which(coords$Y == min(coords$Y))
minims = yourpoints[index]
minims
#> Geometry set for 1 feature 
#> geometry type:  POINT
#> dimension:      XY
#> bbox:           xmin: -81.47276 ymin: 36.23436 xmax: -81.47276 ymax: 36.23436
#> epsg (SRID):    4267
#> proj4string:    +proj=longlat +datum=NAD27 +no_defs
#> POINT (-81.47276 36.23436)

plot(st_geometry(yourshape.sfc))
plot(minims, col = "green", pch = 20, cex = 2, add = TRUE)
plot(yourpoints, col = "red", pch = 20, add = TRUE)

enter image description here

Created on 2020-03-03 by the reprex package (v0.3.0)

dieghernan
  • 406
  • 3
  • 6