Drawing Parallel Lines inside Polygons

3927
11
Jump to solution
01-04-2019 02:20 PM
AdamThompson3
New Contributor III

Hey Everyone, 

I am basically trying to recreate the tool that was done here arcpy - Drawing parallel lines inside polygons (Well Paths) using ArcGIS Desktop? - Geographic Infor...  

But It seems to not be working for me, I am running into errors within the copy features management portion of the script. It seems the dictionary I am trying to copy from is remaining empty even though the script appends to it. 

I am a little unsure of what is completely going on in this script but was wondering if anyone else was able to get it to work and could shed some light and maybe how they did if possible?

Cheers

0 Kudos
1 Solution

Accepted Solutions
RandyBurton
MVP Alum

I tested the script that you linked to and was able to get it to work using desktop 10.5 without making any changes to the code.  I set it up as a script tool with parameter 0 as a feature layer for input, parameter 1 as a feature class for output, and parameters 2 and 3 as linear units for input.

The code at the bottom of the script references the "CURRENT" map document, so the tool is designed to be run inside ArcMap.  The polygon layer should be a layer in the open map.  The output feature can be in memory as the example on stackexchange shows, or a new one to be created in an existing geodatabase.

As you are indicating errors with the copy features management, I would check that the parameter is set as a feature class for output and that you are using a valid name and location for the feature class.  If this feature is being created and is empty, then I would check the line spacing and buffer distance used to make sure the lines will fit inside the polygons.  If the buffer is 10 meters, then the polygon should be over 20 meters in width/height to accommodate the lines.

If you are still having problems with the code, see Debugging script tools for some ideas and post the error messages.

View solution in original post

11 Replies
RandyBurton
MVP Alum

I tested the script that you linked to and was able to get it to work using desktop 10.5 without making any changes to the code.  I set it up as a script tool with parameter 0 as a feature layer for input, parameter 1 as a feature class for output, and parameters 2 and 3 as linear units for input.

The code at the bottom of the script references the "CURRENT" map document, so the tool is designed to be run inside ArcMap.  The polygon layer should be a layer in the open map.  The output feature can be in memory as the example on stackexchange shows, or a new one to be created in an existing geodatabase.

As you are indicating errors with the copy features management, I would check that the parameter is set as a feature class for output and that you are using a valid name and location for the feature class.  If this feature is being created and is empty, then I would check the line spacing and buffer distance used to make sure the lines will fit inside the polygons.  If the buffer is 10 meters, then the polygon should be over 20 meters in width/height to accommodate the lines.

If you are still having problems with the code, see Debugging script tools for some ideas and post the error messages.

AdamThompson3
New Contributor III

Hey Randy,

Thanks for the reply and help of testing the tool as well! I ended up having it work for me as well and the problem cause I found was the data I had recieved was in Geographic NAD 83, so even if I was selecting feet as my required line spacing. It was still referencing decimal degrees causing it to not work. Thanks again for everything.

0 Kudos
AdamThompson3
New Contributor III

Hey Randy, I know this is a bit later down the road but I am possibly looking to build upon this tool. Would you have any suggestions or ideas on how I would go about adding a parameter that allows the user to select the number of sticks (wells) to draw per section. For example, 6 wells per section at 800 feet spacing. I have been looking around but having trouble finding references for something like this. Greatly appreciate any help you could provide. 

0 Kudos
RandyBurton
MVP Alum

I'll take a look. With 6 wells per section at 800 feet spacing, would the buffer be adjusted (if using the current tool under discussion)?  Would you prefer points over lines?

0 Kudos
AdamThompson3
New Contributor III

The buffer honestly within this tool is not too important for my uses. I generally just do 5 feet, you could do anything you'd like for testing purposes in that parameter. But if we could keep it as drawing lines that would be the most ideal. Thank you again. 

0 Kudos
NatashaDakouri-Hild
New Contributor III

Hi

I am trying to run this tool but haven't experimented with this before. Could you please explain how you get there to see the UI shown in the original page referenced above? I have created a new toolbox and added the script from a text file. Then what? I see the window below and am unsure how to set the parameters I need. I have a feature layer with polygons loaded I want filled with wells at 5 m intervals. Edge buffer isn't needed. Thanks.

0 Kudos
AdamThompson3
New Contributor III

Hi Natasha, 

You need to set the parameters as they are outlined within the script. For Arcpy scripts that are created for Tool purposes, your parameters are defined by X = arcpy.GetParameterAsText(0) --> 0 indicating that this is the first parameter that your tool will have. 

So in that GUI you are working with, all you have to do is specify a name you want displayed in the tool for that parameter and then the correct data type. In the case above you will have 4 parameters that you will have to specify and create in the GUI Box.  Some more detailed outlines about tool parameters can be found here as well; http://desktop.arcgis.com/en/arcmap/10.3/analyze/creating-tools/setting-script-tool-parameters.htm 

LukeWebb
Occasional Contributor III

Did you get your adjusted sticks / section code sorted out? 

0 Kudos
NatashaDakouri-Hild
New Contributor III

Many thanks for your quick reply. So I specified 0 as shapefile (since I want the lines inside the polygons of that shapefile; also tried feature layer), 1 also as a feature class, 3 and 4 as linear units. 10 m interval, 0 buffer. I then created a new layer to receive the polylines (since the tool doesn't seem to give the option to create a new layer but prompts choosing an existing one). I also made sure the output matches my coordinate system. The script runs and runs forever and I end up stopping it. Thoughts?

0 Kudos