[R-sig-Geo] problem creating psp

Michael Sumner mdsumner at gmail.com
Mon Oct 15 22:48:30 CEST 2012


It works for this example, so either something is wrong with your data
or the packages are out of date. Can you provide
summary(SierraLeone.roads) and/or the data file, and sessionInfo()?

library(maptools)
xx <- readShapeLines(system.file("shapes/fylk-val.shp", package="maptools")[1],
       proj4string=CRS("+proj=utm +zone=33 +datum=WGS84"))

library(spatstat)
xx.p <- as.psp(xx)

summary(xx)
Object of class SpatialLinesDataFrame
Coordinates:
          min     max
x   -4867.832 1084722
y 6456207.000 7841997
Is projected: TRUE
proj4string : [+proj=utm +zone=33 +datum=WGS84]
Data attributes:
     FNODE_           TNODE_           LPOLY_         RPOLY_
 Min.   :  1.00   Min.   :  2.00   Min.   :1.00   Min.   :1.00
 1st Qu.: 40.00   1st Qu.: 39.00   1st Qu.:2.00   1st Qu.:2.00
 Median : 74.00   Median : 77.00   Median :2.00   Median :2.00
 Mean   : 77.62   Mean   : 77.55   Mean   :1.99   Mean   :1.99
 3rd Qu.:115.00   3rd Qu.:114.00   3rd Qu.:2.00   3rd Qu.:2.00
 Max.   :160.00   Max.   :159.00   Max.   :2.00   Max.   :2.00
     LENGTH            VALINJE_    VALINJE_ID         LTEMA          VANNBR
 Min.   :   106.4   Min.   : 1   Min.   : 55.00   Min.   :3211   Min.   :13
 1st Qu.: 11866.5   1st Qu.:25   1st Qu.: 74.00   1st Qu.:3211   1st Qu.:13
 Median : 31910.9   Median :49   Median : 95.00   Median :3211   Median :13
 Mean   : 41374.7   Mean   :49   Mean   : 94.32   Mean   :3211   Mean   :13
 3rd Qu.: 59311.8   3rd Qu.:73   3rd Qu.:114.00   3rd Qu.:3211   3rd Qu.:13
 Max.   :176540.1   Max.   :97   Max.   :135.00   Max.   :3211   Max.   :13
      DATO
 Min.   :19970630
 1st Qu.:19970630
 Median :19970630
 Mean   :19970630
 3rd Qu.:19970630
 Max.   :19970630

sessionInfo()
R version 2.15.1 Patched (2012-10-07 r60893)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  compiler  methods
[8] base

other attached packages:
[1] spatstat_1.28-2 deldir_0.0-20   mgcv_1.7-21     maptools_0.8-16
[5] lattice_0.20-10 sp_1.0-0        foreign_0.8-50

loaded via a namespace (and not attached):
[1] grid_2.15.1  Matrix_1.0-9 nlme_3.1-104


Cheers, Mike.

On Tue, Oct 16, 2012 at 7:34 AM, Reeder, Bryce Wesley
<reeder4 at illinois.edu> wrote:
> Hello Everyone,
>
> I am currently trying to complete the simple task of converting a
> SpatialLinesDataFrame to PSP so that I can do kernel density estimation on
> the line pattern (density.psp).  When I do this, however, I get an error
> that does not allow me to proceed.  Here is the code I am using (along with
> the error):
>
>> rm(list=ls(all=TRUE))
>> library(spatstat) # spatial tools
>> ## Read in road data
>>
> setwd("~/Dropbox/Spatial_Project/Hot_Spots_Civil_Conflict/Data/SierraLeone_roads/")
>> SierraLeone.roads <- readShapeLines("Sierra_Leone_highway", repair=T)
>> plot(SierraLeone.roads)
>> SierraLeone.psp <- as.psp(SierraLeone.roads)
> Error in as.data.frame.vector(x, ..., nm = nm) :
>   formal argument "nm" matched by multiple actual arguments
>
> I have not worked with line data much so any assistance would be greatly
> appreciated.
>
> --
> Bryce W. Reeder
> University of Illinois, Urbana-Champaign
> PhD Student - Department of Political Science
> Editorial Assistant, International Interactions
> Office: David Kinley Hall, Room 323
> Email: reeder4 at illinois.edu
>
>         [[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



-- 
Michael Sumner
Hobart, Australia
e-mail: mdsumner at gmail.com



More information about the R-sig-Geo mailing list