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.

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
3  
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...

Syntax

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

image

Example Code:

import arcpy
arcpy.env.workspace = r"c:\data"
arcpy.ExportXYv_stats("AidsByCaCnty.shp","HEPRATE", 
"SPACE","aidsbycacnty.txt","ADD_FIELD_NAMES")

i hope it helps you...

share|improve this answer
1  
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
2  
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
3  
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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