Solved

Change Degree Minute Seconds Hemisphere to decimal degrees split

  • 27 June 2017
  • 9 replies
  • 11 views

Badge +6

Hi

Does anyone have a transformer or groups of transformers prebuilt to extract this 32°25'20.4"S 151°29'40.5"E 2145.1 to decimal degrees split into degrees minutes decimal seconds

 

yes i am lazy.....but pressed for time

icon

Best answer by david_r 27 June 2017, 10:23

View original

9 replies

Userlevel 4

You can use a StringSearcher with the following regex to split the values:

(\d+\.?\d*)|([NSEW])

You'll have to set the "All matches list name" to something like _parts, which will be a list that will contain all the separate elements of your DMS string, e.g.:

`_parts{0}.match' has value `32'
`_parts{1}.match' has value `25'
`_parts{2}.match' has value `20.4'
`_parts{3}.match' has value `S'
`_parts{4}.match' has value `151'
`_parts{5}.match' has value `29'
`_parts{6}.match' has value `40.5'
`_parts{7}.match' has value `E'
`_parts{8}.match' has value `2145.1'

You can then feed the individual numbers into a DecimalDegreesCalculator, e.g.:

0684Q00000ArLWuQAN.png

You may also want to use something like a TestFilter and a couple of ExpressionEvaluators for values that aren't situated in the north-eastern hemisphere.

Userlevel 4
Badge +25

I notice in the DecimalDegreesCalculator help it suggests:

...if the attribute has the format:

-DDDMMSS.SS°

the following regular expression could be used in the StringSearcher to parse it into a list attribute with three elements:

^(-?[0-9]+)([0-9][0-9])([0-9][0-9][.][0-9]*)

Obviously you'd need to clean up your string a little first, removing some excess characters.

Badge +6

You can use a StringSearcher with the following regex to split the values:

(\d+\.?\d*)|([NSEW])

You'll have to set the "All matches list name" to something like _parts, which will be a list that will contain all the separate elements of your DMS string, e.g.:

`_parts{0}.match' has value `32'
`_parts{1}.match' has value `25'
`_parts{2}.match' has value `20.4'
`_parts{3}.match' has value `S'
`_parts{4}.match' has value `151'
`_parts{5}.match' has value `29'
`_parts{6}.match' has value `40.5'
`_parts{7}.match' has value `E'
`_parts{8}.match' has value `2145.1'

You can then feed the individual numbers into a DecimalDegreesCalculator, e.g.:

0684Q00000ArLWuQAN.png

You may also want to use something like a TestFilter and a couple of ExpressionEvaluators for values that aren't situated in the north-eastern hemisphere.

 

That award is well deserved...thankyou superstar !!!

You can use a StringSearcher with the following regex to split the values:

(\d+\.?\d*)|([NSEW])

You'll have to set the "All matches list name" to something like _parts, which will be a list that will contain all the separate elements of your DMS string, e.g.:

`_parts{0}.match' has value `32'
`_parts{1}.match' has value `25'
`_parts{2}.match' has value `20.4'
`_parts{3}.match' has value `S'
`_parts{4}.match' has value `151'
`_parts{5}.match' has value `29'
`_parts{6}.match' has value `40.5'
`_parts{7}.match' has value `E'
`_parts{8}.match' has value `2145.1'

You can then feed the individual numbers into a DecimalDegreesCalculator, e.g.:

0684Q00000ArLWuQAN.png

You may also want to use something like a TestFilter and a couple of ExpressionEvaluators for values that aren't situated in the north-eastern hemisphere.

Using this gave me only the first match. How can I set all the matches to something like _parts?? Thanks

 

 

 

Badge +7

FYI: It's probably way too late now, but I just uploaded the DegreeFormatter to the FME Hub.

With this custom transformer, it should be easy to deal with these kind of problems. Handles multiple attributes at once and is able to work with latitude, longitude or latitude-longitude coordinates without having to use regular expressions (although it does use them under the hood ;)).

 

Can convert DMS, DDM (degrees and decimal minutes), ISO-6709 and DD. And vice versa.

 

Enjoy!
Badge

You can use a StringSearcher with the following regex to split the values:

(\d+\.?\d*)|([NSEW])

You'll have to set the "All matches list name" to something like _parts, which will be a list that will contain all the separate elements of your DMS string, e.g.:

`_parts{0}.match' has value `32'
`_parts{1}.match' has value `25'
`_parts{2}.match' has value `20.4'
`_parts{3}.match' has value `S'
`_parts{4}.match' has value `151'
`_parts{5}.match' has value `29'
`_parts{6}.match' has value `40.5'
`_parts{7}.match' has value `E'
`_parts{8}.match' has value `2145.1'

You can then feed the individual numbers into a DecimalDegreesCalculator, e.g.:

0684Q00000ArLWuQAN.png

You may also want to use something like a TestFilter and a couple of ExpressionEvaluators for values that aren't situated in the north-eastern hemisphere.

This tool was exactly what I needed. However, we did find one problem and that is with FME versions. I use FME 2017 locally but our server currently has 2015. While the upgrade cycle is planned, we want to use this in 2015 as well but there appears to be differences in the regex engine. Any help on what needs to be changed for 2015?

Userlevel 2
Badge +17

This tool was exactly what I needed. However, we did find one problem and that is with FME versions. I use FME 2017 locally but our server currently has 2015. While the upgrade cycle is planned, we want to use this in 2015 as well but there appears to be differences in the regex engine. Any help on what needs to be changed for 2015?

You have to specify every part which you need to extract by round brackets in FME 2015. For example, this regular expression might help you.

(\d+)\D(\d+)\D(\d+\.?\d*)\D([NS])\s*(\d+)\D(\d+)\D(\d+\.?\d*)\D([EW])\s*(\d+\.?\d*)

0684Q00000ArNFfQAN.png

Badge

FYI: It's probably way too late now, but I just uploaded the DegreeFormatter to the FME Hub.

With this custom transformer, it should be easy to deal with these kind of problems. Handles multiple attributes at once and is able to work with latitude, longitude or latitude-longitude coordinates without having to use regular expressions (although it does use them under the hood ;)).

 

Can convert DMS, DDM (degrees and decimal minutes), ISO-6709 and DD. And vice versa.

 

Enjoy!

I really like your DegreeFormatter!

Badge +7

I really like your DegreeFormatter!

Thanks! :)

Reply