2

I'm not much of a GIS user, but I've got a big ascii file that I'm trying to convert into a

lat  long  data
x1   y1     d1
x1   y2     d2
x1   y3     d3
x2   y1     d4
...
etc

format, so that I can work with it in R. I've got global national identifier data (i.e.: which country occupies what grid) at 2.5 arc-minute resolution, but I want to coarsen it into half-degree, because that is the resolution of the rest of my data. I could do so in R if the file weren't so large -- its 3.9GB and I can't read it into memory. A NetCDF file would obviously be ideal for me, but I can't find a netcdf version of the data I want.

The data is categorical -- country identifiers. What I want to do is simple to take each 12x12 block of gridcells, evaluate that N=144 matrix, and return the country that appears the most times. (I'd also like it to ignore NA values, unless all values are NA). This would be easy enough in R if I could only open the darn text file.

So I opened QGIS, but there doesn't seem to be any obvious way to "coarsen" a raster.

Is there one?

Then it occured to me that I could convert the data to vector, and then convert it back to raster, specifying the resolution that I want.

BUT is there a way to do so that would allow me to specify that each gridcell should be .5x.5 degrees, going from -180 to 180 and -90 to 90?

This seems like a pretty gross hack.

Is there a better way?


I've decided that it makes more sense for me to just make the file into a netcdf using a remote machine with the memory for it.

underdark
  • 84,148
  • 21
  • 231
  • 413
generic_user
  • 403
  • 2
  • 5
  • 11

2 Answers2

4

You can use Translate (under Raster-->Conversion) using the Outsize option. enter image description here

In the example picture, the setting 25% will produce pixels that are 4x larger. So, to convert your 2.5 minute raster to 30' (0.5°), you would use 8%. I'm not sure what the limitations are, if any, for lat/long pixels, but it should work.

Jay Guarneri
  • 2,105
  • 1
  • 16
  • 33
0

Before you do anything I advice you to read this Question: Exporting DEM-derived rasters to CSV from QGIS?

The workflow I would take would be something like this:

  1. Create a vrt of the raster with the desired resolution: gdalbuildvrt -of VRT -tr output.vrt [gdalfile].
  2. Use gdal2xyz.py (usually it is located to C:/OSGeo4W/bin) to create a xyz file from raster.
nickves
  • 11,519
  • 3
  • 42
  • 75