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 am aware of how to do it using ArcGIS for Desktop - see Exporting feature class into multiple feature classes based on field values using ArcGIS for Desktop?

How do I do it using QGIS, GDAL, SAGA, etc?

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
    
this isn't a complete duplicate, the Q linked to is ArcGIS only while this one is open to other platforms. An important difference for me today ;-) –  matt wilkie Mar 12 at 20:57
    
@mattwilkie To make this not be a duplicate then all that would appear to be needed is an edit that excludes ArcGIS for Desktop. If an alternative software is needed then I think that should be specifically stated so that the more focussed question can be researched/answered. –  PolyGeo Mar 12 at 21:49
    
@mattwilkie Unfortunately, editing this question to de-duplicate it has meant that a number of answers have been stranded. I'll ping their authors to suggest they delete them here and, if still relevant, post them to the Q&A that relates to ArcGIS for Desktop instead. –  PolyGeo Mar 12 at 22:56

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
    
Unfortunately, editing this question to de-duplicate it has meant that your answer has been stranded as no longer applying to the revised question. Would you be able to delete it here and, if still relevant, post it to the Q&A that relates to ArcGIS for Desktop instead. –  PolyGeo Mar 12 at 22:57

You can use this toolset for ArcMap 10 as well.

share|improve this answer
    
Unfortunately, editing this question to de-duplicate it has meant that your answer has been stranded as no longer applying to the revised question. Would you be able to delete it here and, if still relevant, post it to the Q&A that relates to ArcGIS for Desktop instead. –  PolyGeo Mar 12 at 22:58

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
    
Unfortunately, editing this question to de-duplicate it has meant that your answer has been stranded as no longer applying to the revised question. Would you be able to delete it here and, if still relevant, post it to the Q&A that relates to ArcGIS for Desktop instead. –  PolyGeo Mar 12 at 22:58

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
    
Unfortunately, editing this question to de-duplicate it has meant that your answer has been stranded as no longer applying to the revised question. Would you be able to delete it here and, if still relevant, post it to the Q&A that relates to ArcGIS for Desktop instead. –  PolyGeo Mar 12 at 22:58

In QGIS 2.8.1 there's a tool in the Vector menu that can split a dataset based on an attribute.

Look in Vector > Data Management Tools > Split Vector Layer...

split vector layer tool in QGIS 2.8.1

It's a basic tool that should work if you don't want to resort to plugins or tools in Processing; unless they offer additional functionality you need.

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
    
is this different from the plugin suggested by @oeon? –  matt wilkie Mar 12 at 21:00

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.