# Problem to parse geo\_shape from .csv trough logstash

**URL:** https://discuss.elastic.co/t/problem-to-parse-geo-shape-from-csv-trough-logstash/183780
**Category:** Logstash
**Created:** [May 31, 2019, 6:14pm UTC](https://discuss.elastic.co/t/problem-to-parse-geo-shape-from-csv-trough-logstash/183780 "2019-05-31T18:14:12Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![grainsngrubble](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grainsngrubble/32/47260_2.png) [@grainsngrubble](https://discuss.elastic.co/u/grainsngrubble)
#### Post date: [June 8, 2019, 10:34am UTC](https://discuss.elastic.co/t/problem-to-parse-geo-shape-from-csv-trough-logstash/183780/2 "2019-06-08T10:34:38Z")

</div>

I found a solution myself with a lot of help from this post [by Badger](https://discuss.elastic.co/t/geo-shape-geo-link-problems-with-coordinates/179924/5) and thought I share it if others encounter the same issue.

First, the coordinates should not be arranged in an array in the inout.csv file. Of course you can split the array etc in logstash. But for convenience I arranged my coordinates as below:

`-74.0446, 40.6899,-74.0416, 40.6996`

My logstash.conf for converting the coordinates into a geo\_point location and a linestring geo\_shape. I have excluded the part not relevant for the geo operations.

```
filter {
	 csv { separator => ","
	           columns => ["loc_lat","loc_lon","proj_lat","proj_lon"]
	 }
	 mutate { add_field => ["[location]", "%{loc_lon}"]
                   add_field => ["[location]", "%{loc_lat}"]
         }
         mutate { convert => ["[location]", "float"]
                   convert => ["[loc_lat]", "float"]
                   convert => ["[loc_lon]", "float"]
                   convert => ["[proj_lat]", "float"]
                   convert => ["[proj_lon]", "float"]
         }
         mutate { add_field => ["[projection][type]", "linestring"]
         }
         ruby { code => "event.set('[projection][coordinates]', [[event.get('loc_lon'), event.get('loc_lat')], [event.get('proj_lon'), event.get('proj_lat')]])"
}

```

Result in cmd with rubedebug:

```
  {          
        "projection" => {
                "coordinates" => [
                    [0] [
                        [0] -74.0446,
                        [1] 40.6899
                    ],
                    [1] [
                        [0] -74.0416,
                        [1] 40.6996
                    ]
                ],
                       "type" => "linestring"
            },
                "location" => [
                    [0] -74.0446,
                    [1] 40.6899
                ]
  }
```

---

_[View the full topic](https://discuss.elastic.co/t/problem-to-parse-geo-shape-from-csv-trough-logstash/183780)._
