[gdal-dev] Polygonize via Python on Windows

Jay Jennings Jennings.Jay at geoeye.com
Mon Apr 25 15:17:48 EDT 2011


Thanks Elijah, that thread does look promising.  But it involves using gdal_polygonize.py, which is giving me trouble (we haven't tried GDAL/Python options before).  Initial attempt at gdal_polygonize.py gives the error "ImportError: No module named gdal".  After researching the archives, I found some advice from Howard Butler in October 2007 to go to the 'swig' directory and do 'nmake -f makefile.vc python'.  Tried that, and it processed for awhile then quit with this error msg:

"error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.
NMAKE : fatal error U1077: 'C:\Python25\python.exe' : return code '0x1'
Stop. "

It's true, I don't have VS 2003, but I do have VS 2008 and VS 2010.

Does anyone have setup advice on using gdal_polygonize.py on Windows 7 64-bit with GDAL 1.8.0 ?  I have a feeling I'm missing something simple.  We have GDAL 1.8.0 built from source, which works well, but we've never used the Python options.  Most of the GDAL/Python discussions in the archives seem to be about Linux or Apple OS.  Thanks for any guidance.
PS I have Python 2.5 installed.
--JJ

-----Original Message-----
From: Elijah Robison [mailto:elijah at villagis.com] 
Sent: Friday, April 22, 2011 3:05 PM
To: Jay Jennings
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] Polygonize from C# ?

Hi Jay, you might want to review the following thread (Get extent from 
rasters).  Based on a cursory read of his advice, I believe Trent offers 
a solution that might accommodate your task:  
http://lists.maptools.org/pipermail/fwtools/2010-October/001886.html

/Elijah


Jay Jennings wrote:
> Correct, we just need the footprint of the "good" (non-NODATA) area, which will often approximate a simple 4-point polygon with no holes.
>
> -----Original Message-----
> From: Elijah Robison [mailto:elijah at villagis.com] 
> Sent: Friday, April 22, 2011 2:07 PM
> To: Jay Jennings
> Cc: gdal-dev at lists.osgeo.org
> Subject: Re: [gdal-dev] Polygonize from C# ?
>
> Jay, do you basically want a footprint shape of the useful data in the 
> Sat images (say, without the collar), or is the problem more complex, 
> where perhaps you have a mosaic of several images and, like swiss 
> cheese, there are no-data holes within the image?
>
> It sounds to me like you just want a footprint of the collarless area; 
> is this correct? 
>
> /Elijah
>
> Jay Jennings wrote:
>   
>> I see, thanks.  But since I have satellite images, this part of the doc is alarming: "...For non-thematic raster data (such as satellite images) 
>> the result will essentially be one small polygon per pixel, and memory and output layer sizes will be substantial. The algorithm is primarily 
>> intended for relatively simple thematic imagery, masks, and classification results".
>>
>> I just want one polygon enclosing the non-zero pixels (or alternatively, enclosing the zero pixels, then I could do a geometric 
>> difference).  Is there any way to trick the method into doing that, to maybe avoid the heavy resource needs ?
>>
>>
>> -----Original Message-----
>> From: Even Rouault [mailto:even.rouault at mines-paris.org] 
>> Sent: Friday, April 22, 2011 11:45 AM
>> To: Jay Jennings
>> Cc: gdal-dev at lists.osgeo.org
>> Subject: Re: [gdal-dev] Polygonize from C# ?
>>
>> Selon Jay Jennings <Jennings.Jay at geoeye.com>:
>>
>> Generally, refering to the C/C++ doc is a good way of finding the info :
>>
>> See http://gdal.org/gdal__alg_8h.html#3f522a9035d3512b5d414fb4752671b1
>>
>>   
>>     
>>> Hi list,
>>> Can anyone point to any guidance or (preferably) examples on using
>>> GDAL.Polygonize() with C# bindings ?  I see what the interface is, but there
>>> are some unexplained parameters, e.g. "string[] options".
>>>
>>> My eventual goal is to open a raster and produce a WKT POLYGON string
>>> enclosing the "good" (non-NoData) area of the raster.  Thanks.
>>>
>>> .........................................................
>>> Jay Jennings
>>> jennings.jay at geoeye.com
>>>
>>>
>>>
>>>
>>>
>>>     
>>>       
>> _______________________________________________
>> 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