[gdal-dev] Re: Open source API to convert raster to polygons? ( Roger Andr? )

Dan Stahlke dstahlke at gi.alaska.edu
Fri Jan 18 18:41:13 EST 2008


I have a C program that will create a polygon around the non-zero pixels 
of an image.  It was written for Unix so I don't know how hard it would 
be to get it to compile in Windows.  The program is fast though - the 
reading of the image from disk takes as long as the actual polygon 
tracing.  There are many options available including the ability to use 
the Douglas-Peucker algorithm to reduce the number of points in the 
polygon.  Output is in WKT format and can be either in the projection of 
the source image or in longitude/latitude.  Here is the link to the 
source code:
http://www.gina.alaska.edu/page.xml?group=projects&page=gdalscripts

gdal-dev-request at lists.osgeo.org wrote:
> Hi Ricardo,
>
> I had to do the same thing yesterday and wrote the script that's 
> attached here.  It will read a raster data file and create a polygon 
> for each pixel that does not have a value of 0.0.  The input, output 
> and pixel value are all hard-coded, and the script is pretty crude, 
> but it seems to work.  I'll warn you ahead of time that the shapefiles 
> it creates are large, with a very high feature count. Oh, and I make 
> no attempt to assign SRS, the shapefile will be in whatever projection 
> the input raster is in.
>
> Hope that helps,
>
> Roger
> --
> PS - If anyone else reads this and has suggestions for optimizing 
> performance, I would really welcome them.



More information about the gdal-dev mailing list