midraed / water

R package to calculate surface energy balance models
24 stars 20 forks source link

'con' is not a connection #45

Open csryan1 opened 5 years ago

csryan1 commented 5 years ago

I am trying to use the METRIC.EB function (following the Landsat 8 and water package simple procedure vignette), but the MTL file seems to be throwing it off; I get this error: 'Error in readLines(MTL, warn = FALSE) : 'con' is not a connection'.

I read in the MTL file using a 'read.delim' function, and it is properly stored in the R environment, but perhaps this is the wrong way considering it is not a system file within the water package.

Landsat 8 OLI/TIRS and L8 surface reflectance bands and the weather station data were added into the R environment properly ... I can plot all of the bands

Thank you.

csryan1 commented 5 years ago

To simplify, I think the error is occurring with the read.WSdata function after the MTL file is determined to not equal 0 (line 119). Here is my code up to this point excluding some other data preparation (aoi, comments, etc.):

MTL_issue

I appreciate the help.

midraed commented 5 years ago

Can I see your csv file?

On Fri, May 10, 2019, 6:32 PM csryan1 notifications@github.com wrote:

To simplify, I think the error is occurring with the read.WSdata function after the MTL file is determined to not equal 0 (line 119). Here is my code up to this point:

`harbeson <- read.csv("C:\Users\csryan\Desktop\water_trial\harbeson_data.csv", header = TRUE)

LSMTL <- read.delim("C:\Users\csryan\Desktop\water_trial\LS\LS8_test\LS8_test\LC08_L1TP_014033_20170628_20170714_01_T1_MTL.txt", header = FALSE, sep = "=")

harbesonWX <- read.WSdata(WSdata = harbeson, hourly = FALSE, datetime.format = "%m/%d/%Y %H:%M:%S", MTL = LSMTL, height = 2.0, lat = 38.6786, long = -75.2472, elev = 10.0584, date.format = "%m/%d/%Y", time.format = "%H:%M:%S", tz = "America/New_York", columns = c("date"=1,"time"=2,"radiation"=3,"wind"=4,"RH"=5,"temp"=6,"rain"=7))`

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/midraed/water/issues/45#issuecomment-491436426, or mute the thread https://github.com/notifications/unsubscribe-auth/AARBYZT7PRWU7UTNGVUAQWTPUXSWDANCNFSM4HMEHJDA .

csryan1 commented 5 years ago

Here is a screenshot of the csv file 'harbeson_data'. It's data for the entire day, so 289 lines in total. Would emailing the file be more helpful?

harbeson_screenshot

midraed commented 5 years ago

The problem is in the code. Put the csv in WSdata:

harbesonWX <- read.WSdata(WSdata = "haberson.csv", hourly = FALSE, datetime.format = "%m/%d/%Y %H:%M:%S", MTL = LSMTL, height = 2.0, lat = 38.6786, long = -75.2472, elev = 10.0584, date.format = "%m/%d/%Y", time.format = "%H:%M:%S", tz = "America/New_York", columns = c("date"=1,"time"=2,"radiation"=3,"wind"=4,"RH"=5," temp"=6,"rain"=7))`

You don't need to read the file before.

Br

On Sat, May 11, 2019, 1:05 PM csryan1 notifications@github.com wrote:

Here is a screenshot of the csv file 'harbeson_data'. It's data for the entire day, so 289 lines in total. Would emailing the file be more helpful?

[image: harbeson_screenshot] https://user-images.githubusercontent.com/49650140/57572164-b05af700-73e4-11e9-846d-3207973f4352.JPG

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/midraed/water/issues/45#issuecomment-491523488, or mute the thread https://github.com/notifications/unsubscribe-auth/AARBYZT2MF6US4WOMVR6GS3PU3VGNANCNFSM4HMEHJDA .

csryan1 commented 5 years ago

The read.WSdata function did not accept the way that I read in the MTL file, so I left it out entirely and let the code find it in the working directory, which worked. I also left out reading in the harbeson csv data before and read it in directly with the read.WSdata function. There is EB and ET output now.

Thank you for the help,

Charles

zaib19 commented 4 years ago

Can somebody help in this following error;

![Uploading readWS.png…]()

Error in data.frame(date = unique(WSdata$date), radiation_sum = tapply(WSdata$radiation, : arguments imply differing number of rows: 1, 0 In addition: Warning message: In read.WSdata(WSdata, height = 3.3, lat = 40.52, long = 14.92, : As tz = "", assuming the weather station time zone is Europe