[OSGeo-Discuss] clip raster by a circle in map coordinates

Markus Neteler neteler.osgeo at gmail.com
Mon Aug 13 13:32:05 PDT 2007


On 8/13/07, Marc Peterson <Marc.Peterson at gmx.net> wrote:
> I need to clip an input raster data set by a circle and write the extracted
> cells to a new raster.  Then I have to repeat 35,387 times, so any solution
> needs to be scriptable.  The dream solution would be to issue a command with
> arguments specifying the X coordinate, Y coordinate, and radius.  I assume,
> however, that I'll need to do some sort of intersect operation using either
> a mask matrix, a rasterized vector circle, or some XML that defines the
> circle.
>
> Is this possible?  Any script/software recommendations?  I started looking
> in to GRASS r.circle but haven't yet gotten very far.  Basically, I want to
> do what the ArcGIS "Extract by Circle" tool will do, but I want to do it
> much more quickly and without ESRI.
>
> Thanks,
> Marc Peterson
> Spatial Analyst
> Carolina Population Center, UNC Chapel Hill

Marc,

in GRASS, it would be v.buffer which (also) generates circles.
Then v.to.rast and r.mapcalc (ifnull() function), then r.out.gdal.
It is completely scriptable, e.g. in a few lines of shell script or
PERL or Python.

For a Web based solution, you can embed everything in PyWPS
(http://pywps.wald.intevation.org/) - Web Processing Service with
GRASS as backbone, Python based.

Best
Markus

-- 
Open Source Geospatial Foundation
http://www.osgeo.org
http://www.grassbook.org



More information about the Discuss mailing list