Re: [postgis-users] trouble shp2pgsql with numeric
Yes it's imported at numeric column but 0 becam 0.00 and i just need to remove all last 0 after the dot i hope to keep numeric column for these data but with correct decimal ... T. On Tue, Nov 22, 2011 at 2:03 PM, Ben Madin wrote: > Tonton, > > This is a limitation of shapefiles .dbf format. (yet another reason to > move away from shapefiles). PostGIS can't assume that your value is a > categorical value (ie a label) when the column only contains numbers and is > tagged as numeric. To allow for the widest range of cases, it is imported > probably as float or numeric, so if all your column values are integer you > could easily (post-import) issue : > > ALTER TABLE ltb ALTER COLUMN annoying_column TYPE int USING > cast(annoying_column as int); > > hth. > > cheers > > Ben > > On 22/11/2011, at 5:20 PM, Tonton wrote: > > > hello > > > > i use shp2pgsql in a web mapping application to add shp file into > postgis. > > > > after uploading on the server side (in django framwork) i use this cmd > > > > cmd = "/usr/bin/shp2pgsql -c -s 4326 -W latin1 -g geometry > "+/pathToSHPname+" " +str(tablename)+">"+/pathToMyFile.sql" > > > > it is working near great now but for some numeric information in the > sql request numbers are transform to sort of float : 2 became 2.00 > > > > this is an exemple for my generate sql ! > > > > INSERT INTO "ltb" > ("coef_conge","depart_lig","fc","freq_moy","freq__0","freq_moy_m","id_aire","id_station","libbelle","libelle","libell_","ligne","mode","num_type","nom_ligne","nom_statio","num_ligne","num_ligne_","sens","tps_parc","terminus_l","tps_parcou","type_acces","v_com_sytr","vitesse","id_lgn","nom_lgn","nom_stt","order","tpsatt_lgn","vit_off_km","vitcom_lgn","vitesse_km","length",geometry) > VALUES > ('0.00',NULL,'104','0.00','0','0.00','0','0',NULL,NULL,NULL,NULL,NULL,'0',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0',NULL,'0.00','0','18226',NULL,NULL,'31','0','0.00','0.00','0.00','222.2906997126','010520E6100100010220E6100900E721D9B6305F1340E073BE5D7BF34640319802F44B5F13402462B73D81F34640B40C3CD08B5F1340C2FD98C68BF34640C8A0171BA45F134083D387CD8EF34640DBF078F7D05F13408FF4362192F346404248D110246013400742949695F34640BEA067CCB56013403119CEC098F346407A9371A6FD601340F5DF664A9BF34640EA04C7B160611340602B > BB52A1F34640'); > > > > it is disapointing for me because sometimes the use of these data is for > label or legend and it is not great to see 2.000 instead of 2 on > map or in legend part > > > > does someone have same trouble or idea to resolv the trouble ? > > > > regards > > > > T. > > ___ > > postgis-users mailing list > > postgis-users@postgis.refractions.net > > http://postgis.refractions.net/mailman/listinfo/postgis-users > > ___ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users > ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] trouble shp2pgsql with numeric
Tonton, This is a limitation of shapefiles .dbf format. (yet another reason to move away from shapefiles). PostGIS can't assume that your value is a categorical value (ie a label) when the column only contains numbers and is tagged as numeric. To allow for the widest range of cases, it is imported probably as float or numeric, so if all your column values are integer you could easily (post-import) issue : ALTER TABLE ltb ALTER COLUMN annoying_column TYPE int USING cast(annoying_column as int); hth. cheers Ben On 22/11/2011, at 5:20 PM, Tonton wrote: > hello > > i use shp2pgsql in a web mapping application to add shp file into postgis. > > after uploading on the server side (in django framwork) i use this cmd > > cmd = "/usr/bin/shp2pgsql -c -s 4326 -W latin1 -g geometry > "+/pathToSHPname+" " +str(tablename)+">"+/pathToMyFile.sql" > > it is working near great now but for some numeric information in the sql > request numbers are transform to sort of float : 2 became 2.00 > > this is an exemple for my generate sql ! > > INSERT INTO "ltb" > ("coef_conge","depart_lig","fc","freq_moy","freq__0","freq_moy_m","id_aire","id_station","libbelle","libelle","libell_","ligne","mode","num_type","nom_ligne","nom_statio","num_ligne","num_ligne_","sens","tps_parc","terminus_l","tps_parcou","type_acces","v_com_sytr","vitesse","id_lgn","nom_lgn","nom_stt","order","tpsatt_lgn","vit_off_km","vitcom_lgn","vitesse_km","length",geometry) > VALUES > ('0.00',NULL,'104','0.00','0','0.00','0','0',NULL,NULL,NULL,NULL,NULL,'0',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0',NULL,'0.00','0','18226',NULL,NULL,'31','0','0.00','0.00','0.00','222.2906997126','010520E6100100010220E6100900E721D9B6305F1340E073BE5D7BF34640319802F44B5F13402462B73D81F34640B40C3CD08B5F1340C2FD98C68BF34640C8A0171BA45F134083D387CD8EF34640DBF078F7D05F13408FF4362192F346404248D110246013400742949695F34640BEA067CCB56013403119CEC098F346407A9371A6FD601340F5DF664A9BF34640EA04C7B160611340602B BB52A1F34640'); > > it is disapointing for me because sometimes the use of these data is for > label or legend and it is not great to see 2.000 instead of 2 on map > or in legend part > > does someone have same trouble or idea to resolv the trouble ? > > regards > > T. > ___ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
[postgis-users] trouble shp2pgsql with numeric
hello i use shp2pgsql in a web mapping application to add shp file into postgis. after uploading on the server side (in django framwork) i use this cmd cmd = "/usr/bin/shp2pgsql -c -s 4326 -W latin1 -g geometry "+/pathToSHPname+" " +str(tablename)+">"+/pathToMyFile.sql" it is working near great now but for some numeric information in the sql request numbers are transform to sort of float : 2 became 2.00 this is an exemple for my generate sql ! INSERT INTO "ltb" ("coef_conge","depart_lig","fc","freq_moy","freq__0","freq_moy_m","id_aire","id_station","libbelle","libelle","libell_","ligne","mode","num_type","nom_ligne","nom_statio","num_ligne","num_ligne_","sens","tps_parc","terminus_l","tps_parcou","type_acces","v_com_sytr","vitesse","id_lgn","nom_lgn","nom_stt","order","tpsatt_lgn","vit_off_km","vitcom_lgn","vitesse_km","length",geometry) VALUES ('0.00',NULL,'104','0.00','0','0.00','0','0',NULL,NULL,NULL,NULL,NULL,'0',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0',NULL,'0.00','0','18226',NULL,NULL,'31','0','0.00','0.00','0.00','222.2906997126','010520E6100100010220E6100900E721D9B6305F1340E073BE5D7BF34640319802F44B5F13402462B73D81F34640B40C3CD08B5F1340C2FD98C68BF34640C8A0171BA45F134083D387CD8EF34640DBF078F7D05F13408FF4362192F346404248D110246013400742949695F34640BEA067CCB56013403119CEC098F346407A9371A6FD601340F5DF664A9BF34640EA04C7B160611340602BBB52A1F34640'); it is disapointing for me because sometimes the use of these data is for label or legend and it is not great to see 2.000 instead of 2 on map or in legend part does someone have same trouble or idea to resolv the trouble ? regards T. ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users