by rangernemo » Tue Apr 08, 2008 7:45 pm
I use OOo Calc to edit shapefile DBFs all the time... I have a shapefile with almost 9000 polygons. A couple times a month, I download three CSV files and join them to the shapefile, and export to a new shapefile. This gives me a snapshot of the shapefile at that date. The trouble is, the resulting DBF is 63 megabytes.
I open the DBF in OOo Calc and immediately delete all the formatting data... All the ",N,7,5", ",C,256", et al. The C,256 is the type that bloats my DBF. If you don't have similar data lower in the table, you can use Find and Replace to quick strip the formatting out. If you do have similar data in the table, you can select the top row and use the More Options / Current Selection Only option.
I found out through trial and error that you HAVE to remove the formatting data if you want to save back to a DBF. DBF doesn't allow commas in the column name, which it gets from the first row. So, if you open a DBF in Calc and try to immmediately save it, it won't.
When all the formatting data is gone, I format the data the way I want it. I might delete un-needed columns. I might create and fill new columns. I'll espcially format the cells' digit-lengths... I don't need to know acres out to the eighth decimal place. Once I save it, the 63MB file slims down to a svelte 1.7MB... 97% of the original file was padding for columns that where 256 characters wide.
I've not tried sorting the table data, or adding/removing rows. I don't know what that would do when it tried to join back to the spatial file. I also wouldn't recommend this for data files for programs that care about the DBF file format specs. None of the GIS programs I've tried (ArcGIS, QGIS, GRASS, and fGIS) care about the column formats of shapefiles, so changing them is OK. Of course, your mileage may vary, depending on any extensions you might be using.
The one problem I've run into is the new 2.4.0 gives an error when trying to save the DBF... It says it can't connect to the file. So, I uninstalled 2.4.0 and went back to 2.3.1.
TTFN,
Nemo