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

Michael Sumner mdsumner at gmail.com
Sat Sep 2 09:00:40 CEST 2017


On Sat, 2 Sep 2017 at 04:04 Christopher W. Ryan <cryan at binghamton.edu>
wrote:

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

Start with vignette("shapefiles", package = "spatstat") for the spatstat
view of Spatial* - it's relatively straightforward to convert Spatial* to
raster and raster to spatstat, but I don't have an example on hand.

It's not clear to me if you need polygons in spatstat or a raster owin
version of them - admittedly spatstat does allow a combination of the two,
so that's maybe what's needed.

If you have a clear example of using ppm that would do the task if had your
data in spatstat form I'm happy to show the conversion/s.

HTH

Cheers, Mike.


> Or is there a better way to proceed?
>
> Thank you.  Below is my sessionInfo
>
> --Chris Ryan
> Broome County Health Department, Binghamton, NY
>
> =================================
> R version 3.3.3 (2017-03-06)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 7 x64 (build 7601) Service Pack 1
>
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
>  [1] tmap_1.10          rgdal_1.2-6        RColorBrewer_1.1-2
> maptools_0.9-2
>  [5] sp_1.2-4           spatstat_1.50-0    rpart_4.1-10
> nlme_3.1-131
>  [9] shapefiles_0.7     foreign_0.8-67     stringr_1.2.0
> dplyr_0.5.0
>
> loaded via a namespace (and not attached):
>  [1] viridisLite_0.2.0    jsonlite_1.4         splines_3.3.3
>  [4] geojsonlint_0.2.0    foreach_1.4.3        R.utils_2.5.0
>  [7] gtools_3.5.0         shiny_1.0.5          assertthat_0.2.0
> [10] expm_0.999-2         stats4_3.3.3         LearnBayes_2.15
> [13] lattice_0.20-35      digest_0.6.12        polyclip_1.6-1
> [16] colorspace_1.3-2     plyr_1.8.4           htmltools_0.3.5
> [19] httpuv_1.3.5         Matrix_1.2-8         R.oo_1.21.0
> [22] XML_3.98-1.9         rmapshaper_0.3.0     raster_2.5-8
> [25] gmodels_2.16.2       xtable_1.8-2         webshot_0.4.1
> [28] scales_0.4.1         gdata_2.17.0         tensor_1.5
> [31] satellite_1.0.0      spatstat.utils_1.4-1 tibble_1.3.0
> [34] mgcv_1.8-17          gdalUtils_2.0.1.7    mapview_2.1.4
> [37] magrittr_1.5         mime_0.5             deldir_0.1-12
> [40] R.methodsS3_1.7.1    MASS_7.3-45          class_7.3-14
> [43] tools_3.3.3          geosphere_1.5-5      V8_1.5
> [46] munsell_0.4.3        compiler_3.3.3       e1071_1.6-8
> [49] units_0.4-5          classInt_0.1-24      grid_3.3.3
> [52] tmaptools_1.2-1      RCurl_1.95-4.8       dichromat_2.0-0
> [55] iterators_1.0.8      htmlwidgets_0.8      goftest_1.1-1
> [58] crosstalk_1.0.0      bitops_1.0-6         base64enc_0.1-3
> [61] boot_1.3-18          codetools_0.2-15     abind_1.4-5
> [64] DBI_0.6-1            jsonvalidate_1.0.0   curl_2.5
> [67] R6_2.2.0             udunits2_0.13        rgeos_0.3-23
> [70] spdep_0.6-12         KernSmooth_2.23-15   stringi_1.1.5
> [73] osmar_1.1-7          Rcpp_0.12.10         sf_0.5-3
> [76] png_0.1-7            leaflet_1.1.0        coda_0.19-1
> >
>
> ---
> This email has been checked for viruses by AVG.
> http://www.avg.com
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
-- 
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list