4
I have the following datasheets:
BIRDS.GENERO SP1 SP2 XLOCAL
Thamnomanes caesius glaucus 0°32'S52°12'W
Thamnomanes ardesiacus obidensis 0°10'S51°50'W
Thamnomanes caesius glaucus 00°53'44"N52°00'08"W
Thamnomanes ardesiacus obidensis 00°53'44"N52°00'08"W
Thamnomanes ardesiacus obidensis 01°40'N51°23'W
Thamnomanes ardesiacus obidensis 01°40'N51°23'W
Thamnomanes caesius hoffmannsi 03°58'14,82"S49°52'56,37"W
Thamnomanes caesius hoffmannsi 03°58'14,82"S49°52'56,37"W
Thamnomanes caesius hoffmannsi 03°31'46,9"S51°44'05,2"W
Thamnomanes caesius hoffmannsi 03°31'46,9"S51°44'05,2"W
I’d like to split the column XLOCAL in Latitude and Longitude. Thus:
BIRDS.GENERO SP1 SP2 XLOCAL Lat Long
Thamnomanes caesius glaucus 0°32'S52°12'W 0°32'S 52°12'W
Thamnomanes ardesiacus obidensis 0°10'S51°50'W 0°10'S 51°50'W
Thamnomanes caesius glaucus 00°53'44"N52°00'08"W 00°53'44"N 52°00'08"W
Thamnomanes ardesiacus obidensis 00°53'44"N52°00'08"W 00°53'44"N 52°00'08"W
Thamnomanes ardesiacus obidensis 01°40'N51°23'W 01°40'N 51°23'W
Thamnomanes ardesiacus obidensis 01°40'N51°23'W 01°40'N 51°23'W
Thamnomanes caesius hoffmannsi 03°58'14,82"S49°52'56,37"W 03°58'14,82"S 49°52'56,37"W
Thamnomanes caesius hoffmannsi 03°58'14,82"S49°52'56,37"W 03°58'14,82"S 49°52'56,37"W
Thamnomanes caesius hoffmannsi 03°31'46,9"S51°44'05,2"W 03°31'46,9"S 51°44'05,2"W
Thamnomanes caesius hoffmannsi 03°31'46,9"S51°44'05,2"W 03°31'46,9"S 51°44'05,2"W
Searching the forum I found something like this:
dados$lat<- str_sub(dados$XLOCAL, end = 6)
head(x)
dados$long<- str_sub(dados$XLOCAL, start = 7)
As you can see there is a large variation in the size of the information. So the above argument does not work.
Thanks in advance.
Your script has to be smart enough to search for the letter S. If you find copy from start to S and from the character after S to the end. If not, copy from the beginning to the letter N and after the N until the end.
– Reginaldo Rigo