Roger,
Please find enclosed the function and 3 files such as the ones that
are processed. Please extract the zip
into a folder named GLIS_scenes and indicate the path in the call to the
function.
The function is run just by:
source("meta2sppol.R")
HypAr <- meta2sppol(midir="../GLIS_scenes")
What I try to do is read each file, extract the 4 pairs of coordinates
and make a SPDF with the polygons and the data
from the files.
Thanks
Agus
2010/11/29 Roger Bivand <Roger.Bivand at nhh.no>:
On Mon, 29 Nov 2010, Agustin Lobo wrote:
Hi!
I create a SPDF with a function
HypNAr = meta2sppol()
that ends up with:
sitios <- 1:length(noms)
row.names(datos) <- sitios
SpatialPolygonsDataFrame(dummy, data=datos, match.ID = T)
but get:
Warning message:
In data.row.names(row.names, rowsi, i) :
?some row.names duplicated: 2 --> row.names NOT used
The message is coming from data.frame() in base package. Do
debug(meta2sppol)
debug(data.frame)
HypNAr = meta2sppol()
and see what happens inside the data.frame() call that creates datos, which
is where the warning is issued (it may be inside a coercion method call,
such as as.data.frame()); open:
https://svn.r-project.org/R/trunk/src/library/base/R/dataframe.R
and search for "some row.names duplicated".
That is, the problem is in your own function. Please also note that
providing a reproducible example is crucial to getting precise assistance,
and usually the exercise of writing such an example reveals the cause, thus
solving the problem more quickly.
Roger
I do not understand, as I define the row names as a sequence of
integers, how can they be duplicated?
I can plot the SPDF and the data slot is correct, but when I try to
save as shapefile:
writeOGR(HypNAr,dsn="HypNAr",layer="HypNAr",driver="ESRI
Shapefile",verbose=T)
Error in writeOGR(HypNAr, dsn = "HypNAr", layer = "HypNAr", driver =
"ESRI Shapefile", ?:
? ? ? ?GDAL Error 1: Invalid index : -1
Calls: writeOGR -> .Call
In addition: There were 11 warnings (use warnings() to see them)
Is this error related to the previous warning?
Thanks!
Agus