title: Update values in geojson file in Python
body: <p>I have geojson file as follows:</p>
  
  <pre><code>{
    "type": "FeatureCollection",
    "features": [
      {
        "type": "Feature",
        "properties": {},
        "geometry": {
          "type": "LineString",
          "coordinates": [
            [
              57.45849609375,
              57.36801461845934
            ],
            [
              57.10693359375,
              56.31044317134597
            ],
            [
              59.205322265625,
              56.20059291588374
            ],
            [
              59.4140625,
              57.29091812634045
            ],
            [
              57.55737304687501,
              57.36801461845934
            ]
          ]
        }
      },
      {
        "type": "Feature",
        "properties": {},
        "geometry": {
          "type": "LineString",
          "coordinates": [
            [
              59.40307617187499,
              57.29685437021898
            ],
            [
              60.8203125,
              57.314657355733274
            ],
            [
              60.74340820312499,
              56.26776108757582
            ],
            [
              59.227294921875,
              56.21281407174654
            ],
            [
              59.447021484375,
              57.29091812634045
            ]
          ]
        }
      }
    ]
  }
  </code></pre>
  
  <p>I want to replace <code>LineString</code> in <code>"type": "LineString"</code> with <code>Polygon</code>, and also, replace coordinates last point of each <code>linestring</code> by coordinates of first point to make it close if it has more than 3 points. </p>
  
  <p>How can I do it in Python with geopandas or pandas? Thanks.</p>
  
  <p>Here is expected output:</p>
  
  <pre><code>{
    "type": "FeatureCollection",
    "features": [
      {
        "type": "Feature",
        "properties": {},
        "geometry": {
          "type": "Polygon",
          "coordinates": [
            [
              57.45849609375,
              57.36801461845934
            ],
            [
              57.10693359375,
              56.31044317134597
            ],
            [
              59.205322265625,
              56.20059291588374
            ],
            [
              59.4140625,
              57.29091812634045
            ],
            [
              57.45849609375,
              57.36801461845934
            ]
          ]
        }
      },
      {
        "type": "Feature",
        "properties": {},
        "geometry": {
          "type": "Polygon",
          "coordinates": [
            [
              59.40307617187499,
              57.29685437021898
            ],
            [
              60.8203125,
              57.314657355733274
            ],
            [
              60.74340820312499,
              56.26776108757582
            ],
            [
              59.227294921875,
              56.21281407174654
            ],
            [
              59.40307617187499,
              57.29685437021898
            ]
          ]
        }
      }
    ]
  } 
  </code></pre>
  
  <p>Script to get <code>type</code> and <code>coordinates</code> of first <code>LineString</code>:</p>
  
  <pre><code>import json
  from pprint import pprint
  
  with open('data.geojson') as f:
      data = json.load(f)
  
  pprint(data)
  
  data["features"][0]["geometry"]['type']
  data["features"][0]["geometry"]['coordinates']
  </code></pre>