[gdal-dev] Re: python memory driver
Chaitanya kumar CH
chaitanya.ch at gmail.com
Thu May 5 10:53:41 EDT 2011
You can use the Memory raster driver just like you would use any other
format driver. Use the ReadRaster() function.
Refer to http://www.gdal.org/gdal_tutorial.html
On Thu, May 5, 2011 at 7:59 PM, Juliannerc <juliannerc at gmail.com> wrote:
> Thanks for the response.
> Are the code snippets below what you mean by the memory drivers?
> # Create a memory raster to rasterize into.
> target_dr = gdal.GetDriverByName ('MEM')
> target_ds = target_dr.Create ('',
> # Create a memory layer to rasterize from.
> rast_dr = ogr.GetDriverByName ('Memory')
> rast_ogr_ds = rast_dr.CreateDataSource ('wrk')
> That part of the example code works fine. The lines and polygons created
> the ogr layer are rasterized as expected according to the transform
> # Run the algorithm.
> err = gdal.RasterizeLayer (target_ds,
> [2, 3, 1],
> burn_values = [240, 80, 200])
> At this point, I believe that the raster image(s) (per layer) are in the
> memory because the write to the disk produces the expected image:
> out_dr = gdal.GetDriverByName ('pnm')
> out_dr.CreateCopy ('./rasterize_1.ppm',
> My BIG question is whether or not there is a way to get at the memory
> portion of the raster bands. The ideal way (in Python) would be to get a
> numpy array as one does in the ReadAsArray option. However, I'm not sure
> that there is a way, and if so, how to do it.
> I believe that the C interface allows one access to the data store using:
> If all else fails, one can create the images, write them to disk (maybe
> memory file?) and then read them back as needed. It seems unnecessary to
> have to go through the compression/write step when the object is right
> Further clarification would be very welcome.
> View this message in context:
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
Chaitanya kumar CH.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gdal-dev