R programming: How to convert Tiff to IMG (ERDAS) format?

0 votes

I have multiple images in Tiff format. I need to perform 2 operations on these images:

  1.  First multiply them by 2 , 
  2.  Next, convert them to IMG (ERDAS) format (with the same name as input file)

Like so:

my input:

MOD11A1_2009-04-01.LST_Day_1km.tiff

output:

MOD11A1_2009-04-01.LST_Day_1km.img

How can I do this in R?

Jan 16 in Data Analytics by Sophie may
• 9,870 points
116 views

1 answer to this question.

0 votes

This code should work:

library(raster)
input <- list.files(pattern='tif$')
output <- gsub("tif", "img", input)

for (i in seq(along=input)) {
   r <- raster(input[i])
   # using "2 byte unsigned integer" data type
   r <- calc(r, fun = function(x) x * 2, datatype='INT2U', filename = output[i])
}
answered Jan 16 by Tyrion anex
• 8,280 points

Related Questions In Data Analytics

0 votes
1 answer

How to convert JSON into CSV in R programming?

Use the jsonlite::fromJSON to read the data into ...READ MORE

answered Jan 24 in Data Analytics by Sophie may
• 9,870 points
754 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
160 views
0 votes
1 answer

How to convert a list to data frame in R?

Let's assume your list of lists is ...READ MORE

answered Apr 12, 2018 in Data Analytics by nirvana
• 3,060 points

edited Apr 12, 2018 by nirvana 3,593 views
+1 vote
1 answer

How to convert a list of dataframes in to a single dataframe using R?

You can use the plyr function: data <- ...READ MORE

answered Apr 13, 2018 in Data Analytics by darklord
• 6,170 points
191 views
0 votes
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21 in Data Analytics by anonymous
• 31,840 points
149 views
0 votes
1 answer

How can I perform word stemming in R

The tm package in R provides the stemDocument() function to stem the ...READ MORE

answered Aug 20, 2018 in Data Analytics by Anmol
• 3,620 points
76 views
0 votes
1 answer

How to know the type of an object?

To find the type of an object ...READ MORE

answered Sep 19, 2018 in Data Analytics by Anmol
• 3,620 points
40 views
0 votes
1 answer

How do I import document files in R programming

Try the following: read.table("~/SMSSpamCollection", header=TRUE, sep="\t") Change "~/" to the "ptah/to/your/file/" Mess around ...READ MORE

answered Nov 5, 2018 in Data Analytics by Kalgi
• 42,510 points
38 views
0 votes
1 answer

R programming: How to pass variables from a r program to mysql function?

To include the R variables called start.date and end.date, you can use paste to ...READ MORE

answered Dec 28, 2018 in Data Analytics by Tyrion anex
• 8,280 points
74 views
0 votes
2 answers