GDAL polygonize command line and python
<p>I have been using <code>gdal</code> from the command line to convert an <code>asc</code> file to a <code>GeoJSON</code> output. I can do this successfully:</p>

<p><code>gdal_polygonize.py input.asc -f "GeoJSON" output.json</code></p>

<p>Now I wish to use Python and follow this process for a range of files.</p>

<pre><code>import gdal
import glob
for file in glob.glob("dir/*.asc"):
    new_name = file[:-4] + ".json"
    gdal.Polygonize(file, "-f", "GeoJSON", new_name)
</code></pre>

<p>Hpwever, for exactly the same file I get the following error <code>TypeError: in method 'Polygonize', argument 1 of type 'GDALRasterBandShadow *'</code></p>

<p>Why does the command line version work and the python version not?</p>