<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Dave<div><br></div><div>Seems to me this is a point not a raster process you are looking for</div><div><br></div><div>e.g. How do I make a surface from a bunch of discrete points ?</div><div><br></div><div>So instead of having 3 bands of raster you want a stream of XYZ triplets</div><div>you can then submit these to gdal_grid or other tools that work with discrete </div><div>data </div><div><br></div><div><br></div><div>pseudo python assuming you have read your files into numpy arrays</div><div><br></div><div>XYZ = array( zip( bandX.flatten(), bandY.flatten(), bandZ.flatten() ) )</div><div><br></div><div>convert XYZ to any OGR format</div><div><br></div><div>call gdal_grid </div><div><br></div><div>HTH</div><div><br></div><div>Norman</div><div><br><div><div>On Jan 22, 2013, at 10:12 PM, David Hoese <<a href="mailto:dhoese@gmail.com">dhoese@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Jan, please CC the mailing list in your replies.<br><br>I have asked questions about not regularly spaced data on this mailing list before, I just can't find the thread atm. In your first point, do you mean my input data is "effectively a projected surface"? If so, then no it is not projected, there are lat/lon values for each individual pixel and they aren't evenly spaced. If you mean the output is projected, then yes, my software does the projecting from lat/lon space into a projection's metered (or degree) space. The data can then be interpolated and treated like gridding a scatter plot (see the griddata function in scipy and matlab).<br><br>The problem with GDAL and data that is not equally spaced geographically is that it describes the data with a geotransform. The geotransform (<a href="http://www.gdal.org/gdal_datamodel.html">http://www.gdal.org/gdal_datamodel.html</a>) only knows the origin of the data and the pixel size (ignoring the 2 rotation elements). So for my satellite data (VIIRS and MODIS), the data can not be properly represented. My data starts out at one resolution near the center of each row and loses quality as you go outward due to...the earth's shape :).<br><br>So if I understood you correctly, yes it is a hassle because you have to look at each lat/lon point. If you don't look at each point (as I have done with gdalwarp and its geotranforms) the produced image isn't "correct". The quality is wrong and you have problems with "the bow-tie effect". As far as I know, there are only 2 pieces of software currently in development that handle satellite data in this way. One is my software which isn't fully developed and uses a modified version of some old software to do the remapping (which is what I'm trying to replace, but it works). The second is pytroll, but doesn't meet the needs of my bosses and is slower than the old software I'm using.<br><br>I hope at least some of this makes sense. Thanks for sticking with my attempt at explanation. My final goal would be to add to GDAL the ability or a utility to remap satellite data. Sorry this got so long, I wasn't sure how much you knew about GDAL or satellite observations.<br><br>-Dave<br><br>On 1/22/2013 4:34 PM, Jan Heckman wrote:<br><blockquote type="cite">Hi Dave,<br>It sounds as you have effectively a projected surface. The projected<br>(satellite) image consists of regularly spaced pixels? So that the<br>pixels would ideally be warped back, perhaps not image-wise but<br>pixel-wise, which would be a bit of a hassle... Don't see yet that the<br>warp can't be done in one go, but that shows I'm still missing stuff, or<br>that the transformation has to be reformulated to get it to work.<br>So I have some hope that fiddling with gdalwarp might produce something<br>useful. Then, the sheer amount of data may ultimately be best served by<br>a dedicated routine using parallel code. You seem to have figured out<br>the geometry pretty much already.<br>Maybe I'm not getting it yet?<br>Jan<br><br>On Tue, Jan 22, 2013 at 10:52 PM, David Hoese <<a href="mailto:dhoese@gmail.com">dhoese@gmail.com</a><br><<a href="mailto:dhoese@gmail.com">mailto:dhoese@gmail.com</a>>> wrote:<br><br> Hey Jan,<br><br> Thanks for the response. My process will need to be automated so<br> excel won't help. I also will be working with potentially large<br> amounts of data (200MB - ~4GB). I would like the output to be in a<br> flat binary format (just the data), but if I can pull the data out<br> of another format that will do for now. The output data will be<br> used in other software that I have written to place the data in any<br> format I request (geotiff, AWIPS compatible netCDF files, etc). I<br> was hoping to use gdal_grid for its algorithms to do the<br> interpolation from input swath pixels to output grid pixels. I am<br> working with "raw" satellite observation data that is not<br> equidistant (so it can't be put through gdalwarp which expects an<br> equidistant grid as input).<br><br> The x and y arrays are created by software I have written. The<br> values in these arrays state the x and y offset from the grid origin<br> of where the image pixel is. For example, a single pixel might be<br> at column 1.14 and row 1.6 of the grid I am mapping to. I would like<br> gdal_grid (or some other code) to use an algorithm (nearest<br> neighbor, averaging, etc) to interpolate this image pixel value onto<br> the surrounding grid points. Does that make sense? It's difficult<br> for me to describe since I've been working with it so much lately.<br><br> The start-to-finish goal is essentially what gdalwarp does when<br> remapping one grid to another, but this doesn't make the assumption<br> that the data points are equidistant. The gridding utility I'm<br> currently using is old and only offers a single algorithm for<br> interpolation. That algorithm does not produce "pretty" images for<br> a specific instrument's data so I'm looking for alternatives without<br> having to hack up the old utility. Maybe looking at it this way<br> will make more sense:<br><br> (lat,lon,projection) -> my software -> (y,x)<br> (x,y,image_in) -> gdal_grid -> (gridded_image_out)<br><br> Maybe I'll just write the python wrapper for GDALGridCreate since<br> the rest of my software is python. As far as I know GDAL doesn't<br> have anything else that does gridding and doesn't have anything that<br> can do non-equidistant data points. Thanks for the help so far. Man<br> this email got long fast.<br><br> -Dave<br><br><br> On 1/22/13 2:58 PM, Jan Heckman wrote:<br><blockquote type="cite"> Hi Dave,<br> So you have effectively three arrays, one for pixel values, one<br> for x, one for y (probably offsets), which are coordinated and you<br> want to generate a raster or grid which you can display / use in a<br> GIS?<br> Sort of sparse array to be converted to a full array, effectively?<br> It sounds crazy, maybe, but consider converting these to separated<br> text (numbers), bring them into excel (columns), tell (arc)gis to<br> convert to a (point) shapefile and finally, if necessary, convert<br> that to a raster.<br> If this is the job, it can alternatively be done quite simply by<br> writing a small procedure (C++ or python (or something else, I'm<br> sure)), without using excel etc, as long as you know the output<br> format (and maybe have a geoprocessor to call upon). A simple<br> output format is .bil. This is roughly simlar to shapefiles, with<br> some supporting files to use it in a GIS. Possibly flat 32 bit<br> float (.flt) is understood by gdal as well.<br> Sorry that I can't help you with the gdal/ogr commands.<br> If you don't get a helpful gdal command, give me a yell with an<br> example.<br> Jan<br><br> On Sun, Jan 20, 2013 at 9:51 PM, David Hoese <<a href="mailto:dhoese@gmail.com">dhoese@gmail.com</a><br> <<a href="mailto:dhoese@gmail.com">mailto:dhoese@gmail.com</a>>> wrote:<br><br> I have 3 flat binary files that I would like to use to grid<br> data. The 3 binary files are the "scattered" image data pixels<br> and the other two specify the fractional column and row for<br> each input pixel in the output grid. So the image pixel in<br> the first file at offset 0 is mapped to the grid column at<br> offset 0 (from the columns file) and the grid row at offset 0<br> (from the rows file).<br><br> One way I think I can get the data gridded is to use the<br> "gdal_grid" utility, but I'm not really sure how to get the<br> flat binary files to be accepted by "gdal_grid". I thought I<br> could use VRT files, but I'm not exactly sure how I would do<br> that. I wasn't sure since the documentation here<br> <a href="http://www.gdal.org/ogr/drv_vrt.html">http://www.gdal.org/ogr/drv_vrt.html</a> says that I need to<br> specify a "SrcLayer", but binary files don't have layers. So<br> then would I need an intermediate VRT file to define layers<br> for the binaries? If I need an intermediate VRT maybe I<br> should just push the data into a geotiff (with no projection<br> info) and try using that? Could someone clear this up for me?<br><br> My other question is has there been any work done to make a<br> python wrapper for GDALGridCreate(). I found email threads<br> and a ticket (<a href="http://trac.osgeo.org/gdal/ticket/2023">http://trac.osgeo.org/gdal/ticket/2023</a>) talking<br> about creating one, but then conversation just stops and those<br> are from 5 years ago. I didn't notice anything that screamed<br> "this is impossible" when skimming through those threads and<br> the ticket. I'm also sure a lot has changed for GDAL and<br> numpy in the last 5 years. If it's a time thing I'm willing<br> to add it if someone can point me in the right direction to<br> start (how-to on adding to GDAL).<br><br> Thanks.<br><br> -Dave<br> _______________________________________________<br> gdal-dev mailing list<br> <a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a> <<a href="mailto:gdal-dev@lists.osgeo.org">mailto:gdal-dev@lists.osgeo.org</a>><br> <a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br><br><br></blockquote><br><br></blockquote>_______________________________________________<br>gdal-dev mailing list<br><a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>http://lists.osgeo.org/mailman/listinfo/gdal-dev<br></blockquote></div><br></div></body></html>