[R-sig-Geo] warning at creating SpatialPolygonsDataFrame and error at saving through rgdal

Roger Bivand Roger.Bivand at nhh.no
Mon Nov 29 14:08:49 CET 2010


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
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

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



More information about the R-sig-Geo mailing list