[GRASS-stats] readVECT6 problem fo importing null data

Markus Neteler neteler at fbk.eu
Wed Dec 5 09:46:44 EST 2007



Jarek Jasiewicz wrote:
> 
> Marcus!
> 
> FCODE type is character, but problem concerns ONLY numeric data. 
> Character data are exported propertly, probably because it is rather 
> zerolengh string for dbf
> 
> AFAIK, handling numeric NULL in dbf is problematic not only for grass
> users
> 
> best wishes
> Jarek
> 

I have debugged a bit.

GRASS 6.3.cvs (nc_spm_06):~ > db.connect -p
driver:dbf
database:$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/
schema:
group:

GRASS 6.3.cvs (nc_spm_06):~ > v.db.update mylakes col=AREA value=NULL
where="AREA > 6000"

GRASS 6.3.cvs (nc_spm_06):~ > v.db.select mylakes | head
cat|AREA|PERIMETER|FULL_HYDRO|FULL_HYDR2|FTYPE|FCODE|NAME
1||2853.9372|2|55626|LAKE/POND|39000|
2||404.28643|3|55650|DAM/WEIR|34300|
3||708.44683|4|55652|LAKE/POND|39000|
4|1132.10986|151.16533|5|53514|LAKE/POND|39000|
5|2849.43244|249.99941|6|53510|DAM/WEIR|34300|
6|5908.42064|413.13377|7|55640|DAM/WEIR|34300|
7||567.89134|8|55644|LAKE/POND|39000|
8|5310.04399|334.89296|9|55660|LAKE/POND|39000|
9||404.72896|10|55624|TUNNEL/CULVERT|47800|
...

# -> areas removed.

v.out.ogr mylakes dsn=mylakes.shp type=area

openoffice2.3 mylakes.dbf
cat,N,11,0,AREA,N,24,15,PERIMETER,N,24,15,FULL_HYDRO,N,24,15,FULL_HYDR2,N,24,15,FTYPE,C,80,FCODE,N,11,0,NAME,C,80
8,5310.04,334.89,9,55660,LAKE/POND,39000,
33,0,709.53,34,54836,LAKE/POND,39000,
63,469.77,105.84,64,0,,0,
84,0,402.43,85,55595,ROCK/ISLAND,44100,
93,0,344.71,94,53621,DAM/WEIR,34300,

Hooray, problem reproduced :)

BUT:
g.gisenv set=DEBUG=3
v.db.select mylakes
...
D2/3:   ncols = 8 nrows = 10
D2/3: load_table_head(): tab = 9,
/home/neteler/grassdata/nc_spm_06/neteler/dbf//mylakes.dbf
cat|AREA|PERIMETER|FULL_HYDRO|FULL_HYDR2|FTYPE|FCODE|NAME
1||2853.9372|2|55626|LAKE/POND|39000|
2||404.28643|3|55650|DAM/WEIR|34300|
3||708.44683|4|55652|LAKE/POND|39000|
4|1132.10986|151.16533|5|53514|LAKE/POND|39000|
5|2849.43244|249.99941|6|53510|DAM/WEIR|34300|
6|5908.42064|413.13377|7|55640|DAM/WEIR|34300|
7||567.89134|8|55644|LAKE/POND|39000|
8|5310.04399|334.89296|9|55660|LAKE/POND|39000|
9||404.72896|10|55624|TUNNEL/CULVERT|47800|
10||3010.93109|11|55625|LAKE/POND|39000|
...
# -> so far ok

dbfdump /home/neteler/grassdata/nc_spm_06/neteler/dbf/mylakes.dbf
  cat          AREA       PERIMETER    FULL_HYDRO     FULL_HYDR2  FTYPE           
FCODE NAME
    1        (NULL)     2853.937200      2.000000   55626.000000  LAKE/POND     
39000 (NULL)
    2        (NULL)      404.286430      3.000000   55650.000000  DAM/WEIR      
34300 (NULL)
    3        (NULL)      708.446830      4.000000   55652.000000  LAKE/POND     
39000 (NULL)
    4   1132.109860      151.165330      5.000000   53514.000000  LAKE/POND     
39000 (NULL)
    5   2849.432440      249.999410      6.000000   53510.000000  DAM/WEIR      
34300 (NULL)
    6   5908.420640      413.133770      7.000000   55640.000000  DAM/WEIR      
34300 (NULL)
    7        (NULL)      567.891340      8.000000   55644.000000  LAKE/POND     
39000 (NULL)
    8   5310.043990      334.892960      9.000000   55660.000000  LAKE/POND     
39000 (NULL)
    9        (NULL)      404.728960     10.000000   55624.000000 
TUNNEL/CULVERT 47800 (NULL)
   10        (NULL)     3010.931090     11.000000   55625.000000  LAKE/POND     
39000 (NULL)
...
# -> so far ok

ogrinfo /home/neteler/grassdata/nc_spm_06/neteler/dbf//mylakes.dbf mylakes
...
cat: Real (11.0)
AREA: Real (20.6)
PERIMETER: Real (20.6)
FULL_HYDRO: Real (20.6)
FULL_HYDR2: Real (20.6)
FTYPE: String (24.0)
FCODE: Real (11.0)
NAME: String (99.0)
OGRFeature(mylakes2):0
  cat (Real) =           1
  AREA (Real) = (null)
  PERIMETER (Real) =          2853.937200
  FULL_HYDRO (Real) =             2.000000
  FULL_HYDR2 (Real) =         55626.000000
  FTYPE (String) = LAKE/POND
  FCODE (Real) =       39000
  NAME (String) = (null)
...
# -> so far ok

v.out.ogr ...
D2/2: load_table_head(): tab = 9,
/home/neteler/grassdata/nc_spm_06/neteler/dbf//mylakes.dbf
D2/2: col 0 : val = 10
D2/2:   colctype = 2
D2/2: col 1 : val =               <- using db_get_string (&dbstring): works
D2/2:   colctype = 3
D2/2: DBMI db_get_value_double: val = 0.000000              <- using
db_get_value_double(Value): fails
D2/2: DBMI db_get_value_double: val = 0.000000
D2/2: col db_get_value_double: val = 0.000000
D2/2: DBMI db_get_value_double: val = 3010.931090
D2/2: col 2 : val = 3010.93109
D2/2:   colctype = 3

It seems to be a non.feature/bug in db_get_value_double(Value), maybe also 
db_get_value_int(Value) or how the values are stored in dbValue:
lib/db/dbmi_base/value.c

This should be taken to the grass-dev list.

Markus
-- 
View this message in context: http://www.nabble.com/-GRASS-stats--readVECT6-problem-fo-importing-null-data-tf4876840.html#a14172945
Sent from the Grass - Stats mailing list archive at Nabble.com.



More information about the grass-stats mailing list