I am trying to use the geolocation information of a tiff image to geolocate another. Both images are frames from the same drone footage, with the drone still over the same position. The one geolocated is a tif and the one to geolocate is a png, and it is to be converted to a tif. However, when I open the new tif in Google Earth Engine, I got it where I want it, but it's almost all white. I have also noticed that the stack created from the original .png has a fourth layer that should not be there, all of it at maximum spectral value of 255. Do you know hwat might be going on? I have also tried with the first image not as a png but as a tif without geolocation and the same happened. I have also tried with bricks instead of stacks. I tried first with rasters, but the result was even worse. All the image was white. Here is my code:
library(raster)
library(rgdal)
library(ggplot2)
library(dplyr)
## Loading image of interest as raster
R_test <-
stack("Pt6_clear.png")
R_test ## It does not have any CRS
plot(R_test)
## Loading image already geolocated from GIS
frame2 <-
stack("Pt6_frame2.tif")
frame2 ##
plot(frame2)
# Give image of interest the lat/lon coords of the geolocated image as appear in its metadata in the console
extent(R_test) <- c(-9073461, -9073269, 2974255, 2974366)
# Copy the projection data of the geolocated image as appears in the console to the image of interest
projection(R_test) <- CRS("+proj=merc +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs")
plot(R_test)
## Write new geolocated image into a file
writeRaster(R_test, "R_test_geolocated.tif", format = "GTiff")
plotRGB(frame2[[1:3]])
, ie drop the fourth layer? Hard to be definitive without a copy of the file.