OpenDroneMap / FIELDimageR

FIELDimageR: A R package to analyze orthomosaic images from agricultural field trials. This package is a compilation of functions to analyze pos-mosaicking images from research fields, and allows to: crop the image; remove soil effect; build vegetation indices; rotate the image; build the plot shapefile; extract information for each plot; and evaluate stand count, canopy percentage, and plant height.
GNU General Public License v2.0
237 stars 89 forks source link

Rotation incorrectly reprojects image #11

Closed Chris-Schnaufer closed 3 years ago

Chris-Schnaufer commented 4 years ago

Rotating the image in the instructions causes the image to reproject. This causes the rotated image to have incorrect geographic coordinates. The pixels need to be rotated and the geographic information to remain intact.

A way to think about this is recognizing that the original image covers a certain area of the ground; represented by the geographic coordinate system and the image geographic extents. When the rotation step is performed, the image still represents the exact same geographic coordinate system and extents as the original image, only the pixel representation is different.

The following, unassociated, link shows the effect of the reprojection geographically: https://gis.stackexchange.com/questions/131465/gdal-rotate-dem (first response, under Update). As can be seen, the image is now covering a different geographic area after rotation.

The two images in the Rotating the image section display the same area of ground, only the pixel representation has changed.

What worked for me I couldn't find an easy way to rotate the pixels in R, not a strong language for me. What I was able to do is assign the Crop crs and extent back to the rotated image as follows:

crs(EX1.Rotated)<-crs(EX1.Crop)
extent(EX1.Rotated)<-extent(EX1.Crop)

Having a background in GIS, I need to point out that this is an inexact solution that may be considered "close enough".

filipematias23 commented 3 years ago

Hi @Chris-Schnaufer,

I have been thinking on a way to fix this rotation problem. I have some ideas, as soon as I get more improvment on that I will get back to you. Thank you for your suggestion..!!!

Let me know if you have any other idea.

All the best, Filipe

filipematias23 commented 3 years ago

Hi @Chris-Schnaufer ,

I just uploaded the new version of FIELDimageR (0.2.8). In this version, I fixed the rotation issue. Now, it's possible to fit the shapefile back to the original image using the same CRS.

For more information: (1) https://github.com/OpenDroneMap/FIELDimageR#P3 (2) https://github.com/OpenDroneMap/FIELDimageR#P5

Thank you for your suggestions...!

All the best, Filipe