[Qgis-developer] [Fwd: Re: Problems with shp files created in QGIS when imported to R]

Agustin Lobo alobolistas at gmail.com
Tue Jul 7 16:57:13 EDT 2009


I'm sending this on behalf of
Roger Bivand, who is not subscribed to the list.
Agus

-------- Original Message --------
Subject: Re: Problems with shp files created in QGIS when imported to R
Date: Tue, 7 Jul 2009 18:44:15 +0200 (CEST)
From: Roger Bivand <Roger.Bivand at nhh.no>
Reply-To: Roger.Bivand at nhh.no
To: Agustin.Lobo at ija.csic.es
CC: qgis-developer <qgis-developer at lists.osgeo.org>,        Carson Farmer 
<carson.farmer at gmail.com>
References: <4A53756B.3040604 at gmail.com>

On Tue, 7 Jul 2009, Agustin Lobo wrote:

> Hi!
>
> I've found a couple of things that seem to be errors. Let me
> know if I should fill error tickets.
>
> 1. A shape file drawn as a set of independent straight lines in QGIS has 
> 3 pairs of coordinates (the 3rd == the 2nd) for each line , which made 
> unhappy some R functions once the file was imported through rgdal as an 
> SpatialLinesDataFrame. For the first line:
>> coordinates(fl1)
> [[1]]
> [[1]][[1]]
>         [,1]    [,2]
> [1,] 449919.6 4631874
> [2,] 448616.7 4630789
> [3,] 448616.7 4630789
>

The problem was downstream, in that a 0-length segment created problems
for sampling from the line. Otherwise, the duplicated point is simply
redundant. It looks as though the line termination operation adds a final
point even if that point is already given.

>
>
> 2. Shape files edited in QGIS, i.e., deleting one line and making 
> another one, and then saving, cannot be imported to R through rgdal.
>
> Roger Bivand (author of readOGR() in R) has done an extensive exploration, 
.../... (quote of previous message by A. Lobo deleted by A.Lobo)
>> Feature type: wkbLineString with 2 dimensions
>> Warning message:
>> In readOGR(".", "flMata700v2") : Dropping null geometries: 3
>> 
>> I'll check the warning warning - it isn't obvious which one is treated as 
>> null.

Between the two chunks above, I found (quoting from a follow-up to Agus):

"Further:

$ ogrinfo -al -fid 0 flMata700v2.shp
INFO: Open of `flMata700v2.shp'
       using driver `ESRI Shapefile' successful.

Layer name: flMata700v2
Geometry: Line String
Feature Count: 3
Extent: (444325.763593, 4628082.857481) - (449125.423298, 4630060.494173)
Layer SRS WKT:
PROJCS["UTM Zone 31, Northern Hemisphere",
     GEOGCS["International 1909 (Hayford)",
         DATUM["unknown",
             SPHEROID["intl",6378388,297]],
         PRIMEM["Greenwich",0],
         UNIT["Degree",0.017453292519943295]],
     PROJECTION["Transverse_Mercator"],
     PARAMETER["latitude_of_origin",0],
     PARAMETER["central_meridian",3],
     PARAMETER["scale_factor",0.9996],
     PARAMETER["false_easting",500000],
     PARAMETER["false_northing",0],
     UNIT["Meter",1]]
Code: Integer (10.0)
Comment: String (80.0)
ERROR 1: Attempt to read shape with feature id (0), but it is marked
deleted.
Unable to locate feature id 0 on this layer.

Setting -fid to 1 or 2 is OK. The message is coming from:

ogr/ogrsf_frmts/shape/shape2ogr.cpp, line 823

when hDBF && DBFIsRecordDeleted( hDBF, iShape ), so it seems to be a
marker
in the DBF file. The DBF file has an asterisk in the first data row, seen
by:

ogr/ogrsf_frmts/shape/dbfopen.c, line 1709

as a deletion mark, consequently deleting the feature as a whole."

Just marking a DBF field as missing is probably not a portable way of
deleting a feature, it really needs to be removed fully.

Roger

>
>
> Agus
>

-- 
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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: alobolistas.vcf
Type: text/x-vcard
Size: 251 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/qgis-developer/attachments/20090707/c4bfd5a3/alobolistas.vcf


More information about the Qgis-developer mailing list