If you really require square cells, then the resample function in 'raster' might be useful:
library(raster) r = raster('ncdffile') # or r=raster(matrix); extent(r) = c( , , , ) s = raster(r) res(s) = min(res(s)) s = resample(r, s, method='bilinear') s = writeRaster(s, filename='abc.asc', format='ascii') Or first do an interpolation first. Many options for that. E.g. see ?raster::interpolate Robert On Mon, Feb 1, 2010 at 2:49 PM, Michael Sumner <mdsum...@gmail.com> wrote: > Does it have to be that ascii format? There are much better options > for regular grids, such as GeoTIFF - but it depends on your target of > course. Note that some software supports different dx/dy sizes, namely > GDAL and Golden Surfer for this format: > > http://www.gdal.org/frmt_various.html#AAIGrid > > If it does need to be ESRI ASCII, you could write it out with square > cells and then reset the cell sizes in the target (if possible). > > Is the requirement for square cells with the ESRI version of this > format, or with the software you want to use next? > > As a last resort you could resample the grid using R's indexing/seq > functions, or with spsample in package sp, or warp it with an external > tool like gdalwarp. > > Cheers, Mike. > > On Tue, Feb 2, 2010 at 9:32 AM, Narayani Barve <narayani...@gmail.com> wrote: >> Hi All, >> >> I want to convert netCDF files to ESRI ASCII grid. I used the package ncdf >> to read the file and get the required variable in the matrix format. Now I >> want to write this matrix into ESRI ASCII grid. Looking at the extends of >> the data, and the row and column dimensions, I know that the CELLSIZE is not >> square. >> >> Is there any way, I can convert this data into square ASCII Grid (ESRI) >> format. >> >> Thanks, >> Narayani >> >> [[alternative HTML version deleted]] >> >> _______________________________________________ >> R-sig-Geo mailing list >> R-sig-Geo@stat.math.ethz.ch >> https://stat.ethz.ch/mailman/listinfo/r-sig-geo >> > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo