Skip to content

Instantly share code, notes, and snippets.

@DanielJWood
Created March 16, 2012 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielJWood/2053540 to your computer and use it in GitHub Desktop.
Save DanielJWood/2053540 to your computer and use it in GitHub Desktop.
Creating DMA polygons
  1. Get your DMA data into an sqlite file. This sqlite file must contain the county FIPS, the name of the DMA area, and the unique DMA code for that area.
  2. Create a county sqlite file from a county shapefile that contains county FIPS.
  3. Join DMA sqlite with a geographic enabled county polygon sqlite file to create a DMA sqlite file that has a geometry column.
  4. Load the DMA sqlite file into Qgis
  5. Use the dissolve tool to create the larger dma shapes from the smaller counties (Vector>Geoprocessing Tools>Dissolve)
  • The Input vector layer is the DMA sqlite file
  • The Dissolve Field is whatever unique ID each DMA has. So all the counties surrounding around Mobile Alabama and Pensacola Florida, for instance, would use the dissolve field that containedMobile, AL-Pensacola, FL.
  1. View your new DMA polygons, and save as an sqlite file, in whatever projection you need it in.

Troubleshooting: After step 5, when your new DMA polygons file is generated, if there are residual lines and slivers in the middle of your polygons, it is because there are small holes in between your original county files. Try using a different county shapefile in step two. Normally, a more coarse county shapefile will not contain these holes and slivers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment