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

Brent Fraser bfraser at geoanalytic.com
Wed Jun 4 17:17:44 EDT 2008


Dan (and others),

I've compiled your gdal_trace_outline code on Windows XP / VS2003.NET with only a few minor problems (I can send details if you are interested).

Unfortunately I've got a bunch (56) 1-bit tiff files generated from an image segmentation process I want lines (ok, polygons) for.  So I really want to vectorize the centerline of the pixels, not their outlines.  How hard would it be to modify gdal_trace_outline to do this?

To others interested:  
	I've experimented with ras2vec (http://www.xmailserver.org/davide.html) and had some success, but it misses generating a few line segments where the "edge" pixels are adjacent. I've been able to use OpenJump to polygonize the lines (after bumping up the allocated memory on startup), so that part is ok.

	I plan on looking into Grass too...

Thanks!
Brent Fraser
GeoAnalytic Inc. 

Dan Stahlke wrote:
> 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.
> 
> _______________________________________________
> 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