Find majority county coverage in model grid cells

From LADCO Wiki
Revision as of 21:15, 7 December 2018 by Zac (talk | contribs) (3. Add X Y columns to the shapefile)
Jump to: navigation, search

Question

How do I figure out which grid cells (x, y) contain any part of the Chicago ozone nonattainment area?

Approach

Use a GIS to find the counties that intersect the model grid cells.

Details

1. Create a shapefile of the 12US2 modeling grid (396x246)

Use the Spatial Allocator raster tools to create the shapefile. See generateGridShapefile.csh script as an example.

  setenv GRID_PROJ "+proj=lcc +a=6370000.0 +b=6370000.0 +lat_1=33 +lat_2=45 +lat_0=40 +lon_0=-97"
  setenv GRID_ROWS 246
  setenv GRID_COLUMNS 396
  setenv GRID_XMIN  -2412000.0
  setenv GRID_YMIN  -1620000.0
  setenv GRID_XCELLSIZE 12000
  setenv GRID_YCELLSIZE 12000
  setenv GRID_SHAPEFILE_NAME ../output/conus_12US2.shp
  ../bin/64bits/create_gridPolygon.exe 

2. Add X Y columns to the shapefile

  1. Load the CONUS12 shapefile into QGIS.
  2. Open the attribute table, put the file in edit mode, and add two short integer columns: X and Y
  3. Apply the following field calculator formulas, in this order (calculate Y first), to calculate X and Y; note that 396 = NCOLS
  Y = (floor(("GRIDID"-1)/396)+1)
  X = "GRIDID"-("Y"-1)*396

3. Intersect the county and grid shapefiles using GIS

Use the QGIS Intersect function to find the dominant county in each grid cell.

1. Load a county shapefile into QGIS

Error creating thumbnail: File missing

2. Load the grid shapefile and put the county shapefile and model grid shapefile on the same coordinate system

Error creating thumbnail: File missing

3. Use Vector->Geoprocessing Tools->Intersection to intersect the two features. The grid shapefile is the Input Layer; the county shapefile is the Intersect Layer

Error creating thumbnail: File missing

Results

Download a CSV file with county and grid cell intersection