I have a shapefile that contains 200+ metropolitan cities. In each city, there are some tract polygons. The dbf table looks like:
tract city xvar
1 0040 20
2 0040 12
3 0040 45
... ... ...
5 5602 22
6 5602 44
... ... ...
My goal is to select a city and save it as a separate shapefile the name of which is the same as the city code:
0040.shp
tract city xvar
1 0040 20
2 0040 12
3 0040 45
... ... ...
5602.shp
tract city xvar
5 5602 22
6 5602 44
... ... ...
How should I automate this process for all the cities using arcpy?