I have large spatial data set in text. i need to convert degree minute.decimal values to decimal degrees. my code as follows. it works well values except 0 to -1. values in 0 to -1 convert to positive values by as.numeric() Coordinate conversion method is fine, but problem is how to pass minus zero (-0) values in iflese statement. how i overcome this problem?
data <- c("-7ø12.2","-1ø23.0","-0ø50.3","0ø14.6","2ø59.7")
# latitudes in degree minutes.decimal format
lat1 <- as.numeric(gsub( "ø.*$", "", data)) # substring befor ø
lat2 <- as.numeric(sub(".*ø", "", data)) # substring after ø
lat <- ifelse(lat1 < 0, lat1 - lat2 / 60, lat1 + lat2 / 60)
lat1 [1] -7 -1 0 0 2