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,620 points
1,429 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,700 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,620 points
7,114 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
1,961 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,130 points

edited Apr 12, 2018 by nirvana 22,134 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 14, 2018 in Data Analytics by Sahiti
• 6,370 points
7,097 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
• 33,030 points
1,837 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 9, 2018 in Data Analytics by Abhi
• 3,720 points
1,664 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,720 points
4,575 views
0 votes
1 answer

How to know the type of an object?

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

answered Sep 20, 2018 in Data Analytics by Abhi
• 3,720 points
726 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,700 points
1,346 views
+1 vote
3 answers

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

Try this: df$symbol <- as.character(df$symbol) df$symbol[df$sym ...READ MORE

answered Jan 11, 2019 in Data Analytics by Tyrion anex
• 8,700 points
35,865 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP