On Wed, Apr 23, 2008 at 12:09 PM, Tim Michelsen <[EMAIL PROTECTED]> wrote: > Hello, > taking up on the post on accessing raster data from python [1] I'd like > to ask for your advice on writing arrays (numpy arrays) to python > raster/vector. > > I have a array of data of which I know the four boundary coordinates. > The array is a numpy array. > > Is there any example on how I can save this to a geoformat like Arc/Info > ASCII Grid or GeoTiff (including the world file)? > > How can I save a array of the form > xi yi zi > to a gdal raster? > > Are there also examples or tutorials for vector data input/output with > python? > I know that matplotlib basemap has a shapefile interface and can plot on > basemaps. > > Thanks and kind regards, > Tim > > [1]: http://permalink.gmane.org/gmane.comp.python.gis/15 > > _______________________________________________ > Community mailing list > [email protected] > http://lists.gispython.org/mailman/listinfo/community >
hi, for raster, i use something like below, which gives a georeferenced tiff. that's for an N * N array so you'd need to get your x, y, z data in that format. if you have irregularly spaced points you need a grid first. the module here: http://code.google.com/p/griddata-python/ will do that with the minimal amount of pain. from osgeo import gdal, gdal_array import numpy from osgeo.gdalconst import GDT_Float64 xsize, ysize = 10, 10 a = numpy.random.random((xsize, ysize)).astype(numpy.float64) xmin, xmax = -121., -119. ymin, ymax = 41., 43. driver = gdal.GetDriverByName('GTiff') out = driver.Create('a.tiff', a.shape[0], a.shape[1], 1, GDT_Float64) out.SetGeoTransform([xmin , (xmax - xmin)/a.shape[0] , 0 , ymin , 0 , (ymax - ymin)/a.shape[1]]) gdal_array.BandWriteArray(out.GetRasterBand(1), a) _______________________________________________ Community mailing list [email protected] http://lists.gispython.org/mailman/listinfo/community
