Clip polyline file with polygon file - output several polyline files

4044
9
Jump to solution
06-14-2012 12:44 AM
MiikaMäkelä1
New Contributor
I have a file of polylines and a file of 20 polygons. I want to produce 20 new polyline files, subsetting the original  polyline file with the polygons. I know I could do this one by one with the clip tool, but there must be a way to doing this in one go.
0 Kudos
1 Solution

Accepted Solutions
MarcinGasior
Occasional Contributor III
Ben,

Original model tool was created in ArcGIS 10 and it doesn't work in 9.3.

I attached a script tool with the same functionality which should work in 9.3 (and also in 10).
There're two more options compared to original tool - you can specify a unique identifier field of feature in feature class (usually OBJECTID or FID)
and a unique field which values will be added to output file name to make them unique.

View solution in original post

0 Kudos
9 Replies
MarcinGasior
Occasional Contributor III
I've created simple model which takes each polygon in polygon feature class (Input Iterator Feature Class) and use it to clip lines feature class (Input Feature Class to Clip).
It was tested for feature classes in file geodatabase, and if you use shapefiles modify 'Field' in Iterate Feature Selection iterator from OBJECTID to FID.

Make sure that at the end of Output Clipped Feature Class is %Value% which allows to differentiate outputs (add number based on OBJECTID of polygon layer).
Let me know if something goes wrong.

ps.
To use the model just unzip attached file (toolbox) and browse to it in files tree in Catalog window (or ArcCatalog).
0 Kudos
MiikaMäkelä1
New Contributor
Fantastic job! Thanks so much Marcin!

I changed the field to FID as I'm working with shapes and had no issues with that. I helpful tweak would be to know how I can change the value to something else besides the ID. I tried using my "NAME" field where I have a max. 50 char string. I couldn't get it to work however. Any solution to this? And a supertweak would be to have the possibility of 2 NAME fields concatenated as the file name. Then I wouldn't have to do any renaming afterwards. But I think I am pushing it here 🙂
0 Kudos
MarcinGasior
Occasional Contributor III
I'm glad I could help:)

What error do you get when using NAME field?
Maybe this field contains some characters which are not allowed in shapefile name?

If you want to concatenate names, it's easier to do it prior to using the model.
Just add new field and concatenate values from two fields in Field Calculator.
0 Kudos
MiikaMäkelä1
New Contributor
thanks, had a closer look at the error description and indeed some of the characters are not accepted. I think I've come across this before that the clip tool does not support scandinavian letters ä,ö,å for example. Possibly the hyphen - is also not accepted. I guess I'll change those before I run.

Thanks a lot for this. This tool is a great help!
0 Kudos
BenVan_Kesteren1
Occasional Contributor III

ps.
To use the model just unzip attached file (toolbox) and browse to it in files tree in Catalog window (or ArcCatalog).


Hi, i am trying to use this item but I am unsure as to how to 'run' it? I have placed this .tbx on the desktop, and now im unsure as to how to use in ArcGIS 9.3.1???

I have tried doing this:
Open ArcToolbox
Right click on the white area and click Add Toolbox...
Navigate to Desktop
Choose Clipping.tbx

but after doing this nothing appears in the list.

Any further instructions on how to use it?

Cheers
0 Kudos
MarcinGasior
Occasional Contributor III
Ben,

Original model tool was created in ArcGIS 10 and it doesn't work in 9.3.

I attached a script tool with the same functionality which should work in 9.3 (and also in 10).
There're two more options compared to original tool - you can specify a unique identifier field of feature in feature class (usually OBJECTID or FID)
and a unique field which values will be added to output file name to make them unique.
0 Kudos
BenVan_Kesteren1
Occasional Contributor III
Ben,

Original model tool was created in ArcGIS 10 and it doesn't work in 9.3.

I attached a script tool with the same functionality which should work in 9.3 (and also in 10).
There're two more options compared to original tool - you can specify a unique identifier field of feature in feature class (usually OBJECTID or FID)
and a unique field which values will be added to output file name to make them unique.


Hi Marcin,

It looks like its what i need to use, but unfortunately I am getting this error...

[ATTACH=CONFIG]15679[/ATTACH]

Any Hints?

Cheers
0 Kudos
BenVan_Kesteren1
Occasional Contributor III
Hi Marcin,

It looks like its what i need to use, but unfortunately I am getting this error...


Ok I figured it out, originally I was selecting 'suburb name' for the 'Field in Clip FC with features unique identifier' but I should have selected ObjectID instead (I should have read the instructions closer!!), now it run from start to finish.

Cheers for the help.
0 Kudos
MarcinGasior
Occasional Contributor III
It looks like its what i need to use, but unfortunately I am getting this error...


Indeed tool had an error. I allowed to chose id field which is not handled in the script.
Now it's possible to use string field as an unique IDentifier (I attached corrected tool in previous post).
0 Kudos