[R-sig-Geo] using spatialpolygonsdataframe in ppm (or, converting spatialpolygonsdataframe to pixel image or other object useful in ppm)

Adrian Baddeley adrian.baddeley at curtin.edu.au
Sat Sep 2 12:21:31 CEST 2017


Christopher W. Ryan <cryan at binghamton.edu> writes:

 > What is the best way to use a spatialpolygonsdataframe,

 > with a numerical variable of interest for each polygon

 > (proportion of households in poverty for US census tracts

 > in the region of interest) as a predictor in ppm() in spatstat?


 > I don't think I can use it directly on the RHS of ppm(),

 > because spatialpolygonsdataframe is not listed in the help file

 > for ppm() as an acceptable predictor.


     That's correct.


 > So is there a way to convert the
 > census tract spatialpolygonsdataframe to an acceptable input object for
 > ppm(), such as a pixel image with each pixel having the numerical value
 > of poverty in its census tract polygon?


   Yes, this is possible.


    Alternatively, you could convert the data into a function with arguments (x,y)

    that returns the value of poverty in the polygon in which the location (x,y) falls.


    It's probably easier to make a function, and it's better because you won't lose accuracy

    due to discretisation.

          1. Convert each polygon into a window of class 'owin' in the spatstat package.

           2. Make a tessellation (class 'tess') out of these polygons.

           3. Convert the tessellation to a function using 'as.function.tess'

               using the argument 'values' to specify the value associated with each polygon.

    To do steps 1 and 2, see the 'shapefiles' vignette in the spatstat package.


     If you decide you need a pixel image instead, then just use 'as.im' to convert the function

     to an image.


Hope this helps.

Adrian Baddeley

Spatstat author


Prof Adrian Baddeley DSc FAA

John Curtin Distinguished Professor

Department of Mathematics and Statistics

Curtin University, Perth, Western Australia

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list