[postgis-users] Problem with pgsql2shp .dbfs

Frank Koormann frank.koormann at intevation.de
Thu Aug 25 03:23:19 PDT 2005


Hi,

* Matthew Perry <perrygeo at gmail.com> [050825 03:03]:
> On 8/24/05, Frank Koormann <frank.koormann at intevation.de> wrote:
> > * Matthew Perry <perrygeo at gmail.com> [050824 23:14]:
> > > ls -al *.dbf
> > > -rw-r--r--  1 perrygeo perrygeo 466623 2005-08-24 12:51 salinetrack_bad.dbf
> > > -rw-r--r--  1 perrygeo perrygeo   7325 2005-08-24 12:59 salinetrack.dbf
> > >
> > > What could be causing this difference? Could pgsql2shp be exporting a
> > > corrupted .dbf??
> > 
> > Can you post a link to both files or send it to me in private mail?
> > 
> 
> The shapefile and dbfs can be accessed at these URLs:
> 
> http://perrygeo.net/download/salinetrack.shp
> http://perrygeo.net/download/salinetrack.shx
> http://perrygeo.net/download/salinetrack.dbf
> http://perrygeo.net/download/salinetrack_bad.dbf

It's the SVG_GEOM column causing the problems. 

Some technical stuff:
- This field is far to large for a dbf-File: The specs reserve 1 Byte for 
  the field size description, as a consequence a field can be 265 characters 
  maximum. 
- pgsql2shp writes a 2 Byte size into the field header (here: 32842 characters)
  and also data of that size into the file.
- Some programs (e.g. OO.org) read only the first byte (here: 74 chars) and 
  cut off the rest of the data. This causes the significantly reduced
  size of the second ("good") dbf.
- Some other programs might stumble either over the corrupted header
  (correctly interpreted field description: A character field, with 74
  characters and 128 decimals; which does not make any sense) or the
  sheer size of the field.

In short: I think this is a bug in the underlying shapelib (dbfopen); as
a fast solution you might surpress the output of the SVG_GEOM colum with
a crafted query.

Best regards,

        Frank

-- 
Frank Koormann                             <frank.koormann at intevation.de>
 Professional Service around Free Software       (http://intevation.net/)
 FreeGIS Project                                 (http://freegis.org/)



More information about the postgis-users mailing list