I have a loaded .csv table in R containing xlongl, xlongr, ylatb, ylatup values (EPSG:4326). Each row indicates with its combination of lat/long the extent of one rectangled polygon.
> mydata xlongl xlongr ylatb ylatup 1 13.500000 15.500000 6.000000 8.000000 2 9.000000 22.000000 0.000000 20.000000 3 18.000000 27.000000 -5.000000 9.000000 4 9.000000 18.000000 -5.000000 9.000000
Referring to this post entry it is possible to nest the
extent function, from the raster library, in
as to create a SpatialPolygons object. It seems to be the smarter solution instead of using the more complex way from matrix/data frame(lat/long) -> Polygon -> Polygons -> SpatialPolygon
Could someone help me to develop a coding containing a loop that built the extent as SpatialPolygon object one row after another? And that can finally merge the created single SpatialPolygon objects to one by maintaining the original order of the table?