[gdal-dev] [GDAL 1.7] GDAL_Contour png file

Ari Jolma ari.jolma at gmail.com
Mon Jun 7 10:51:43 EDT 2010


Paul,

Paul Meems wrote:
> Hi List,
>
> I'm trying to vectorize a png file to a shapefile.
> This png file only contains lines with one color.
> Using this command a nice shapefile is generated:
> gdal_contour -a elev test.png contour.shp -i 10.0 -snodata 255
>
> But the shapefile is the wrong size up.
> Up and bottom are flipped.
> How do I fix that?

If you do not provide a GeoTransform to the png file then it is "upside 
down" as the default coefficient for y_line is 1 and not -1. It can be 
set from a world file as explained here: 
http://www.gdal.org/frmt_various.html

>
> The generated shapefile is huge: 97MB from a 205 kB png file (high 
> resolution: 6720 x 4984  Pixels)
> The shapes created are all very small/short and should be chained 
> together. Can GDAL do that as well?

Maybe the png file contains many 8-connected features? Polygonize uses 
4-connectness. Polygonize method doesn't seem to have connectedness 
parameter, which is a pity IMHO(*).

>
> I tried gdal_polygonize.py already and that is looking better, but 
> because not all lines are correctly closed not all polygons are good.
> I'm looking for something similar, but the output should be polylines 
> instead of polygons.

I'm not aware of vectorize method in GDAL, which produces polylines.

Best regards,

Ari

(*) maybe we could use the Options list for that?

>
> Thanks in advanced for any advice.
>
> Paul
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev



More information about the gdal-dev mailing list