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:

How can I convert a shape file (GIS) to text?
or, How can I extract the information in a shape file?

share|improve this question

migrated from superuser.com Mar 16 '11 at 16:01

This question came from our site for computer enthusiasts and power users.

marked as duplicate by PolyGeo Oct 14 '14 at 5:50

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.

This question is on-topic for Super User, but you might get a more detailed, accurate response on gis.stackexchange.com. You don't need to ask your question a second time; if you would like it migrated, flag for a moderator and they can move it for you. Either way, it might be helpful to update your question with more details about what GIS software you are using if you want more specific help. Good luck solving your problem! –  nhinkle Feb 25 '11 at 7:06
This is an exact duplicate of gis.stackexchange.com/questions/7339/shapefiles-to-text : the answers are already there. They also appear at gis.stackexchange.com/questions/5962/… and gis.stackexchange.com/questions/6806/… . –  whuber Apr 1 '11 at 19:15
@whuber, sorry for asking a duplicate question, however none of the other answers mention pyshp (as far as I can tell), which is what I ended up using, so in a way I am glad I asked. –  instanceofTom Apr 1 '11 at 19:51
2 votes left to close duplicate –  Mapperz Apr 1 '11 at 20:42
@instance I'm glad it worked out for you. A better way to get answers--and a way to get even better answers--is to acknowledge the previous threads and indicate why the existing answers might not suffice in your case. For instance, you might have specified you were looking for a Python solution. –  whuber Apr 2 '11 at 17:49

12 Answers 12

If you have ArcGIS 9.x you can use an out of the box script available from ArcToolbox located here, under the ArcGIS install location:

Toolboxes\Samples\Data Management\Features\Write Features To Text File

If you need further formatting of the text file then a Python script would be the way to go...

There is also an ArcGIS Idea called Generate and Ungenerate all vector feature classes from/to ASCII that could use your vote, and this comment has been made:

I just found out at http://forums.arcgis.com/threads/57600-Where-is-the-Generate-tool-in-ArcGIS-10?p=199524#post199524 that there were equivalent tools that already do this in the Sample Tools that have been deprecated (see http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/An_overview_of_the_Samples_toolbox/00pv00000003000000/). Their names are Create Features from Text File and Write Text File from Features.

share|improve this answer
Just and FYI, but while this does write out the feature vertices to points to a text file, it does not write the data out as OGC compliant Well Known Text (WKT), in case that is what you are looking for. –  RyanDalton Apr 22 '13 at 19:20
I fixed a couple of bugs and updated the 9.x developer sample of WriteFeaturesFromTextFile for 10.x, grab it from github.com/maphew/arcplus/blob/master/ArcToolbox/Scripts/… –  matt wilkie Feb 16 at 19:40

if you want to draw it on map you can convert shape file into WKT(well known text) format then you can store it in to DB or use it what ever you want to, with your shape file

share|improve this answer

There seems to be a few questions for this across the site. I just posted an answer at another location. See How to get all the lat/long coords that define a shapefile

share|improve this answer

load them to PostGIS.

query them something like:

Select st_x(the_geom) as Xcoord, st_y(the_geom) as Ycoord, attr1, attr2 from table1;

you can output the query directly to csv from pgadmin.

if you geometries is linestrings or polygons and you want all the vertexpoints, just do the same but split to points with st_dumppoints.


share|improve this answer

If you want to write a little bit of Python, you can use pyshp to read in all the shapefiles and output the X/Y for points or vertices for lines/polygons. Should require a minimal amount of code to get working.

Some sample code from their site:

import shapefile
sf = shapefile.Reader("shapefiles/blockgroups")
shapes = sf.shapes()

Shapes will contain an array of shapes

points = shapes[0].points

Points will contain all the points of the shape at index 0.

share|improve this answer
Ill give this a try, thanks. Is there anything in pyshp that would allow me to reproject the shapefiles so that the X/Ys are Latitude/Longitudes? –  instanceofTom Apr 1 '11 at 19:29
Nevermind my previous comment, the data is already stored in Lat/Lng –  instanceofTom Apr 1 '11 at 19:44
Nice! I hadn't heard of pyshp before - could have used it a few months back. –  Timothy Michael Apr 1 '11 at 20:13

You can use GDAL/OGR with the ogr2ogr command and export to a csv file, for example:

$ ogr2ogr -f CSV output.csv myshape.shp -lco GEOMETRY=AS_WKT

note that you may serialize the geometry in a variety of formats (WKT, XY, XYZ). Please refer to the official documentation, it is very well explained.

share|improve this answer

The utility ogrinfo should be able to do that. I have never tried it with a shapefile but it works fine for me with other GIS formats. Try something like that:

ogrinfo -al myshapefile.shp

On Windows you can easily get a compiled version of ogrinfo by installing FWtools.

share|improve this answer

With QGIS you can open Shapefiles and either export them as CSV or just copy-paste selected features from the map window into a text editor. You'll get WKT of the geometries and all attribute values.

share|improve this answer

Using OrbisGIS, you'll be able to open your shapefile and export its content in a CSV file. You'll retrieve a set of lines, each containing a record present in the shapefile. your geometries will be stored as well kown text (WKT) values

share|improve this answer

Just look at the folder with your shapefile in Windows Explorer rather than ArcCatalog and you will see the shapefile is actually several files. Your attribute information, which I am guessing is what you want in a text file is in the .dbf, just open that in Excel, Access, Open Office, etc and save as you wish.

share|improve this answer

A shape file map consists of the geometry (.shp), the spatial index (.shx), the attribute table (.dbf) and the projection metadata file (.prj). The geometry you could represent in OGC Simple Features SQL style but that won't bring you far. The attribute file you can open with Openoffice or Excel and look at it or export to another format.

share|improve this answer

shapefiles tend to come with several 'companion' files with different extensions. If you just want to extract the attributes, then copying the contents of the .dbf file is sufficient. However, if you want to restore the spatial information, then you will need to add the XY coords into the attribute table first (e.g. AddXY function in ArcMap), then export the attribute table.

share|improve this answer

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