Creating a Quarter Quarter Section Grid with Python

Share Button

*Updated – 4/6/2014*
Added a new tool that creates a custom grid of any size from an existing polygon feature class.
Removed the requirement of having an existing point and polyline feature class. They are now made in-memory.

Download the Custom Grid Toolbox - works with ArcGIS 10.1+
(contains 5 tools, 4 to make quarter and quarter quarter section grids with labels and 1 to make a custom grid)

View the Source Code:
Create Custom Grid
Create Q Sections script
Create QQ Sections script
Create Q Labels script
Create QQ Labels script

This YouTube video is out-of-date, but still gives a good idea on how the tool works.

I was tasked with creating a quarter quarter section grid for a few Nebraska counties because the BLM didn’t have one available. They did have a section grid though. So, basically, I had to split each section grid into 16 parts and also add an attribute that will be used as a label for each quarter quarter section grid. Also, I know this isn’t a substitute for an actual survey grade quarter quarter section grid, but sometimes you’re required to work with what you have. And in this case, the quarter quarter section grid will be used by an electric utility to name their equipment and customers, so they actually prefer the sections to be split equally. It all depends on what you need.

Section To QQ

I needed to create quarter quarter sections for about 3000 sections in Nebraska, so doing it manually was out of the question. Using Python was the only reasonable solution.

To do this, I created a search cursor on the Nebraska section grid which looped through each individual polygon and used its Shape geometry field to record the coordinates of each vertex in the polygon. At the same time, it also recorded the coordinates of each corner for the extent of the polygon.

After finding the coordinates of each vertex, I then found the distance of each vertex from each corner of the extent of the polygon. This allowed me to find which vertex corresponded to which corner. A little math was then performed to determine the coordinates of each quarter quarter section along the outside of the section grid, as show below.

Quarter Quarter Sides

Next, I created a Polyline geometry object and had it connect each point to the one directly across from it. An insert cursor was then used to insert each Polyline object into a new polyline feature class.

I then manually used the Split Polygons tool inside ArcMap in the Advanced Editing toolbar to split each section based on the polylines previously created. It was necessary to use a Cluster Tolerance of about 30 feet, but this will vary based on the grid used. This is because if the polygon had more than just one vertex at each corner, there could possibly be a gap between the end of the created polylines and the polygon border. After applying the Cluster Tolerance, I was left with exactly what I needed, but I still wasn’t done.

Part II

I also needed to attribute each quarter quarter section a specific number to be used as a label. The good news is that the numbers are the same for each section.

Quarter Quarter Numbers

While thinking of how to do this, I realized I already had what I needed to create it. I just needed to do a little more math in order to find the centroid of each quarter quarter section. This script was similar to the first one. I used a search cursor to loop through each polygon and read the Shape geometry field to find the coordinates of each corner. From there I was able to find the centroid coordinates of each quarter quarter section, so I knew where each centroid was located within the polygon. This allowed me to record which label was linked to which quarter quarter section as shown above.

As I found the centroid for each quarter quarter section, I created a Point geometry object for each one. I then used an insert cursor to insert each Point object along with its appropriate label attribute into a new point feature class.

Finally, I added the newly created point feature class and the previously created quarter quarter section grid to ArcMap and performed a spatial join. This outputted a new quarter quarter section grid with the appropriate label joined to it.

______________________________________________________________

I decided to go ahead and get rid of the hardcoding and make these scripts available through an ArcGIS Toolbox, so other people can utilize them. I also made two similar scripts for creating quarter section grids and labels. If you didn’t notice, the Toolbox is available for download at the top of this page.

I hope someone finds these scripts useful. If there are any questions or problems, please leave a comment and I’ll try to help.

17 thoughts on “Creating a Quarter Quarter Section Grid with Python

  1. Dan Norris
    February 19, 2014 at 11:42 am

    This is fantastic! After searching for a long time for a tool to break up sections and finding nothing but disappointment, I found this. This tool does exactly what I was hoping to do and will make it so much easier to find and plot approximate property boundaries. Kudos to you for not only figuring it out, but also posting the code and even the toolbox. The graphical interface makes it remarkably easy. I processed the entire state of Missouri (several million quarter-quarter sections) and it only took a few hours to run.

    1. Ian
      March 25, 2014 at 3:22 pm

      Dan, thank you for your kind words! I’m glad you were able to put it to good use.

  2. Maggie
    March 25, 2014 at 2:23 pm

    Hi Ian,

    First off, wow. It looks like you put a lot of time into these tools; thanks a lot! I am currently being faced with a similar task. I need to create 3 lat/long grids with varying resolution: 1/4 degree, 1/20 degree, and 1/100 degree. I have already created just a 1 degree shapefile using the CreateFishnet tool, which I had to do 16 separate times then merge due to the size limit the tool has. I can only imagine how much of a pain it would be to do the same process for the higher res grids. It looks like the quarter tool would be applicable to the 1/4 degree res, but I’m wondering, could we modify the tool to divide each cell into 1/20ths, then 1/100ths? Or possibly make that another variable? Looking at the two create sections python scripts, it doesn’t look like the latter would be a viable option as it stands, but honestly it’s a little bit over my head so I’m not sure I’d know how to modify the code myself. I’m not even sure this is the best way to go about this at all because the number of cells is so large, but maybe you could help me out.

    Thanks a bunch!

    PS: Clicking the link to download the toolbox doesn’t seem to be working, it just opens in the browser…am I missing something?

    1. Ian
      March 26, 2014 at 11:47 am

      Hi Maggie,

      The toolbox downloads fine for me. You might try right clicking on the link and doing a Save As or Save Link As.

      As for your question, creating higher resolution grids from the code I posted would definitely be possible. It would just require some more division. Creating a function to do this would be the way to go. I’m not sure if you are creating your lat/long grids based on an existing grid or a feature though. If I find some time, I’ll shoot you an email to get some more information.

      1. Maggie
        March 26, 2014 at 5:49 pm

        Yes duh, that worked, I can’t believe I didn’t try that.

        That would be so helpful! I would need some guidance, but I think it would be useful to do for people who need to split grids into various higher resolutions (I can’t be the only one, right?).

        Anyways, I have a shapefile of lat/long 1 degree, in which each cell is represented as a polygon. (180 * 360 total polygons). I need to split all of the polygons in this shapefile such that each cell is divided into 16ths (so I guess using your quarter quarter script). I’m not sure if this answers your question, but if you get the chance I would love to hear from you.

        Thanks!

      2. Maggie
        March 27, 2014 at 11:42 am

        Ian,

        Just wanted to let you know that I’m going to go about my task in a different way, so no need to spend time helping me modify the algorithm. I’m sure this tool will still be very useful to me in the future however, and I’m glad to have discovered your webpage! Thanks again for sharing your ideas.

        1. Ian
          March 29, 2014 at 1:58 pm

          I’m glad you got something figured out! I just want to let you know that I added a new tool to the toolbox called Create Custom Grid and I’ve renamed the toolbox from Section Grid Tools to Custom Grid Tools. The new tool allows you to choose a vertical and horizontal division. So you could create a 1/20 by entering either 5×4 or 4×5 in the tool parameters. I hope you find the tool useful in the future and thank you for your comments and having input on the additional functionality. The new toolbox can be downloaded at the top of this page.

  3. Grant
    April 10, 2014 at 3:52 pm

    I’ve been looking for a tool like this, thanks! Any chance you could make the source code available? Looks like the script is embedded in the toolbox.

    1. Ian
      April 10, 2014 at 11:44 pm

      Grant, sorry about that. I updated the scripts recently and forgot to post them again. I’ve added them to the top the page. Thanks for reminding me and I hope you find them useful.

  4. Tom
    April 29, 2014 at 4:28 pm

    Ian!

    Absolutely perfect for what I needed. You are the man!!!! I needed something to split Quarter Quads for NAIP imagery, and this was PERFECT!

    Great job!

    Tom

    1. Ian
      May 1, 2014 at 10:18 am

      Thanks, Tom! I’m always interested in hearing the different ways people are using the tools, so I appreciate you letting me know!

  5. bill@TLH
    May 14, 2014 at 9:32 am

    Impressive and very helpful; well done.
    Keep ‘em, coming!

  6. Mark
    June 23, 2014 at 10:57 am

    Can it be tweaked to wok with quarter sections (split polygons into 4 equal polygons)?

  7. Mark
    June 23, 2014 at 11:31 am

    oops – ignore may comment – didn’t see th QQ option. This works fantastic.
    Thank You

    1. Ian
      July 14, 2014 at 8:56 pm

      Thanks, Mark, glad it worked for you!

  8. jake
    July 14, 2014 at 9:49 am

    I am having to split STR into QQ as part of an assignment for class, and ran across this website. I guess i’m missing a step or doing something wrong though cause once I get to the point of editing the lines after creating them, using the create QQ sections I get stuck. my advanced edit toolbar will not allow me to click on the split poly tool.

    1. jake
      July 14, 2014 at 9:56 am

      Nevermind my last post, I figured out that it is a licensing issue.

Leave a Reply

Your email address will not be published. Required fields are marked *