[Gdal-dev] PostGIS varchar fields

William Kyngesburye woklist at kyngchaos.com
Wed Jan 11 16:18:09 EST 2006


I did not use the precision option.  But they are varchars in the  
PostGIS DB - I verified that by browsing the DB with phppgadmin.  I  
thinks that's because I originally created it by importing just the  
geometry with no attributes (I was experimenting),then cleared it,  
then added the attribute fields with SQL commands.  Then I appended  
to the DB with OGR with mif/mid's with full attributes.  So, the  
PostGIS DB does have varchars.  I'd have to scan the DB (large), or  
test on a separate one, to see if any name strings were cut off at 80  
chars (if the fields are already varchar, does -append still cut off  
at 80 chars if the default precision=true is used?).

So, back to the question, is OGR supposed to recognize varchar field  
lengths in postgis?


(Thanks for the heads-ups on the precision option.  I should read the  
docs more carefully ^_^)


On Jan 10, 2006, at 10:20 PM, Frank Warmerdam wrote:

> On 1/10/06, William Kyngesburye <woklist at kyngchaos.com> wrote:
>> I'm not sure if it's supposed to work this way or not:  I extracted
>> an area out of a big PostGIS database, to shapefile, and all the
>> varchar fields from PostGIS became character fields of length 80.  So
>> all those 2-8 varchar fields in the attributes balloon the dbf, and
>> the few 200 char name fields get chopped off.
>>
>> ogrinfo -al -so on the PostGIS DB returns "String (0.0)" for the
>> field type for all varchar fields, but the correct length for all
>> fixed char fields (a few 1 and 2-char fields).  The original mif/mid
>> source I used to create the PostGIS DB with ogr2ogr returns the
>> correct length for all char fields.  A direct ogr2ogr from the mif/
>> mid to shapefile also creates the correct field lengths in the
>> shapefile, although the integer fields get changed to reals.
>
> William,
>
> Is there any change you used the -lco PRECISION=FALSE
> option when copying the data into postgres?  If so, VARCHAR
> gets used for fixed length fields otherwise the fixed length
> string fields should be created as CHAR(length).
>
> The PRECISION layer creation should default to TRUE
> according to the code and docs.
>

-----
William Kyngesburye <kyngchaos at kyngchaos.com>
http://www.kyngchaos.com/

"Mon Dieu! but they are all alike.  Cheating, murdering, lying,  
fighting, and all for things that the beasts of the jungle would not  
deign to possess - money to purchase the effeminate pleasures of  
weaklings.  And yet withal bound down by silly customs that make them  
slaves to their unhappy lot while firm in the belief that they be the  
lords of creation enjoying the only real pleasures of existence....

- the wisdom of Tarzan



More information about the Gdal-dev mailing list