I have found a way to give a PNG the CRS and location of a geolocated TIFF, and to convert the PNG to TIFF. Now I have to apply it to different PNGs in the same folder (all named
Pt6_frame2, etc.) and write the individual new TIFF files as
Pt6_frame2_geolocated, etc. Does anyone have an idea of how to do so? I have tried the code in various posts, using for loops and functions, but I get various errors.
## Loading image of interest as stack R_test <- stack("Pt6_clear.png") # 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") ## Write new geolocated image into a file writeRaster(R_test, "R_test_geolocated.tif", format="GTiff", overwrite=TRUE, NAflag=-9999)