[gdal-dev] Zonal statistics with GDAL/StarSpan
Brent Fraser
bfraser at geoanalytic.com
Thu Dec 18 15:21:16 EST 2008
Greg,
OpenJump is a good topology/geometry fixing tool. Load your shapefile and do Tools->Generate->Buffer, set the Buffer distance to 0 to clean up the polygon vertices. I seem to recall it may have a problem preserving attributes when the results are saved as a shapefile, but you may be able to just use the new .shp portion with the old .dbf and .shx if the resulting geometry records are not re-ordered.
Brent
Greg Ederer wrote:
> Brent,
>
> My Google search didn't turn up much of use (most of the results were
> PostGIS-specific). Do you know of a tool that would tell me which
> feature(s) have problems? Do you know of a tool that might be able to
> fix these polygons?
>
> Thanks!
>
> Greg
>
> Brent Fraser wrote:
>> Greg,
>>
>> It means the GEOS topology library is having problems with geometry
>> of your input shapefile. Most likely related to duplicate vertices
>> (or near-duplicate) in a polygon. Do a Google for "side location
>> conflict". It would be nice if it spat out the FID of the offending
>> polygon...
>>
>> Brent
>> Greg Ederer wrote:
>>> Hi Brent,
>>>
>>> Thanks for the example. Here's what I got:
>>>
>>> Macintosh-4:starspan_tests gregederer$ starspan2 --progress --RID
>>> none --vector
>>> /Users/gregederer/servers/geoserver_data/data/shapefiles/Admin/afadmn2n.shp
>>> --raster rfe_2006_04_pct.tif --stats results.txt avg
>>> starspan: --out-prefix: ?
>>> Type `starspan --help' for help
>>>
>>> I then added a --out-prefix, like so:
>>>
>>> Macintosh-4:starspan_tests gregederer$ starspan2 --progress --RID
>>> none --vector
>>> /Users/gregederer/servers/geoserver_data/data/shapefiles/Admin/afadmn2n.shp
>>> --raster rfe_2006_04_pct.tif --stats results.txt avg --out-prefix bar
>>> starspan: --out-type: ?
>>> Type `starspan --help' for help
>>>
>>> I then added '--out-type table' (I found in the source that valid
>>> --out-types are: table, mini_raster_strip, mini_rasters, rasterization):
>>>
>>> Macintosh-4:starspan_tests gregederer$ starspan2 --progress --RID
>>> none --vector
>>> /Users/gregederer/servers/geoserver_data/data/shapefiles/Admin/afadmn2n.shp
>>> --raster rfe_2006_04_pct.tif --stats results.txt avg --out-prefix
>>> bar --out-type table
>>> Number of features: 550
>>> starspan_csv: 1: Extracting from rfe_2006_04_pct.tif
>>> 0% terminate called after throwing an instance of
>>> 'geos::util::TopologyException'
>>> what(): TopologyException: side location conflict -8.25 23.1536
>>> Abort trap
>>>
>>> Any idea what the TopologyException indicates?
>>>
>>> Thanks!
>>>
>>> Greg
>>>
>>> Brent Fraser wrote:
>>>> Greg,
>>>>
>>>> I've used StarSpan to do similar things; in my case I wanted "mode"
>>>> not "avg". Using v1.2.01 (I don't think I made major mods to the
>>>> source):
>>>>
>>>> starspan2.exe --progress --RID none --vector boundaries.shp
>>>> --raster big.tif --stats results.txt mode
>>>>
>>>> I edited the resulting results.txt text (csv) file and used GDAL's
>>>> ogr2ogr to do a join on the shapefile's DBF file based on the FID.
>>>>
>>>> Brent Fraser
>>>>
>>>>
>>>> Greg Ederer wrote:
>>>>> Hello all,
>>>>>
>>>>> I'm a GDAL newbie. I have a shape file containing subnational
>>>>> boundaries for Africa. I have a raster containing rainfall for
>>>>> Africa. I need to pull out the spatial average of rainfall for
>>>>> each of the subnational units.
>>>>>
>>>>> I think that I might be able to pull this off using StarSpan. But,
>>>>> the docs on the StarSpan wiki do not line up with the current
>>>>> version of the program (the changelog mentions that certain command
>>>>> line switches have been eliminated, and others added; but it
>>>>> doesn't say what the new switches do, or how to use them). I am
>>>>> digging through the StarSpan sources to try to figure out how to
>>>>> use it.
>>>>>
>>>>> Does anyone have any suggestions as to how I might get the needed
>>>>> data using GDAL (with, or without StarSpan)?
>>>>>
>>>>> Thanks!
>>>>>
>>>>> Greg
>>>>>
>>>
>>>
>
>
More information about the gdal-dev
mailing list