[GRASS-stats] readVECT6 problem fo importing null data
Roger Bivand
Roger.Bivand at nhh.no
Mon Nov 26 15:20:23 EST 2007
On Mon, 26 Nov 2007, Jarek Jasiewicz wrote:
> Dear Collages!
>
> I found some Issue (seems problematic) with readVECT6 (there are all commands
> I used, complete my answer)
>
> I have vector file attached table (pgSQL) with null values both for int4 and
> char columns (example table):
> I import the table via RdbiPgSQL
>
>> library(RdbiPgSQL)
>> conn=dbConnect(PgSQL(), host="localhost", ........)
>> sql="SELECT * FROM t"
>> quer=dbSendQuery(conn, sql)
>> table=dbGetResult(quer)
>> table
> cat int4 char
> 1 2 1 <NA>
> 2 4 NA <NA>
> 3 6 5 <NA>
> 4 7 NA <NA>
> 5 1 0 n
> 6 3 NA b
> 7 5 4 p
> 8 8 6 c
>
> As you see, there are two columns int4 and char with null values, which are
> imported to R as shoud be.
I can reproduce the problem, which seems related to DBFIsAttributeNULL not
being handled adequately on either side (both are using the OGR library).
Could you please try to write the temporary shapefile directly using
v.out.ogr, and then try to read it with readOGR() and with readShape*()
with * as Points, Lines, or Poly depending on what getinfo.shape() says?
I'll try to debug using the DBF code in the foreign package to start with
- numeric fields should have value /* NULL numeric fields have value
"****************" */ from dbfopen.c, but do not seem to.
Roger
>
> But what happend if we import data b y readVECT6:
>
>> readVECT6("t")
> Exporting 8 points/lines...
> 100%
> 8 features written
> OGR data source with driver: ESRI Shapefile
> Source: "/home/jarekj/grassdata/azp/PERMANENT/.tmp/jarekj-desktop", layer:
> "t"
> with 8 rows and 3 columns
> coordinates cat int4 char
> 1 (3688170, 5673160) 1 0 n
> 2 (3694430, 5674130) 2 1 3 (3701530, 5665800) 3 0 b
> 4 (3690110, 5660580) 4 0 5 (3706040, 5668900) 5 4 p
> 6 (3693660, 5665800) 6 5 7 (3704170, 5674130) 7 0 8
> (3705460, 5660450) 8 6 c
>
> null values for char are preserved but for int, has been changed to 0.
>
> AFAIK, it is due to v.out.ogr use shapefile and dbf which treat null in
> integer as 0 during export.
>
> So, it is a problem??? Or May I forgot do something.
> best regards
> Jarek
>
> _______________________________________________
> grass-stats mailing list
> grass-stats at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-stats
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the grass-stats
mailing list