Skip to content
Prev 28625 / 29559 Next

Geolocating and writing many tiffs at the same time

Solved!

library(raster)
library(rgdal)
library(ggplot2)
library(dplyr)
library(OpenImageR)


geolocate <- function(input) {
## Loading image of interest as raster
R_test <-
  stack(input)
R_test ## It does not have any CRS
plot(R_test)

# 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,
            filename=sub(".png", "_geolocated.tif", input),
            format="GTiff",
            overwrite=TRUE,
            NAflag=-9999)
}


filenames <- list.files(path = ".",  #The point means the working directory
                        # Now follows a regular expression that matches:
                        pattern = ".png",
                        full.names = TRUE)
for (f in filenames) {
  geolocate(f)
}

Esteban N. Rodofili
Ph.D. Student - Interdisciplinary Ecology Program, SNRE
Lic. in Biology - Mgtr. in Public Policy
Marine Geomatics Lab
University of Florida
UF Climate Action Plan - Transportation Working Group
352-284-6828
erodofili at ufl.edu
https://www.thelecourslab.org/

I stand in solidarity with Graduate Assistants United and demand the University of Florida:
1.      Follow through with its agreement to pay certain fees on behalf of GAs as outlined in Article 10.6 of our Collective Bargaining Agreement.
2.      Discontinue all business relationships with Aramark due to their use of prison labor, and directly consult with the Food Justice League, Gator NAACP, Dream Defenders, and allied groups on the upcoming food service vendor contract to ensure racial equity.
3.      Immediately reverse its plan to demolish the Maguire and UVS Graduate Family Housing complexes.
4.      Immediately revoke its new furlough policy.
Message-ID: <BN6PR22MB01329B7558B2329C590375DDA6299@BN6PR22MB0132.namprd22.prod.outlook.com>
In-Reply-To: <BN6PR22MB0132B15F22F66164832B83EFA6299@BN6PR22MB0132.namprd22.prod.outlook.com>