[R-sig-Geo] distmap

Roger Bivand Roger.Bivand at nhh.no
Wed Jun 27 12:43:10 CEST 2007


On Tue, 26 Jun 2007, Agustin Lobo wrote:

> Still some problems:
>
>>  sessionInfo()
> R version 2.5.0 (2007-04-23)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=Spanish_Spain.1252;LC_CTYPE=Spanish_Spain.1252;LC_MONETARY=Spanish_Spain.1252;LC_NUMERIC=C;LC_TIME=Spanish_Spain.1252
>
> attached base packages:
> [1] "stats"     "graphics"  "grDevices" "utils"     "datasets" "methods" 
> "base"
>
> other attached packages:
> maptools  foreign spatstat     mgcv       sp
> "0.6-13" "0.8-20" "1.11-7" "1.3-25" "0.9-14"
>
>>  limit1 <- read.shape("limit_PNSN2000.shp")
>>  limit1owin <- as(limit2,"owin")
> Error in inherits(x, "factor") : cannot get a slot ("contains") from an 
> object of type "NULL"
>>  limit1owin <- as(as(limit2, "SpatialPolygons"), "owin")
> Checking 3 polygons...1, 2, [Checking polygon with 2749 edges...]
> 3.
> done.
> Checking for cross-intersection between 3 polygons...1, Polygons 1 and 3 
> cross over
> 2.
> done.
> Error in owin(poly = opls) : Polygon data contain overlaps between polygons
>>  plot(limit2)
>
> I can send you limit2.rda, is that ok?

Yes, but as you can see, the problem seems to be that your polygons 
overlap. That probably needs resolving first, or in the limit2 object 
inside R.

Roger

>
> Agus
>
>
>
> Roger Bivand escribió:
>>  On Mon, 25 Jun 2007, Edzer J. Pebesma wrote:
>> 
>> >  Roger Bivand wrote:
>> > >   On Mon, 25 Jun 2007, Agustin Lobo wrote:
>> > > 
>> > > >   I've tried (among other things):
>> > > > >    limit1 <- read.shape("limit_PNSN2000.shp")
>> > > >   Shapefile type: Polygon, (5), # of Shapes: 2
>> > > > >    limit1poly <- Map2poly(limit1)
>> > > > >    limit1owin <- as(limit1poly,"owin")
>> > > >   Error in .classEnv(thisClass) : unable to find an environment 
>> > > containing >   class "polylist"
>> > > > > >    limit2 <- readOGR("limit_PNSN2000.shp",layer="limit_PNSN2000")
>> > > >   OGR data source with driver: ESRI Shapefile
>> > > >   Source: "limit_PNSN2000.shp", layer: "limit_PNSN2000"
>> > > >   with  2  rows and  1  columns
>> > > 
>> > >   Then just:
>> > > 
>> > >   limit1owin <- as(limit2,"owin")
>> > > 
>> > >   ought to work with current maptools, or possibly coerce:
>> > > 
>> > >   limit1owin <- as(as(limit2, "SpatialPolygons"), "owin")
>> > > 
>> >  the latter form shouldn't be needed thanks to S4 inheritance.
>>
>>  In principle yes, especially with fresh sp and maptools, but I'm not sure
>>  that my code in earlier versions allowed inheritance properly, and we
>>  don't know which package versions are being used. Hence the general
>>  request to state sessionInfo() output in all questions to the list.
>>
>>  Roger
>> 
>> >  -- 
>> >  Edzer
>> >
>> 
>
>

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