I have a line layer (roads) and a polygon layer which represents districts/counties. I want to clip the roads according to every one different county. That means that I must repeat the procedure sixty times as the total count of districts is 60. (I must select one different district (feature of polygon) every time and then Vector -> Geoprocessing -> Clip). Is there any possible way this procedure to become automatic? I work in QGIS (and ArcGIS).
You can create a model from the Processing Toolbox which allows you to automate a number of tasks.
You can create one by going to the menubar:
Processing > Graphical Modeler...
From the Inputs tab (shown in the red box), you will need two
Vector layer parameters (shown in the blue box) for both your line and polygon layers.
Then from the Algorithms tab (shown in the red box), type in "clip" to search for your Clip tool. Then select the relevant options:
Don't forget to type a name for the model and group shown in the green box. Save it and load the Processing Toolbox interface which can be enabled from the menubar:
Processing > Toolbox.
Then find your model from the toolbox which should be under
Models (or you can type in the name of your model in the search box). Now when you run it, click the green round-arrow button next to the polygon input layer to iterate through each polygon feature:
When you run it, the road layer will clip onto each polygon feature and the results will be loaded.
Note: I have tested this on a simple example and it worked fine. Tested with QGIS 2.16.0-Nødebo with Processing plugin v2.12.2, Win7 64-bit..
Using ArcGis, no programming needed:
1 - Apply intersect, so all your network will take a unique cod for each district.
2 - Open model builder, under menu insert chose "Iterators\Row Selections"
3 - Right click on row selection and create two Model Variable (1-Input Table 2-Group By Field)
4 - Double click on Input table and chose created shapefile from Intersect command.
5 - Double click on group by field and chose the unique key of districts.
6 - open toolbox under Data management\Feature chose copy feature drag and drop it into model space.
7 - Link your selected feature of "Row Selections" with "Copy Feature" as input feature.
8 - On output chose your geodatabase where u want to save your shapefile dont forget to rename it "....your path.gdb\yourname_%VALUE%". %VALUE% is very import to rename all your new shape file with your unique code.
Your model would look like.
To add on to Joseph's answer, in newer versions of QGIS (I'm on 3.10) to use the "Iterate" button you need to use "Vector Features" in the input instead of "Vector Layer"
Related Question: Modeling iterative processes in QGIS 3