New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional feature - Conversions dialog or elsewhere #5395
Comments
It would be good to have this.
If I have understood you correctly then we can take out the N, S, E, W using Prepare > Column: Text > Transform > Substring. Then doing from 1 to -2 will get the number part and from -2 to -1 will get the direction.
Then I have used the Calculate simply as degrees + minutes/60, but it would be better to have an extra option on the conversions dialogue, because that would also cope better with the N/S question.
Nice example. I wonder how many countries follow the KMD example. It isn't "tidy" to mix the minutes and the N/S or E/W?
I would also like eventually to include regex as well!
Cheers
Roger
Roger Stern
Statistical Services Centre
University of Reading, Whiteknights Road, Reading RG6 6FN
Tel: +44 (0) 118 378 6421 (or 8025)
e-mail r.d.stern@reading.ac.uk<mailto:r.d.stern@reading.ac.uk>
web: www.reading.ac.uk/ssc<http://www.reading.ac.uk/ssc>
…________________________________
From: Shadrack Kibet <notifications@github.com>
Sent: 28 June 2019 05:25
To: africanmathsinitiative/R-Instat
Cc: Subscribed
Subject: [africanmathsinitiative/R-Instat] Additional feature - Conversions dialog or elsewhere (#5395)
I have stations catalogue and I would like to map all stations at KMD. Below is a screenshot of the data.
[image]<https://user-images.githubusercontent.com/26301973/60316175-32da4e80-9972-11e9-9f03-ee8dcee3a4f6.png>
I would like to have a facility in R-Instat to convert Degrees and minutes + seconds(when available) to latitude and longitudes.
This is possible in R using dms2dd() function from biogeo package. Using str_extract() from stringr package I extract letters (N, S, E, W) and minutes of latitude or longitude from Minutes columns. This is already possible using Find Replace dialog . You need to know some regex to be able to give the correct pattern. How can this be made easy for users who are not familiar with Regex? Here is a screenshot of result columns.
[image]<https://user-images.githubusercontent.com/26301973/60316889-3b805400-9975-11e9-9fb9-74342b990432.png>
Another alternative is using measurements::conv_unit() but this doesn't deal with "E/W" "N/S" entries, it requires positive/negative degrees.
I suggest this as another option in the conversions dialog or we can have this as a special dialog under mapping section?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#5395>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ACVU2ZNOFHMWMJG3H37TTPDP4WHETANCNFSM4H4CABXA>.
|
We've discussed this with Shadrack and think the best approach is to write our own function so we can make a few additions to the |
@dannyparsons here is the implementation of the R function. Any comments? |
Looks pretty good. Few small points:
I think adding these checks are important because its good quality control of the type of data that will be used for this. Is it also common to not have the N/S E/W column and instead the values are already positive/negative? If so, |
Thanks, yes it is true that when
I am not sure if it is common to have N/S E/W column. I think if this is not available then I think we should also check that |
You don't want convert_to_dec_deg <- function (dd, mm = 0 , ss = 0, dir) {
if(missing(dd)) stop("dd must be supplied")
if(!missing(dir)) {
dir <- toupper(dir)
if(!all(na.omit(dir) %in% c("E", "W", "N", "S"))) stop("dir must only contain direction letters E, W, N or S")
if(any(dd < 0)) stop("dd must be positive if dir is supplied")
}
if(!all(mm >= 0 & mm <= 60, na.rm = TRUE)) stop("mm must be between 0 and 60")
if(!all(ss >= 0 & ss <= 60, na.rm = TRUE)) stop("ss must be between 0 and 60")
sgn <- ifelse(is.na(dir), NA, ifelse(dir %in% c("S", "W"), -1, 1))
decdeg <- (dd + ((mm * 60) + ss)/3600) * sgn
return(decdeg)
} |
Thanks. |
I have stations catalogue and I would like to map all stations at KMD. Below is a section of the data.
I would like to have a facility in R-Instat to convert Degrees and minutes + seconds(when available) to latitude and longitudes.
This is possible in R using
dms2dd()
function from biogeo package. Usingstr_extract()
from stringr package I extractletters (N, S, E, W)
and minutes of latitude or longitude from Minutes columns. This is already possible using Find Replace dialog . You need to know some regex to be able to give the correct pattern. How can this be made easy for users who are not familiar with Regex? Here is a section of result columns.Another alternative is using
measurements::conv_unit()
but this doesn't deal with "E/W" "N/S" entries, it requires positive/negative degrees.I suggest this as another option in the conversions dialog or we can have this as a special dialog under mapping section? @rdstern @dannyparsons what are your views?
The text was updated successfully, but these errors were encountered: