[R-sig-Geo] shp (produced with QGIS) into R: missing first field?
Agustin Lobo
aloboaleu at gmail.com
Thu Nov 20 14:48:16 CET 2008
When I inspect the table of a shp in QGIS I can see a field
"id" with unique values for each row (polygon), but
once I import it into R, that first field is not there:
> metrop1spdf <- readOGR("/media/IOMEGA
HDD/Mario/BCNmetrop/GEODATA_BCN/Shape_final2c", layer="SHAPE_FINAL2C")
OGR data source with driver: ESRI Shapefile
Source: "/media/IOMEGA HDD/Mario/BCNmetrop/GEODATA_BCN/Shape_final2c",
layer: "SHAPE_FINAL2C"
with 3272 rows and 49 columns
> save.image()
> str(metrop1spdf,2)
Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots
..@ data :'data.frame': 3272 obs. of 49 variables:
..@ polygons :List of 3272
..@ plotOrder : int [1:3272] 703 1501 140 1467 1416 1336 82 2127
2796 1387 ...
..@ bbox : num [1:2, 1:2] 421333 4576848 438994 4593850
.. ..- attr(*, "dimnames")=List of 2
..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
> str(metrop1spdf at data)
'data.frame': 3272 obs. of 49 variables:
$ FID_inters: int 0 0 1 1 2 3 4 5 6 7 ...
$ FID_UC : int 0 0 0 0 0 0 0 0 0 0 ...
$ ID_GRAFIC : int 1 1 1 1 1 1 1 1 1 1 ...
$ N_VERTEXS : int 5770 5770 5770 5770 5770 5770 5770 5770 5770 5770 ...
$ PERIMETRE : num 191741 191741 191741 191741 191741 ...
$ PERIMETREE: num 191807 191807 191807 191807 191807 ...
$ AREA : num 4444 276 5364 790 3935 ...
etc
As I want to operate with that table in R (which implies merging with
other DF) and produce
a new SPDF and export to shp, I worry for not having that field.
Or is it somehow implied in R? I'm surprised by the fact
that the first value in the id field in QGIS is 0 and not 1. I
think that such an id in R would start by 1, am I wrong?
Agus
--
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: Agustin.Lobo at ija.csic.es
http://www.ija.csic.es/gt/obster
More information about the R-sig-Geo
mailing list