Skip to content

Question:manipulating spatial data using combination of Maptools and Splancs

4 messages · kostas karis, Roger Bivand

#
Hi,
I have a problem that concerns combination of the package Maptools and 
Splancs
I have 2 shapefiles that i want to manipulate (one of type point and one 
polygon).I import them in R using Maptools but then i can't estimate a 
quartic Kernel using Splancs. The package doesn't recognize the shapes 
(invalid points and poly argument).I don't know if this is an easy task but 
i have read both packages's manual and i can't find a liable solution. Thank 
u for your time.
#
On Fri, 16 Sep 2005, kostas karis wrote:

            
Say you have a shapefile of points, and a shapefile with one single ring 
polygon, no holes or other geometry objects, then using maptools 0.5-2:
Loading required package: foreign
Loading required package: sp
Shapefile type: Polygon, (5), # of Shapes: 1
Conversion is by
+    getSpPpolygonsSlot(cardiff_poly)[[1]])[[1]])

to unpack the coordinates of the points and the single ring boundary. If 
you have more than one shape, and/or more than one ring in that shape, 
adjust the [[Shape]])[[ring]] indices to suit. Then:
+    add=TRUE)
works as expected. Extracting the polygon looks complicated because 
shapefiles have a "richer" geometry than splancs. Wrapper functions for 
splancs to use the sp classes now used by maptools will be available 
before long.

  
    
#
Thank you for your advice but i still have a problem...Everything goes fine 
till the plotting (as usual).When i try the code you posted for the 
conversion i get the following message:

Error in coordinates(quakes) : no direct or inherited method for function 
'coordinates' for this call

i don't have a clue what this means...

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search!
#
On Sat, 17 Sep 2005, kostas karis wrote:

            
Please always include the commands you gave, here in particular the
command(s) creating the quakes object - other list participants cannot see
your computer screen. All the error message says is that it is not a
SpatialPoints* object, so you have not done:
as I suggested. I also suggest moving this thread to the R-sig-geo list - 
subscription details on the "Spatial" Task View on CRAN:

http://cran.r-project.org/src/contrib/Views/Spatial.html