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 shapefile where there are 3 fields OBJECTID, NAME , LOCALITY. I want to create new shapefile that contains the geometry, projection etc. of the parent shapefile and according to the locality;

OBJECTID    NAME    LOCALITY
1    JOHN    UK
2    ANITA   USA
3    CAL     USA
4    DAVE    UK

This shapefile is read and two seperate shape files are created with the properties
of the parent shape files

OBJECTID    NAME    LOCALITY
1    JOHN    UK
2    DAVE    UK
OBJECTID    NAME    LOCALITY
1    ANITA   USA
2    CAL     USA

Please guide me how to do it. I am new to Python

share|improve this question

marked as duplicate by whuber Feb 15 '13 at 16:13

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.

2  
What software do you have available? This question is a possible duplicate http://gis.stackexchange.com/questions/22584/making-multiple-separate-selection‌​s-from-attributes/22585#22585 –  Alexandre Neto Feb 15 '13 at 12:39
    
Much more about this FAQ is available by searching our site: gis.stackexchange.com/search?q=split+shapefile+attribute+arcgis –  whuber Feb 15 '13 at 16:14
    
Another post that will help you is here: How can i split by attribute in ArcGIS 10? - a couple of the answers either have Python code or you can open up the script tools that are mentioned to examine the code and modify for your purposes. –  ccn Feb 15 '13 at 16:34

2 Answers 2

Here's a tutorial showing you how to do exactly what you're looking for. Before you start you'll need to install the gdal/ogr bindings for Python. Information for that can be found here:

http://pypi.python.org/pypi/GDAL/

Here's a question from here on how to install the bindings:

What's the easiest way to install GDAL and OGR for Python?

And here's the tutorial:

http://cosmicproject.org/OGR/cris_example_write.html

share|improve this answer

If you have ArcGIS at your disposal and do not want to write anything from scratch, there is already a tool available for that (if I got you right, you want to "split" the shapefile by a certain attribute).

You could also build a model:

enter image description here

Or check another GIS Stackexchange thread.

share|improve this answer

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