Use edge to find the bounding lines, the Hough transform to find the 4 lines in the edge image and then find the intersection points of those 4 lines or use a corner detector on the edge image. ![]() Plot some results to get an idea pts.Given such a binary mask BW of a convex quadrilateral, what would be the most efficient way to determine the four corners? ![]() # "the ID (index) of (one of) the nearest objects" distance is in meters (default)ĭist.mat <- geosphere::dist2Line(p = pts, line = wrld_subset) # (from ?dist2Line): "returns matrix with distance and lon/lat of the nearest point" & # compute the shortest distance between points and polygons You didn't say.Īs mentioned here, one can also use the geosphere::dist2Line for unprojected coordinates (lat-long). If you have 17,000 points then you might want to do this in smaller subsets to avoid creating a 17,000 x 5,000 matrix if you have 5,000 polygons. Note you should use data in a projected spatial coordinate system and not lat-long. The zeroes are for points inside one of the polygons. That's the minimum distance from each of the 20 points to any of the polygons. Now use rgeos to compute point-polygon distances, and take the minimum for each point: library(rgeos) Click 20 times on the map, some inside and some outside polygons: pts = locator(20,type="p")Ĭonvert to Spatial data type: spts = SpatialPoints(pts) Let's set up some sample data: library(sp)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |