I have a Sentinel image, the coordinates of the boundary are given. I want to extract/subset a polygon from it. I am using R and don't have any prior experience in GIS.
I have downloaded some Sentinel 1 images from Copernicus https://scihub.copernicus.eu/dhus/#/home. The associated KML file has the coordinates of the image corners.
<coordinates>-118.362823,34.353683 -121.078079,34.752659 -120.786476,36.256836 -118.020294,35.860096</coordinates>
If I plot the coordinates on a map using DaftLogic Area Calculator it looks like the screenshot below:
The shape drawn above isn't parallel/perpendicular to the latitude and longitude lines, its inclined because of the satellite orbit. Also, two of the sides have a difference of ~1 km. So the shape is not in rectangular format.
I am opening the satellite image using raster package in R. The extent(georeferencing) of the image/raster doesn't have the actual geo coordinates. But, it represents the dimensions of this image.
library(raster)
s <- brick('s1a-iw-grd-vv-20161030t230720-20161030t230745-013726-016066-001.tiff')
s
#class : RasterBrick
#dimensions : 16716, 25485, 426007260, 1 (nrow, ncol, ncell, nlayers)
#resolution : 1, 1 (x, y)
#extent : 0, 25485, 0, 16716 (xmin, xmax, ymin, ymax)
#coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
#data source : s1a-iw-grd-vv-20161030t230720-20161030t230745-013726-016066-001.tiff
#names : s1a.iw.grd.vv.20161030t230720.20161030t230745.013726.016066.001
#min values : 0
#max values : 65535
extent(s)
# class : Extent
# xmin : 0
# xmax : 25485
# ymin : 0
# ymax : 16716
There is a function to assign the extent, setExtent()
. This would have worked if the shape/polygon was rectangular and not inclined.
What I need to do after the correct georeferencing is done, is to get a subset of the raster based on the polygon using extract()
. Since I am not able to set the extent properly, I am not able to do so.
Why R? I can use any other language as well. I am using a language because I have to repeat the process with multiple images.
One more problem to deal with is, some of the images are mirrored image, this adds to the problem. Note for mirrored image https://sentinel.esa.int/web/sentinel/faq
Is this the right approach? Should I work with other package or language? If somebody has already done it, please help.