Forum Discussion

KNO's avatar
KNO
Icon for Helper I rankHelper I
5 years ago
Solved

How to extract latitudes and longitude?

Hi, 

 

This is proberply a simple quest, but how would to extract coordinates that reside in the same column?

  • KNO 

    I created a sample:


    You can paste the code given below on a new blank query in the advanced editor and check the steps.

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bdC7CoAwDIXhd+lcQm+J7Vu4i7OL6OzbmyEROboVfr4eyLKE+dyv7TxCDIMy18KizxTW+E4s1IWl/qRBJZnKqCYSU5hU+VZB1amZwjSo+lZFpT+awqTKtxokSZRMYRrUfIu/yq+BSZVvCar8XEPTegM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [geometry.type = _t, geometry.coordinates = _t, Indeks = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"geometry.type", type text}, {"geometry.coordinates", type number}, {"Indeks", Int64.Type}}),
        #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
        #"Inserted Modulo" = Table.AddColumn(#"Added Index", "Modulo", each Number.Mod([Index], 2), type number),
        #"Removed Columns" = Table.RemoveColumns(#"Inserted Modulo",{"Index"}),
        #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Removed Columns", {{"Modulo", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Removed Columns", {{"Modulo", type text}}, "en-US")[Modulo]), "Modulo", "geometry.coordinates"),
        #"Renamed Columns" = Table.RenameColumns(#"Pivoted Column",{{"1", "Lat"}, {"0", "Log"}})
    in
        #"Renamed Columns"

     

    Result:

     



     

1 Reply

  • KNO 

    I created a sample:


    You can paste the code given below on a new blank query in the advanced editor and check the steps.

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bdC7CoAwDIXhd+lcQm+J7Vu4i7OL6OzbmyEROboVfr4eyLKE+dyv7TxCDIMy18KizxTW+E4s1IWl/qRBJZnKqCYSU5hU+VZB1amZwjSo+lZFpT+awqTKtxokSZRMYRrUfIu/yq+BSZVvCar8XEPTegM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [geometry.type = _t, geometry.coordinates = _t, Indeks = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"geometry.type", type text}, {"geometry.coordinates", type number}, {"Indeks", Int64.Type}}),
        #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
        #"Inserted Modulo" = Table.AddColumn(#"Added Index", "Modulo", each Number.Mod([Index], 2), type number),
        #"Removed Columns" = Table.RemoveColumns(#"Inserted Modulo",{"Index"}),
        #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Removed Columns", {{"Modulo", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Removed Columns", {{"Modulo", type text}}, "en-US")[Modulo]), "Modulo", "geometry.coordinates"),
        #"Renamed Columns" = Table.RenameColumns(#"Pivoted Column",{{"1", "Lat"}, {"0", "Log"}})
    in
        #"Renamed Columns"

     

    Result: