2

I have lines of surface runoff and I need to select the ones that are lying mostly in internal buffer of polygon. I'm trying to make some script in python, but it's very important to make the script simpliest as it's possible, because there are 30 milions of this lines (and some about 650 000 polygons) and this is only a part of whole problem. Has somebody any suggestion?

I'm using ArcGIS 10.2.

Sample of my problem - red circles shows lines that are need to be selected There are the raw data

There are the raw data.

3
  • I have testing data that I'm using for testing scripts. And I think that the best way is make cycle for every polygon that will testing specific lines.
    – david_p
    Jul 28, 2014 at 12:16
  • How are you defining "mostly in the internal buffer"? Is it an absolute or percentage of length, do they need to start/stop/pass through the internal buffer?
    – Hornbydd
    Jul 28, 2014 at 13:15
  • I need to define which lines goes along the boundaries of the polygon and which only starts/ends (are orthogonal to boundary). The best way to select is relative (percentage) of length. For example if 30% of line overlap the buffer, I need to select it.
    – david_p
    Jul 28, 2014 at 13:23

2 Answers 2

2

Here is a general python script that will compare pre and post lengths and create the >30% select feature class (make sure your line layer has a unique ID column to base the join field method on):

import arcpy

arcpy.env.workspace = 'C:/Temp/test.gdb'

arcpy.Intersect_analysis(["line", "AOI_polygon"], "line_intersect", "ALL", "", "")
arcpy.JoinField_management("line_intersect", "Id", "line", "Id", "")
arcpy.AddField_management("line_intersect", "compare", "TEXT", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
arcpy.CalculateField_management("line_intersect", "compare", "compare( !Shape_Length!, !Shape_Length_1!)", "PYTHON", "def compare(f1,f2):\\n  value = f1/f2\\n  if value > 0.3:\\n    return 'Select'\\n  else: return 'No Select'")
arcpy.Select_analysis("line_intersect", "line_select", "compare = 'Select'")

Depending on your line table size (number of records) you may want to use Add Attribute Index method to help speed up the join.

1
  • Thank you very much! That works perfectly after adjustment to my script.
    – david_p
    Jul 29, 2014 at 9:29
1

Sounds like a lot of data to process. Make sure your data is in a File GeoDatabase which will ensure there is a spatial index.

Without knowing your data I do not know how long your lines are, so if they extend across many of your polygons then consider using the SPLIT tool to improve the efficiency of the spatial index.

So what are these polygons, ward boundaries? If so they should be enclosed in some high level administrative boundary like a district. It will be worth the effort of splitting your data at this level and cycling through at the district level so you not trying to process the whole of line dataset again your smaller polygon.

As a preprocessing step create your internal buffers

You could knock together a model or write a python script. Pseudo code as:

  1. Having prepared your data as described above:
  2. For each districts worth of polylines
  3. For each polygon in a district
  4. Intersect internal polygon with lines
  5. Summarize intersection table and identify any lines that exceed 30%
  6. Select polylines based upon (5) and do what ever it is you want to do.
1
  • Data are in GDB. The polygons are soil blocks (fields) and lines simulate ground runoff (whole problem is about water erosion). I don't know if I get it right. So i try to repeat like I understood. I have lines splitted by polygons, then I make internal buffers. After that, I make intersect lines and buffer and I get the pieces of lines that are in buffer. That I understand. But what I dont understand is how I can compare (identify) lenghts of original lines and the pieces? For me its important to do it in Python.
    – david_p
    Jul 28, 2014 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.