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.
Create an ASCII gridded XYZ file using centroids in grid units.
Add the projection information via VRT/Proj4 with grid units (gdalbuildvrt).
Polygonize it to shapefile (gdal_polygonize.py).
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.