Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This question already has an answer here:

I have a polyline shapefile with about 20 kinds of roads.

I would like to know how can I create automatically a vector file for each one.

I can use ArcGIS for Desktop, QGIS (or GDAL separately).

share|improve this question

marked as duplicate by PolyGeo Nov 17 '14 at 6:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

I posted an answer similar to your question before about this, see gis.stackexchange.com/questions/9998/… –  artwork21 May 18 '12 at 17:10

8 Answers 8

you can use Export Feature Attribute to ASCII (Spatial Statistics) with arcpy. get some information here...


ExportXYv_stats (Input_Feature_Class, Value_Field, Delimiter, Output_ASCII_File, Add_Field_Names_to_Output)


Example Code:

import arcpy
arcpy.env.workspace = r"c:\data"

i hope it helps you...

share|improve this answer
Thanks for the explanation, but ascii is a raster format. I want to get a shape file ( or any other vector format ) to work separately on them ) I found out that it's is possible with Qgis, it's actually in the basic menu ( -_- ) thanks anyway the Function is SEPARATE A VECTOR LAYER in the vector menu ( then you choose the ID and the directory ) –  Bobo May 18 '12 at 9:10
ASCII isn't a raster format. ASCII just means ASCII text format en.wikipedia.org/wiki/ASCII –  Nathan W May 18 '12 at 11:11
Bobo, since you found a solution you should write it as an answer and accept it. That way future readers with the same question can easily find the answer. –  user3461 May 18 '12 at 11:14
nevermind Aragorn I was confuse, thanks anyway –  Bobo May 18 '12 at 12:55

You can use this toolset for ArcMap 10 as well.

share|improve this answer

Quantum GIS has a plugin called ShapefileSplitter http://plugins.qgis.org/plugins/shapefile_splitter/version/0.1.2/ which does this.

share|improve this answer
I can't seem to find a download link for this anywhere. I looked within "Fetch python plugins" within qgis, and did not find it either. –  Mike Furlender May 24 '13 at 14:08
I think QGIS plugin reorganization lost us for a bit. It appears it's still available for QGIS 1.8 here: plugins.qgis.org/plugins/plugins.xml?qgis=1.8 - Direct link: plugins.qgis.org/plugins/shapefile_splitter/version/0.1.2 –  oeon Sep 10 '13 at 17:21

Create a search cursor, loop through each row. At each row, take the OID (or any other unique value) and put it in a where clause. Use that where clause in the Select_analysis(in_feature, out_feature, whereClause) gp tool.

If you want to go by type of road rather than a new fc /shapefile for each row, you'd use the select method on the first record, then append all other records of that road type to that fc / shapefile with an if/else structure.

share|improve this answer

You could consider saga gis (either directly or through sextante in qgis). It contains a module that will split a shape by attribute (shapes/tools/ split table/shape by attribute).

share|improve this answer

If use loop through each row by a Cursor as suggested by Roy, you will need to build whereclause for each row.

Then the buildWhereClause function suggested in this discussion How to include variable in where clause of arcpy.Select_analysis? will be really helpful.

share|improve this answer

On the processing toolbox of QGIS, if you go the example scripts of the Scripts section. You'll find the script called "Split vector layer by attribute". That'll do what you need.

share|improve this answer

With ArcGIS 10, the most simple way to do this is to use model builder and the copy data tool combined with "iterate row selection".

share|improve this answer

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