[GRASS-stats] readVECT6 problem fo importing null data
Roger Bivand
Roger.Bivand at nhh.no
Tue Nov 27 04:02:29 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
Dear Jarek,
Could you please try readOGR() directly from the PostgreSQL/PostGIS
source? This will remove the imposition of the intermediary DBF format,
and if it succeeds provides a feasible solution, and if it doesn't,
suggests that OGR drivers have problems with missing value handling in
some implementations (in GRASS and in rgdal, where v.in.ogr and readOGR()
use the same basic approach, as do v.out.ogr and writeOGR()).
Roger
>
>> 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.
>
> 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