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

Agustin Lobo alobolistas at gmail.com
Tue Jul 7 12:18:51 EDT 2009


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



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, his 
last comment being:
"OK - this means that QGIS doesn't delete it, but just marks the DBF in a 
particular way that is highly non-standard, and probably only understood by OGR. 
I suggest running ogr2ogr to see if the feature gets flushed too"

Not sure if this has to be reported as an error, perhaps something to
be modified in order to avoid problems with other software?

I reproduce here Roger's tests and comments:

> $ ogrinfo -al 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)
> OGRFeature(flMata700v2):1
>  Code (Integer) = 2
>  Comment (String) = CarrElBrull700
>  LINESTRING (445982.70244308974361 4628195.695610512979329,
>              444325.763592548959423 4630060.494173487648368,
>              444325.763592548959423 4630060.494173487648368)
> 
> OGRFeature(flMata700v2):2
>  Code (Integer) = 1
>  Comment (String) = (null)
>  LINESTRING (445751.825211017741822 4628242.35935128480196,
>              449125.423298357811291 4628875.170917978510261,
>              449125.423298357811291 4628875.170917978510261)
> 
> suggests that the OGR driver sees something missing - there are three declared features, but one, the first - FID "0", is not in specification.


> system("ogr2ogr -f 'ESRI Shapefile' flMata700v2a.shp flMata700v2.shp")
> xxxx <- readOGR(".", "flMata700v2a")
> 
> works for me, with:
> 
>> xxxx <- readOGR(".", "flMata700v2a")
> OGR data source with driver: ESRI Shapefile
> Source: ".", layer: "flMata700v2a"
> with  2  rows and  2  columns
> Feature type: wkbLineString with 2 dimensions
>> xxx <- readOGR(".", "flMata700v2")
> OGR data source with driver: ESRI Shapefile
> Source: ".", layer: "flMata700v2"
> with  3  rows and  2  columns
> 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.


Agus
-------------- 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/6694ca84/alobolistas.vcf


More information about the Qgis-developer mailing list