I have the
NE lat lng and
SW lat lng. My goal is simple, I am using RStudio and I want to create a bounding box from the above two lats and longs and then generate Polygon and I want to add random points into the square polygon.
I have NELat/Lng and SW-Lat/Lng in a csv file that I could import into a data.frame.
I just need a little guidance to get started, Im very new to R language, its really different to what i am used to.
So far I have this:
coords = cbind(78.46801, 19.53407) coordsmax = cbind(78.83157, 19.74557 ) sp = SpatialPoints(coordsmax) sp2 = SpatialPoints(coords) r1 = rbind(coords, coordsmax[1, ]) # join P1 = Polygon(r1) Ps1 = Polygons(list(P1), ID = "a") plot(Ps1)
I just saw some examples elsewhere but I am not able to plot a polygon of 4 corners.