TransWikia.com

gdal_polygonize not converting raster values

Geographic Information Systems Asked on August 5, 2021

I am trying to convert a weather radar geoTIF to geoJSON using gdal_polygonize.

enter image description here

I am sharing the original .tif on google drive :
https://drive.google.com/file/d/1p2eE0QUtNypNjs5Qb9JBfXrDdMd8Ifpb/view?usp=sharing

My command to convert is :

python gdal_polygonize.py -q KEWX_L2_BREF_RAW_20210624_165114.tif -f "GeoJSON" myPolygonizedImage.geojson

It produces a file with lots of data that looks to be correct, but there is no information about the color values. Example of the output for a random polygon :

{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -95.429, 32.3965 ], [ -95.429, 32.394 ], [ -95.4265, 32.394 ], [ -95.4265, 32.3965 ], [ -95.429, 32.3965 ] ] ] } },

Is there a way to also have the script place color value data in the output? I am new to gdal_polygonize – maybe I am not understanding the basics? I am using GDAL 3.1.0, released 2020/05/03.

One Answer

As documented https://gdal.org/programs/gdal_polygonize.html gdal_polygonize should create an attribute.

This utility creates vector polygons for all connected regions of pixels in the raster sharing a common pixel value. Each polygon is created with an attribute indicating the pixel value of that polygon.

By default the field is named "DN"

I used your command with GDAL 3.1.4 installed with OSGeo4W installer on Windows and I got a result that contains features with DN attribute

{ "type": "Feature", "properties": { "DN": 89 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -98.959, 33.4565 ], [ -98.959, 33.454 ], [ -98.9465, 33.454 ], [ -98.9465, 33.4565 ], [ -98.959, 33.4565 ] ] ] } },

I do not what goes wrong for you.

Answered by user30184 on August 5, 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