maptools::as.im.RasterLayer with factor layers

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

maptools::as.im.RasterLayer with factor layers

Matt Lewis

Dear all,


Not so much a question as a bit of adapted code.


Recently, I've been working with the spatstat package and using maptools to convert raster objects to spatstat's im format. One issue I have been having is the conversion of factor raster layers to im. To that end, I've adapted the maptools::as.im.RasterLayer() function to work with factor layers.


I realise that quite possibly this is a problem that has an alternative solution that I'm unaware of, but in case my adapted function is useful to others or something which you would like to include in the next release of maptools, I have attached it here.


Thanks for your work with maptools, and with all best wishes,

Matt


This email was originally sent to Roger Bivand who directed me to this list.

--
Matt Lewis (he/him)
MPhil Student

Insect Ecology Group
Department of Zoology
University of Cambridge
CB2 3EJ

[hidden email] | [hidden email]
@matthewlewis896
https://www.zoo.cam.ac.uk/directory/matthew-lewis

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

as.im.RasterLayer.R (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: maptools::as.im.RasterLayer with factor layers

Roger Bivand
Administrator
Not seeing a reply here, I opened an issue:
https://github.com/spatstat/spatstat/issues/132, which has been answered.
If you are on github, Matt and others interested, please look at the code
and let me know when it stabilises enough to revise maptools.

Roger

On Tue, 9 Jun 2020, Matt Lewis wrote:

> Dear all,
> Not so much a question as a bit of adapted code.
> Recently, I've been working with the spatstat package and using maptools
> to convert raster objects to spatstat's im format. One issue I have been
> having is the conversion of factor raster layers to im. To that end,
> I've adapted the maptools::as.im.RasterLayer() function to work with
> factor layers.
> I realise that quite possibly this is a problem that has an alternative
> solution that I'm unaware of, but in case my adapted function is useful
> to others or something which you would like to include in the next
> release of maptools, I have attached it here.
> Thanks for your work with maptools, and with all best wishes,
> Matt
> This email was originally sent to Roger Bivand who directed me to this
> list.
>
>

--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: [hidden email]
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway