TransWikia.com

Gdal_polygonize and gdaltindex error

Geographic Information Systems Asked by Omkar Kadlag on March 10, 2021

I’m trying to convert .tif file to .geojson using following cmd:

gdal_polygonize.py flowdirection.tif -f "ESRI Shapefile" flowdirection_shp.shp

After which I’m getting error:

Program 'gdal_polygonize.py' failed to run: Application not foundAt line:1 char:1
+ gdal_polygonize.py flowdirection.tif -f “ESRI Shapefile” flowdirectio ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
At line:1 char:1
+ gdal_polygonize.py flowdirection.tif -f “ESRI Shapefile” flowdirectio ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed

After that I just gave the same cmd but using -q :

gdal_polygonize.py -q flowdirection.tif -f "ESRI Shapefile" flowdirection_shp.shp

Still

Program 'gdal_polygonize.py' failed to run: Application not foundAt line:1 char:1
+ gdal_polygonize.py -q flowdirection.tif -f "ESRI Shapefile" flowdirec ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
At line:1 char:1
+ gdal_polygonize.py -q flowdirection.tif -f "ESRI Shapefile" flowdirec ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
    + FullyQualifiedErrorId : NativeCommandFailed

All other Gdal cmds are working but it seems some problem with gdal_polygonize.
Also I tried gdaltindex , but it gave me some error:

gdaltindex flowdirection_shp.shp doq/*flowdirection.tif
Creating new index file...
ERROR 4: doq/*flowdirection.tif: No such file or directory
ERROR 4: doq/*flowdirection.tif: No such file or directory
Unable to open doq/*flowdirection.tif, skipping.

One Answer

You have probably problem with installing Python and/or GDAL Python bindings. I guess that other Python utilities like gdal_calc.py will fail as well. When it comes to another problem, some Windows builds have had an issue with wildcards. They appeared after some Windows update. OSGeo4W and ones from gisinternals should work now. Otherwise make a list file for example with

dir /b doq/*flowdirection.tif > my_list.txt

and point gdaltindex to use my_list.txt as input.

I suppose that you really have that doq directory and you have not just copied it from the command help

Usage: gdaltindex [-f format] [-tileindex field_name] [-write_absolute_path]
                  [-skip_different_projection] [-t_srs target_srs]
                  [-src_srs_name field_name] [-src_srs_format [AUTO|WKT|EPSG|PROJ]
                  [-lyr_name name] index_file [gdal_file]*

e.g.
  % gdaltindex doq_index.shp doq/*.tif

Correct answer by user30184 on March 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP