Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

25 lines (16 sloc) 1.016 kb
date layout slug status title wpid
2007-05-14 11:58:28
Cleaning up CAD data with postgis

Don't you just love getting CAD data into GIS! I received a .dwg file with study areas delineated as polylines which we needed as polygons for analysis purposes. And it wasn't just one polyline surrounding each study area ... there were hundreds of little line segments which outlined a couple dozen areas (what was this CAD tech thinking?) . Luckily each segment had a name to associate it with the proper area.

I found that ArcMap's tools for doing this are painfully inadequate so I turned to postgis. After converting the dataset to a shapefile, the solution was simple:

shp2pgsql "study_areas.shp" areas | psql -d gisdata pgsql2shp -f "study_areas_poly.shp" gisdata \ "SELECT BuildArea(collect(the_geom)) AS the_geom, name FROM areas GROUP by name"

Viola... a new shapefile with my proper polygons instead of CAD chicken scratch.

Jump to Line
Something went wrong with that request. Please try again.