# How to import a GeoJSON to elastic.. using Logstash or any other possible way

**URL:** <https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001>\
**Category:** Elasticsearch\
**Created:** [November 7, 2019, 7:15pm UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001 "2019-11-07T19:15:46Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jayasri\_Cimba](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jayasri_cimba/32/50397_2.png) [@Jayasri\_Cimba](https://discuss.elastic.co/u/Jayasri_Cimba)\
**Post date:** [November 7, 2019, 7:15pm UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/1 "2019-11-07T19:15:47Z")

</div>

My sample GeoJSON file..

```
"type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "FIDindex": 6035
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              -79.51092606323992,
              48.344613038602226
            ],
            [
              -79.5331359417738,
              48.330644012951296
            ],
            [
              -79.54767721776007,
              48.34385594693975
            ],
            [
              -79.54098581498502,
              48.34806594628507
            ],
            [
              -79.51092606323992,
              48.344613038602226
            ]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "FIDindex": 6036
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              -79.49765416107279,
              48.50665405729244
            ],
            [
              -79.50452010147922,
              48.497367987214574
            ],
            [
              -79.52998110253995,
              48.49616195107807
            ],
            [
              -79.51270010258166,
              48.52528298266071
            ],
            [
              -79.49765416107279,
              48.50665405729244
            ]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "FIDindex": 6037
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              -79.4937419793212,
              49.08821604910215
            ],
            [
              -79.52318087215492,
              49.02943208366772
            ],
            [
              -79.55202111684834,
              49.03141796850029
            ],
            [
              -79.56778415808171,
              49.056759963348156
            ],
            [
              -79.4937419793212,
              49.08821604910215
            ]
          ],
          [
            [
              -79.5365910174132,
              49.04234909537448
            ],
            [
              -79.53981414365047,
              49.04198099108133
            ],
            [
              -79.5416999721036,
              49.04055804587344
            ],
            [
              -79.538320178897,
              49.04091392507655
            ],
            [
              -79.5365910174132,
              49.04234909537448
            ]
          ],
          [
            [
              -79.53314181028657,
              49.047972036859456
            ],
            [
              -79.54218399465174,
              49.04691700341087
            ],
            [
              -79.54466192708877,
              49.04621599583252
            ],
            [
              -79.53695381365907,
              49.044765936954086
            ],
            [
              -79.53314181028657,
              49.047972036859456
            ]
          ],
          [
            [
              -79.52812883212242,
              49.050876877000356
            ],
            [
              -79.53206385269057,
              49.051771037330965
            ],
            [
              -79.5346651964943,
              49.05115596741972
            ],
            [
              -79.5336059608879,
              49.05080696502161
            ],
            [
              -79.52812883212242,
              49.050876877000356
            ]
          ],
          [
            [
              -79.5202589809016,
              49.05320498871566
            ],
            [
              -79.52311796828306,
              49.0535590070871
            ],
            [
              -79.5249519759151,
              49.0516320071246
            ],
            [
              -79.52163902727364,
              49.05194802154083
            ],
            [
              -79.5202589809016,
              49.05320498871566
            ]
          ]
        ]
      }
    },

```

..... goes on like this ..

am trying to index this in Kibana..

It is a Shapefile .. which I converted to GeoJSON .. I dint upload it directly on Kibana because of the size limitation and also I have this GeoJSON size(7 MB) still takes forever to index it when uploaded as GeoJSON in Kibana maps directly.. Looking for a best way to load this GeoJSON on to kibana/elastic

_ **How can this be done using Logstash / elastic ?** _

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [November 8, 2019, 4:05am UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/2 "2019-11-08T04:05:23Z")

</div>

If you are using 7.3 or 7.4 of the default distribution you could try using the GeoJSON Upload feature in the Maps application. [https://www.elastic.co/guide/en/kibana/current/geojson-upload.html](https://www.elastic.co/guide/en/kibana/current/geojson-upload.html)

---

<div class="post-metadata">

**Author:** ![Jayasri\_Cimba](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jayasri_cimba/32/50397_2.png) [@Jayasri\_Cimba](https://discuss.elastic.co/u/Jayasri_Cimba)\
**Post date:** [November 8, 2019, 3:24pm UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/3 "2019-11-08T15:24:03Z")

</div>

@nickpeihl I am using 7.3 version and my GeoJSON file size is 7MB it shows on the map but it takes forever to index. And also I have a GeoJSON of file size 30MB it doesn't show on the Map either and the progress bar shows loading... So I was wondering what could be done. In the first case while loading the 7MB file .. it doesn't throws this error

```auto
{
  "success": false,
  "failures": [],
  "docCount": 0,
  "error": {
    "displayName": "RequestTimeout",
    "message": "Request Timeout after 30000ms"
  }
}

```

_ **And also what if the GeoJSON size it greater than 50MB, how to ingest it ?** _

---

<div class="post-metadata">

**Author:** ![Jayasri\_Cimba](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jayasri_cimba/32/50397_2.png) [@Jayasri\_Cimba](https://discuss.elastic.co/u/Jayasri_Cimba)\
**Post date:** [November 12, 2019, 6:15pm UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/4 "2019-11-12T18:15:38Z")

</div>

@nickpeihl Can you help me to figure this out.

_Thanks in advance!_

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [November 13, 2019, 6:25pm UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/5 "2019-11-13T18:25:52Z")

</div>

Strange the GeoJSON Upload isn't working for you. Perhaps the 7.4 release of Elasticsearch and Kibana might work better.

For files larger than 50MB, you might use [GDAL](https://gdal.org/). GDAL has [an output driver for Elasticsearch](https://gdal.org/drivers/vector/elasticsearch.html). However, the current release (v3.0.2) does not work with Elasticsearch 7. Support for Elasticsearch 7+ was added in the master branch. So you can [build GDAL from source](https://trac.osgeo.org/gdal/wiki/BuildHints) or use one of the [nightly docker images](https://gdal.org/download.html#linux-docker-images) if you have Docker installed.

I have some examples here for using GDAL with Elasticsearch: [https://gist.github.com/nickpeihl/1a8f9cbecc78e9e04a73a953b30da84d](https://gist.github.com/nickpeihl/1a8f9cbecc78e9e04a73a953b30da84d)

---

<div class="post-metadata">

**Author:** ![Jayasri\_Cimba](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jayasri_cimba/32/50397_2.png) [@Jayasri\_Cimba](https://discuss.elastic.co/u/Jayasri_Cimba)\
**Post date:** [December 3, 2019, 2:20pm UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/6 "2019-12-03T14:20:29Z")

</div>

Hi @nickpeihl, I have tried using GDAL and I got this error

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/a/fa5f91366b90496ecd1c9bd11214497ca354ef64.jpeg)

> ERROR 1: HTTP error code : 400  
> ERROR 1: {"error":{"root\_cause":[{"type":"illegal\_argument\_exception","reason":"Types cannot be provided in put mapping requests, unless the include\_type\_name parameter is set to true."}],"type":"illegal\_argument\_exception","reason":"Types cannot be provided in put mapping requests, unless the include\_type\_name parameter is set to true."},"status":400}  
> ERROR 1: Unable to write feature 0 from layer quebec.  
> ERROR 1: Terminating translation prematurely after failed  
> translation of layer quebec (use -skipfailures to skip errors)

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [December 3, 2019, 4:24pm UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/7 "2019-12-03T16:24:23Z")

</div>

Hi @Jayasri_Cimba, I believe this error is caused by an older version of GDAL that does not support Elasticsearch 7. Can you paste the output of `ogr2ogr --version`?

GDAL 3.1.0 is required to ingest into Elasticsearch 7. But GDAL 3.1.0 is not released yet. So the best way to get GDAL to support Elasticsearch 7 is by [building from source](https://trac.osgeo.org/gdal/wiki/BuildHints). This may look daunting, but should be relatively easy on most operating systems.

If you have Docker installed on your local machine, you can also try using the nightly Docker images of GDAL ([examples here](https://gist.github.com/nickpeihl/1a8f9cbecc78e9e04a73a953b30da84d#examples-using-nightly-docker-images)).

I have also written a [detailed blog post](https://www.elastic.co/blog/how-to-ingest-geospatial-data-into-elasticsearch-with-gdal) that contains most of the information I have shared with you.

---

<div class="post-metadata">

**Author:** ![Jayasri\_Cimba](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jayasri_cimba/32/50397_2.png) [@Jayasri\_Cimba](https://discuss.elastic.co/u/Jayasri_Cimba)\
**Post date:** [December 3, 2019, 4:37pm UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/8 "2019-12-03T16:37:42Z")

</div>

Hi @nickpeihl  
_I have gdal installed on my MACOS its version 2.4.2_

I have tried using this command

```auto
ogr2ogr -lco INDEX_NAME=gdal-data -lco NOT_ANALYZED_FIELDS={ALL} -lco WRITE_MAPPING=./mapping.json ES:http://localhost:9200 my_shapefile.shp

```

to create a mapping file and I get this in the output file

> { "FeatureCollection": { "properties": { "type": { "type": "text" }, "properties": { "properties": { "Lower": { "type": "double" }, "Upper": { "type": "double" } } }, "geometry": { "type": "geo\_shape" } }, "\_meta": { "fid": "ogc\_fid", "geomfields": { "geometry": "POLYGON" } } } }

So, Once after I get the map.json what is the next step? How can I see the index on Kibana?

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [December 3, 2019, 6:01pm UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/10 "2019-12-03T18:01:58Z")

</div>

Hi @Jayasri_Cimba,

Unfortunately, GDAL version 2.4.2 will not work with your Elasticsearch 7.3 version. You will have to upgrade to GDAL 3.1.0 by building from the source code.

I also have a Mac and this is how I build GDAL from source.

1. Clone the [gdal repository](https://github.com/osgeo/gdal) to my computer
2. `cd` into the gdal subdirectory of the repository
3. Run `./configure`
4. Run `make` (this will take a long time)
5. Run `make install`
6. Run `ogr2ogr --version` to confirm I am running 3.1.0-dev-\*.

---

<div class="post-metadata">

**Author:** ![Jayasri\_Cimba](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jayasri_cimba/32/50397_2.png) [@Jayasri\_Cimba](https://discuss.elastic.co/u/Jayasri_Cimba)\
**Post date:** [December 3, 2019, 7:01pm UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/11 "2019-12-03T19:01:08Z")

</div>

Hi @nickpeihl , I have installed gdal-3.0.2 and tried to do this

```
jayasri-cimba:Users jayasri$ ogr2ogr ES:http://localhost:9200 /Users/jayasri/quebec.shp
ERROR 1: HTTP error code : 400
ERROR 1: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."}],"type":"illegal_argument_exception","reason":"Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."},"status":400}
ERROR 1: Unable to write feature 0 from layer quebec.
ERROR 1: Terminating translation prematurely after failed
translation of layer quebec (use -skipfailures to skip errors)

```

> ```
> jayasri-cimba:Users jayasri$ ogr2ogr --version
> GDAL 3.0.2, released 2019/10/28 
> 
> ```

Still it throws the same error. Am not sure what to be done.

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [December 4, 2019, 1:01am UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/12 "2019-12-04T01:01:22Z")

</div>

Hi @Jayasri_Cimba,

GDAL 3.0.2 is not compatible with Elasticsearch 7. Please follow the [steps above](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/7) to build **GDAL 3.1.0** from the source code.

---

<div class="post-metadata">

**Author:** ![Jayasri\_Cimba](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jayasri_cimba/32/50397_2.png) [@Jayasri\_Cimba](https://discuss.elastic.co/u/Jayasri_Cimba)\
**Post date:** [December 4, 2019, 3:40pm UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/13 "2019-12-04T15:40:05Z")

</div>

Hi @nickpeihl..

Thank you so much. It fixed all my issues. Appreciating your patience 😃  
Thanks once again

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 1, 2020, 3:40pm UTC](https://discuss.elastic.co/t/how-to-import-a-geojson-to-elastic-using-logstash-or-any-other-possible-way/207001/14 "2020-01-01T15:40:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
