[SciPy-User] ROI, the sequel

Pinner, Luke Luke.Pinner@environment.gov...
Tue Aug 3 22:07:11 CDT 2010

GDAL/OGR perhaps? www.gdal.org

Some semi-pseudo code below.

from osgeo import gdal,gdal_array,ogr
import numpy

# Open a polygon layer to rasterize from.
poly_ds = ogr.Open( some file dataset ) #Can also create an in-memory poly layer from scratch

# Create an in-memory raster to rasterize into
target_ds = gdal.GetDriverByName('MEM').Create( approriate args...)

gdal.RasterizeLayer( appropriate args... )
numpy_array = gdal_aray.DatasetReadAsArray(target_ds)

Then use the numpy_array as you lie.


-----Original Message-----
From: scipy-user-bounces@scipy.org [mailto:scipy-user-bounces@scipy.org] On Behalf Of Thøger Emil Juul Thorsen
Sent: Wednesday, 4 August 2010 10:05 AM
To: scipy-user@scipy.org
Subject: [SciPy-User] ROI, the sequel

Hello list; 

I need a tool for polygon clipping of 2d NumPy arrays, but I cannot seem
to find anything. Shapely will only export the vertices of the polygon.
NXutils and patches in matplotlib seem to be purely visual, in any case
I cannot see how they would be saved as arrays in data coordinates. 

There is a very neat IDL routine, POYFILLV which returns a 1d array of
the (1d) indices of the pixels that are inside the polygon, sort of like
a "where" function. Is there anything like it out there for numpy



SciPy-User mailing list

If you have received this transmission in error please notify us immediately by return e-mail and delete all copies. If this e-mail or any attachments have been sent to you in error, that error does not constitute waiver of any confidentiality, privilege or copyright in respect of information in the e-mail or attachments. 

Please consider the environment before printing this email.


More information about the SciPy-User mailing list