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, 2019 in Data Analytics by Sophie may
• 10,100 points
346 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, 2019 by Tyrion anex
• 8,550 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, 2019 in Data Analytics by Sophie may
• 10,100 points
2,622 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
423 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,120 points

edited Apr 12, 2018 by nirvana 13,651 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 Sahiti
• 6,320 points
924 views
+1 vote
2 answers

How to sort a data frame by columns in R?

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

answered Aug 21, 2019 in Data Analytics by anonymous
• 32,490 points
414 views
+10 votes
3 answers

Which is a better initiative to learn data science: Python or R?

Well it truly depends on your requirement, If ...READ MORE

answered Aug 8, 2018 in Data Analytics by Abhi
• 3,680 points
194 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 Abhi
• 3,680 points
319 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 Abhi
• 3,680 points
67 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,550 points
207 views
0 votes
2 answers

How to change the value of a variable using R programming in a data frame?

You are getting this error since the ...READ MORE

answered Aug 16, 2019 in Data Analytics by anonymous
• 32,490 points
13,195 views