[R-sig-Geo] Question:manipulating spatial data using combination of Maptools and Splancs

Roger Bivand Roger.Bivand at nhh.no
Mon Sep 19 14:30:32 CEST 2005


On Mon, 19 Sep 2005, kostas karis wrote:

> I ran the commands as you suggested and it rans ok, until the ploting
> 
> >akto<-readShapePoly("akto.shp")
> >quakes<-readShapePoints("QD15.shp")
> >ls()
> [1] "akto"   "quakes"
> >sp_quakes<-coordinates(quakes)
> >sp_akto<-getPolygonCoordsSlot(getPolygonsPolygonsSlot(getSpPpolygonsSlot(akto)[[1]])[[1]])
> 
> when i type
> >polymap(sp_akto)
> 
> the shape that the device plots isn't right. the rings and shapes indices 
> are correct but the output is wrong. 

What do: "isn't right" and "wrong" mean in this context? Maybe you could 
attach the shapefiles to me off-list, with some specification of which 
ring in which polygon shapefile is the relevant one for your points - I 
still can't see over your shoulder?

> I used another shapefile with more 
> shapes and i get the following error:
> 
> >nomoi<-readShapePoly("nomoi.shp",verbose=T)
> Shapefile type: Polygon, (5), # of Shapes: 52
> >sp_nomoi<-getPolygonCoordsSlot(getPolygonsPolygonsSlot(
> +getSpPpolygonsSlot(nomoi)[[52]])[[52]])
> Error in getPolygonsPolygonsSlot(getSpPpolygonsSlot(nomoi)[[52]])[[52]] :
>         subscript out of bounds

Yes, the first 52 is OK, but the second one refers to the 52nd ring in the 
52nd multipolygon object. Try:

getSpPnParts(nomoi)

to see how many consituent rings there are in each polygon object - to get 
the last ring of the last polygon, you would need 52 and 
getSpPnParts(nomoi)[52] - the final ring. I guess there are not as many as 
52.

> 
> 
> I currently write my Msc thesis and i am using open-source programs for the 
> processing of spatial data. I am using R for the spatial statistics part but 
> this is the first time that i use this program so i would really appreciate 
> your help.
> 
> _________________________________________________________________
> Don't just search. Find. Check out the new MSN Search! 
> http://search.msn.click-url.com/go/onm00200636ave/direct/01/
> 

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