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