feature class to csv

A few days ago Tony asked for a py script that will write out the OID + x + y for each feature in a polyline feature class / shapefile.  No problem we say, see code example at bottom.

This was quick and fun exercise and we were happy to write this code. But for more timely technical help i’d direct people to the esri forums, or gis stack exchange

Cheers and happy coding.


2 thoughts on “feature class to csv

  1. I’m just getting started with Python and ArcGIS, and always like to examine the internals of the programs I use, so this post was a nice help. To make the script work, though, I needed to change `geom[‘paths’]` to `geom[‘rings’]` in line 29. Is this because I’m using ArcMap 10.1, or for some other reason? (I also had to add an `import json` following the `import csv`, on line 20, but that of course makes easy sense.)

    • good catch on the import json, i just fixed it.

      and yes, good catch on ‘paths’ vs ‘rings’. If the feature’s geometry is polygon, you get ‘rings’, if lines, you get ‘paths’. Thanks for pointing that out.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s