Solved

Need help reformatting lat long

  • 27 September 2018
  • 6 replies
  • 1 view

I'm trying to convert some poorly formatted lat long coordiantes into correct ones. You can see the original and new format in this sample data. I'm sure this is pretty straight forward but I'm new to Safe FME and could use some help.

icon

Best answer by takashi 27 September 2018, 23:43

View original

6 replies

Userlevel 2
Badge +17

Hi @tmoreland, a possible way is to use some FME String functions to create new values. You can set these expressions to the "Attribute Value" column in the AttributeManager or the AttributeCreator.

New Longitude:

-@Substring(@Value(Origional Longitude),0,2).@Trim(@Substring(@Value(Origional Longitude),2),0)

New Latitude:

@Substring(@Value(Origional Latitude),0,2).@Trim(@Substring(@Value(Origional Latitude),2),0)

See here to learn more about FME String functions: String Functions

Hi @tmoreland, a possible way is to use some FME String functions to create new values. You can set these expressions to the "Attribute Value" column in the AttributeManager or the AttributeCreator.

New Longitude:

-@Substring(@Value(Origional Longitude),0,2).@Trim(@Substring(@Value(Origional Longitude),2),0)

New Latitude:

@Substring(@Value(Origional Latitude),0,2).@Trim(@Substring(@Value(Origional Latitude),2),0)

See here to learn more about FME String functions: String Functions

Thank @takashi! This works great except when there is are zeros after the location where the point is added. So for example, 35082249, loses its zero and gets converted to 35.82249. This puts the lat long in an entirely different location. Is there a way to treat it as a string to preserve the zeros?

 

Userlevel 2
Badge +17

Hi @tmoreland, a possible way is to use some FME String functions to create new values. You can set these expressions to the "Attribute Value" column in the AttributeManager or the AttributeCreator.

New Longitude:

-@Substring(@Value(Origional Longitude),0,2).@Trim(@Substring(@Value(Origional Longitude),2),0)

New Latitude:

@Substring(@Value(Origional Latitude),0,2).@Trim(@Substring(@Value(Origional Latitude),2),0)

See here to learn more about FME String functions: String Functions

Don't use the @Trim function, in order to preserve the zeros.

 

In your sample CSV data, however, the zeros have been removed as shown below. I therefore thought the zeros should be removed. The sample was wrong?

 

 

Origional Longitude,Origional Latitude,New Format Longitude,New Format Latitude
85056853,34992947,-85.56853,34.992947
85273136,34991196,-85.56853,34.991196
85273136,34991196,-85.56853,34.991196
85280427,35017689,-85.56853,35.17689
85273136,34991196,-85.56853,34.991196
85326172,35107351,-85.56853,35.107351
85330663,35088552,-85.56853,35.88552
85156949,35042868,-85.56853,35.42868
85156949,35042868,-85.56853,35.42868
85156949,35042868,-85.56853,35.42868
85211314,35013269,-85.56853,35.13269
85200594,35165607,-85.56853,35.165607
85257462,35015881,-85.56853,35.15881
85056649,35098115,-85.56853,35.98115
85056649,35098115,-85.56853,35.98115
85327874,35110546,-85.56853,35.110546
85134423,35112615,-85.56853,35.112615
85100611,35069722,-85.56853,35.69722
85383202,35018934,-85.56853,35.18934
85211326,35008570,-85.56853,35.857
85301228,35048436,-85.56853,35.48436 

Hi @tmoreland, a possible way is to use some FME String functions to create new values. You can set these expressions to the "Attribute Value" column in the AttributeManager or the AttributeCreator.

New Longitude:

-@Substring(@Value(Origional Longitude),0,2).@Trim(@Substring(@Value(Origional Longitude),2),0)

New Latitude:

@Substring(@Value(Origional Latitude),0,2).@Trim(@Substring(@Value(Origional Latitude),2),0)

See here to learn more about FME String functions: String Functions

Sorry for providing bad sample data. I wasn't aware the zeros were removed. So does that mean I can just use substring again and not trim or is a different string function needed?

 

 

Userlevel 2
Badge +17

Hi @tmoreland, a possible way is to use some FME String functions to create new values. You can set these expressions to the "Attribute Value" column in the AttributeManager or the AttributeCreator.

New Longitude:

-@Substring(@Value(Origional Longitude),0,2).@Trim(@Substring(@Value(Origional Longitude),2),0)

New Latitude:

@Substring(@Value(Origional Latitude),0,2).@Trim(@Substring(@Value(Origional Latitude),2),0)

See here to learn more about FME String functions: String Functions

Just not trim the zeros.

 

-@Substring(@Value(Origional Longitude),0,2).@Substring(@Value(Origional Longitude),2)
@Substring(@Value(Origional Latitude),0,2).@Substring(@Value(Origional Latitude),2)
 

Hi @tmoreland, a possible way is to use some FME String functions to create new values. You can set these expressions to the "Attribute Value" column in the AttributeManager or the AttributeCreator.

New Longitude:

-@Substring(@Value(Origional Longitude),0,2).@Trim(@Substring(@Value(Origional Longitude),2),0)

New Latitude:

@Substring(@Value(Origional Latitude),0,2).@Trim(@Substring(@Value(Origional Latitude),2),0)

See here to learn more about FME String functions: String Functions

@takashi Worked like a charm! Thank you for your help. 

 

Reply