[R-sig-Geo] spatialdataframe to spatial.polygon

Edzer Pebesma edzer.pebesma at uni-muenster.de
Tue Jun 11 17:50:26 CEST 2013

After looking at the data (off-list), I got the following warnings & error:

Warning messages:
1: In is.na(poly[, 1]) :
  is.na() applied to non-(list or vector) of type 'NULL'
2: In is.na(poly[, 1]) :
  is.na() applied to non-(list or vector) of type 'NULL'
Error in coordinates(coords) :
  error in evaluating the argument 'obj' in selecting a method for
function 'coordinates': Error in 1:(na.index[1] - 1) : NA/NaN argument

after checking the arguments, it turns out that polygon has value NULL.

?polygons2spatial.polygon tells that it wants a

    poly: a 2-column matrix of coordinates, where each complete
          subpolygon is separated by NA's

as first argument, but that is not what you give it.

On 06/06/2013 09:04 PM, Kalbasse Group wrote:
> Hi to all I am new in R
> I am trying to transform a spatialdataframe into a Spatial.Polygon file using the SptialEpi package with no success. This the code
> library(SpatialEpi)
> library(proj4)
> polygon <- ADpoly$polygon$polygon
> nrepeats <- ADpoly$polygon$nrepeats
> names <- ADpoly$data$ADIDU
> spatial.polygon <- polygon2spatial.polygon(polygon, coordinate.system== "+proj=lcc +lat_1=50 +lat_2=70 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0" ,names, nrepeats)
> ADpoly is my spatialdataframe projected in canada lambert conformal
> and this is the error:
> cannot evaluate the  'obj' when selecting a mthod for the 'coordinates' function
> Please may someone help me?
> 	[[alternative HTML version deleted]]
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
83 33081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de

More information about the R-sig-Geo mailing list