[postgis-users] Maintain length and precision for numneric fields in pgsql2shp and shp2pgsql

Peter Hopfgartner peter.hopfgartner at r3-gis.com
Thu Jan 24 00:26:49 PST 2008


Paul Ramsey wrote:
>
> On Jan 23, 2008, at 3:39 AM, Peter Hopfgartner wrote:
>
>> we were looking at the tables generated by shp2pgsql. As it seems, 
>> numeric(m, 0) is mapped, if possible to integers, and numeric(m,n) is 
>> mapped to numeric.
>
> Do you mean, mapped to float?
>
Usually yes, but in our case the original column was a a numeric(19, 
11), so the if statement in line 559 choses numeric instead of float8, 
which makes perfectly sense.
>> We would like to optionally maintain the numeric length and precision 
>> for our data imports. Looking at shp2pgsql.c,  this should be rather 
>> simple. Basically, we could add an option, let's say '-K' for keep 
>> precision, and modify the code around line 550.
>
> This is possible. You need to be aware of the *massive* performance 
> penalty that comes with using numeric instead of integer/float.  As 
> long as you are clear on that, it's certainly acceptable.
>
Yes, this is true. In almost all cases the current behavior of shp2pgsql 
and pgsql2shp is preferable. But in this specific project we are working 
on, the customer, a public administration, insists on data formats.
> Since we have -i for "force to integer" how about -n for "use numeric 
> for all numbers"?
>
Sounds good.
>> A similar change could be done for pgsql2shp, modifying the SQL 
>> query, which gets the type information from PostgreSQL and changing 
>> the code generating the dbf header.
>>
>> If such a change is welcomed, we can try to have it done soon.
>>
>> Regards,
>>
>> Peter Hopfgartner and Sergio Segala
>>
>> R3 GIS
>> http://www.r3-gis.com
>>
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
Regards,

Peter & Sergio

R3 GIS
http://www.r3-gis.com



More information about the postgis-users mailing list