Skip to content

to many characters in .dbf file?

4 messages · Wayne Richter, Roger Bivand, Michael Denslow

#
Dear r-sig-geo,

I am in a bit of a bind. I am trying to write a shape file using
writeOGR() in rgdal.
I just realized that I may have too many characters in the cells as
they are getting cut off when the shape file is created. The cells are
unchanged in the SpatialPointsDataFrame. But when I inspect the .dbf
they are all truncated.
The cells that are cut off contain literature citations, so some are
very long (hundreds of characters). Is there a solution to this
problem?
This shape file is being imported into Geoserver so I am some what
limited as to the formats that I can use.

Any advice?

Thanks in advance,
Michael
#
A shapefile limits the width of a character field to 254 characters: http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Geoprocessing%20considerations%20for%20shapefile%20output. Perhaps you will need to export your long field into a different format.
From: 	Michael Denslow <michael.denslow at gmail.com>
To:	r-sig-geo <r-sig-geo at stat.math.ethz.ch>
Date: 	3/18/2010 3:13 PM
Subject: 	[R-sig-Geo] to many characters in .dbf file?

Dear r-sig-geo,

I am in a bit of a bind. I am trying to write a shape file using
writeOGR() in rgdal.
I just realized that I may have too many characters in the cells as
they are getting cut off when the shape file is created. The cells are
unchanged in the SpatialPointsDataFrame. But when I inspect the .dbf
they are all truncated.
The cells that are cut off contain literature citations, so some are
very long (hundreds of characters). Is there a solution to this
problem?
This shape file is being imported into Geoserver so I am some what
limited as to the formats that I can use.

Any advice?

Thanks in advance,
Michael
#
On Thu, 18 Mar 2010, Michael Denslow wrote:

            
The OGR driver truncates (I think to 254 characters), so use 
writeSpatialShape() in maptools instead, passing your large number through 
the max_nchar= argument. Please read the details in ?write.dbf - field 
widths above 254 are not portable.

Roger

  
    
#
Hi Roger!

<SNIP>
writeSpatialShape() worked for me. The file was read by Geoserver with
the extra text as well.

Thanks!
Michael