Shape file of CMAQ 12km grid cell for USA

I am wondering how the grid cells at 12 km resolution are defined in CMAQ. I searched the CMAS center and Data Clearinghouse but I couldn’t find the shape file of 12 km grid cell used in CMAQ for Texas or USA.

I was wondering if you have any clue on where to find the shape file. I really appreciate your help.

I don’t know if there is an official repository for such shapefiles, but creating them is fun and easy with GDAL. I am sure there are other ways, but here is how I do it.

  1. Create an ASCII gridded XYZ file using centroids in grid units.
  2. Add the projection information via VRT/Proj4 with grid units (gdalbuildvrt).
  3. Polygonize it to shapefile (gdal_polygonize.py).
  4. Check the results.

More details on each step are below.

Step 1: Make a gridded XYZ file

You could do this in excel, but I like python.

python -c "
rows = [j for j in range(0, 299)]
cols = [i for i in range(0, 459)]
outfile = open('test.csv', 'w')
for row in rows[::-1]:
    for col in cols:
        print('{},{},{}'.format(col + 0.5, row + 0.5, col * 1000 + row), file=outfile)

outfile.close()
"

Step 2: Create a virtual dataset with projection information.

Here I have translated the IOAPI meta data into the PROJ4 definition including adjusting the units. This is important because we didn’t use sizes in the CSV above.

gdalbuildvrt -srcnodata 1 -a_srs "+proj=lcc +lat_1=33.0 +lat_2=45.0 +lat_0=40.0 +lon_0=-97.0 +y_0=1728000.0 +x_0=2556000.0 +a=6370000.0 +b=6370000.0 +to_meter=12000.0 +no_defs" test.vrt test.csv

Step 3: Convert the virtual raster into a Shapefile

gdal_polygonize.py test.vrt testout

Step 4: Spot check

I always compare the results to the lower left and upper right corners LOND and LATD in GRIDDOT2D.

…and watch out for which geodetic spheroid you use. MM5, WRF=ARW, and CMAQ usually use a perfect sphere with radius R=6370000 meters.

1 Like