NEONScience / NEON-geolocation

Code package for handling NEON geolocation data. Includes functions to extract spatial data from the API based on a named location, and to calculate more precise locations for select observational data products.
GNU Affero General Public License v3.0
20 stars 5 forks source link

Warning message - In if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used #14

Closed nunocesarsa closed 3 years ago

nunocesarsa commented 3 years ago

Function getLocTOS

Describe the bug Unsure it's a "bug" but its a warning that is hard to understand if its important.

To Reproduce Code to reproduce is available here: https://github.com/nunocesarsa/NEON/blob/main/RScripts/Dev/00_10_NEON_DHP_geoNEON_getLocTOS.R (EDIT: added the wrong link)

Data was processed using the NeonUtilities for download (zipbyproduct) & stacking (stackbytable) (scripts 00_07, 00_08 and finally 00_10)

Expected behavior No warning messages were expected

System (please complete the following information):

Additional context I am using the functions on all available data downloadable by neonutilities. In this case, using the basic product of the DHP.

Warning messages: 1: In if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used 2: In if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used 3: In if (is.na(projargs)) { : the condition has length > 1 and only the first element will be used 4: In if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used 5: In if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used 6: In if (is.na(projargs)) { : the condition has length > 1 and only the first element will be used 7: In if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used 8: In if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used 9: In if (is.na(projargs)) { : the condition has length > 1 and only the first element will be used

cklunch commented 3 years ago

@nunocesarsa Thanks for the alert about this! It should be an easy fix, I'll take a look this week.

cklunch commented 3 years ago

@nunocesarsa I'm actually having some trouble replicating this error. Can you narrow it down - is it a particular site that's generating these warnings?

nunocesarsa commented 3 years ago

@cklunch here comes an example i just tried out

cklunch commented 3 years ago

@nunocesarsa Yes, I can replicate this error with DP1.10023.001, I'm investigating it. But I haven't been able to replicate the error with DP1.10017.001, the DHP images producing the error:

if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used

Thanks!

nunocesarsa commented 3 years ago

@cklunch ok - i am not sure where the "error" is. It must be something in the data though. It only happens when you use the entire DP1.10017.001 dataset:

Script:


setwd('D:/NEON/TestFolder')

#create a directory
dir.create('ZipsByProduct_DHP_20210323')

zipsByProduct(dpID='DP1.10017.001',
              site='all',
              package='basic',
              check.size = F,
              savepath ='D:/NEON/TestFolder/ZipsByProduct_DHP_20210323',
              token='eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJhdWQiOiJodHRwczovL2RhdGEubmVvbnNjaWVuY2Uub3JnL2FwaS92MC8iLCJzdWIiOiJudW5vLmNlc2FyLnNhQGdtYWlsLmNvbSIsInNjb3BlIjoicmF0ZTpwdWJsaWMiLCJpc3MiOiJodHRwczovL2RhdGEubmVvbnNjaWVuY2Uub3JnLyIsImV4cCI6MTc3Mzg4Mzg3MSwiaWF0IjoxNjE2MjAzODcxLCJlbWFpbCI6Im51bm8uY2VzYXIuc2FAZ21haWwuY29tIn0.MsU9SbNGA1sH7aj29fdJuCZv73C5HD7b_OLQYozryaIDaS62xwcYHxuHHlryvie89kVP4QrBH6oMn5V3eVkyBw')

stackByTable(filepath='D:/NEON/TestFolder/ZipsByProduct_DHP_20210323/filesToStack10017',
             savepath = 'D:/NEON/TestFolder/CrashTest',
             nCores = 10)

i_df = read.csv('D:/NEON/TestFolder/CrashTest/stackedFiles/dhp_perimagefile.csv')

o_df = geoNEON::getLocTOS(data=i_df,dataProd='dhp_perimagefile',
                          token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJhdWQiOiJodHRwczovL2RhdGEubmVvbnNjaWVuY2Uub3JnL2FwaS92MC8iLCJzdWIiOiJudW5vLmNlc2FyLnNhQGdtYWlsLmNvbSIsInNjb3BlIjoicmF0ZTpwdWJsaWMiLCJpc3MiOiJodHRwczovL2RhdGEubmVvbnNjaWVuY2Uub3JnLyIsImV4cCI6MTc3Mzg4Mzg3MSwiaWF0IjoxNjE2MjAzODcxLCJlbWFpbCI6Im51bm8uY2VzYXIuc2FAZ21haWwuY29tIn0.MsU9SbNGA1sH7aj29fdJuCZv73C5HD7b_OLQYozryaIDaS62xwcYHxuHHlryvie89kVP4QrBH6oMn5V3eVkyBw')

write.csv(o_df,'D:/NEON/TestFolder/CrashTest/AllAreas_dhp_perimagefile_AllYears.csv',row.names = F)

Console dump:

o_df = geoNEON::getLocTOS(data=i_df,dataProd='dhp_perimagefile', token = 'etc' )

Warning messages: 1: In if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used 2: In if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used 3: In if (is.na(projargs)) { : the condition has length > 1 and only the first element will be used 4: In if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used 5: In if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used 6: In if (is.na(projargs)) { : the condition has length > 1 and only the first element will be used 7: In if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used 8: In if (!is.na(projargs)) { : the condition has length > 1 and only the first element will be used 9: In if (is.na(projargs)) { : the condition has length > 1 and only the first element will be used

write.csv(o_df,'D:/NEON/TestFolder/CrashTest/AllAreas_dhp_perimagefile_AllYears.csv',row.names = F)

cklunch commented 3 years ago

@nunocesarsa This turned out to be a problem with the handling of Alaska and Hawaii UTM zones. Thanks for helping us catch it! Now resolved.