Loading data into PostGIS
Paulo Corti's notes on
Migrating shapefiles to PostGIS from "Thinking in GIS"
What I am really about on this page is using Python to transfer data from ESRI proprietary formats into PostGIS.
You need an ArcGIS license for this to access the ESRI formats. If your data are in shapefiles you don't need this...
I already know how to iterate over an ESRI feature class using a cursor. I might have trouble with the geometry... pretty sure I can do it though, especially for point files! Points are easy.
The simplest possible script to iterate over a feature class. The nice thing about using the ESRI code for this is that it does not matter what the data source is, it's just a 'feature class' that can be stored in a shapefile or a personal geodatabase or ArcSDE... etc...
import arcgisscripting gp = .create(9.3) workspace = 'D:/AGIProducts/IncidentView_Data/Data/WA/South_King/IncidentView.mdb' featureclass = 'Address_points' gp.workspace = workspace desc = gp.describe(featureclass) fields = gp.GetFields(fcname, '*') # Get a list of the attributes rows = gp.SearchCursor(featureclass) row = rows.Next() while (row) { geom = row.geometry() # We have geometry and attributes. # We should do something with them here, eh? row = rows.Next() }