Skip to content

warning at creating SpatialPolygonsDataFrame and error at saving through rgdal

2 messages · Agustin Lobo, Roger Bivand

#
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

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:
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
#
On Mon, 29 Nov 2010, Agustin Lobo wrote:

            
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