Exporting Dsurface map into GIS

questions concerning anlysis/theory using program DENSITY and R package secr. Focus on spatially-explicit analysis.

Exporting Dsurface map into GIS

Postby Lombardijv » Tue Oct 21, 2014 11:37 am

Murray,

I wanted to know if there was a way to export a density surface map from R into a GIS (shape file?), and if so what would I export the file as? Reason why I am asking is because my advisors and I wanted to see if we could overlay the density surface map on top of a city zoning map in order to identify potential hot spots of human - carnivore contact.


- Jason
Lombardijv
 
Posts: 9
Joined: Mon Mar 17, 2014 1:07 pm

Re: Exporting Dsurface map into GIS

Postby murray.efford » Tue Oct 21, 2014 3:50 pm

Hi Jason
I don't have a simple answer. secr masks and Dsurfaces don't include projection information that would be needed. The next version of secr will have a method for making a raster package RasterLayer object from a Dsurface, and then I expect you could export from raster, sp etc. Meantime, you have the options of exporting the raw coordinates and density values (e.g. covariate D.0), or constructing a RasterLayer object with the raster signature for matrix objects (see ?raster).
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Exporting Dsurface map into GIS

Postby sixtystrat » Mon Jun 01, 2015 1:50 pm

So then, how would one extract the values for D.0? I can get the x and y okay but am having trouble with the r language to get me down to D.0. Thanks!
Joe
sixtystrat
 
Posts: 115
Joined: Wed Jun 01, 2011 9:19 am

Re: Exporting Dsurface map into GIS

Postby murray.efford » Mon Jun 01, 2015 5:36 pm

A Dsurface is a sort of mask. Group-specific densities are stored as columns in the covariates attribute, extracted with covariates(). 'D.0' is used for 'all groups'. Unfortunately, I wrote a 'print' method for Dsurfaces that makes it look as if D.0 is part of the same dataframe as x and y, which it isn't.
Code: Select all
shorePossums <- predictDsurface(possum.model.Ds)
head(covariates(shorePossums))
head(covariates(shorePossums)$D.0)

The working version (2.9.5) available from the Density website also has documentation for making a 'raster' object from a Dsurface that may help (see Examples in ?raster once you've installed and loaded 2.9.5).

Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Exporting Dsurface map into GIS

Postby sixtystrat » Tue Jun 02, 2015 11:17 am

That worked! If I wanted to estimate N for a subset of the study area within that grid (a conservation area for example), could I simply sum the per-pixel density values within that subset or would I have to re-run the model using that area as a mask? The former is a lot quicker... I understand that my densities (which are on a per ha basis) for summing would have to be adjusted because my pixels are larger than 1 ha. Thanks!
Joe
sixtystrat
 
Posts: 115
Joined: Wed Jun 01, 2011 9:19 am

Re: Exporting Dsurface map into GIS

Postby murray.efford » Tue Jun 02, 2015 4:25 pm

Joe
There's no need to re-fit the model. You can sum pixels as you suggest, or, more directly, use region.N specifying the 'region' argument, which may be a mask or a SpatialPolygonsDataFrame (see Details in ?region.N).
Murray
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Exporting Dsurface map into GIS

Postby sixtystrat » Wed Jun 03, 2015 7:40 am

Great. Thanks as always for your prompt response Murray.
Joe
sixtystrat
 
Posts: 115
Joined: Wed Jun 01, 2011 9:19 am

Exporting fx.total into GIS

Postby cowzrgr8 » Wed Mar 28, 2018 3:36 pm

Mr. Efford,

I have a similar question about exporting a map into GIS. Is there a way to export a plot created by fx.total into GIS? I am having difficulties turning this plot into a raster using writeSpatialShape, raster, writeRaster, etc.

Thank you
Becca
cowzrgr8
 
Posts: 3
Joined: Wed Feb 21, 2018 6:31 pm

Re: Exporting Dsurface map into GIS

Postby murray.efford » Wed Mar 28, 2018 4:14 pm

Code: Select all
fxsurface <- fx.total(ovenbird.model.D, sessnum = 3)
r <- raster(fxsurface, 'D.fx')
library(raster)
plot(r)
# or, if that doesn't work
plot(r, useRaster = FALSE)


But first, do you really want to use fx.total? These pretty plots are usually misleading. Be prepared to explain in words exactly what it is that you are plotting and why, and do _not_ call it a 'density plot'.
murray.efford
 
Posts: 686
Joined: Mon Sep 29, 2008 7:11 pm
Location: Dunedin, New Zealand

Re: Exporting Dsurface map into GIS

Postby cowzrgr8 » Wed Mar 28, 2018 4:39 pm

Thank you! My hope is to display best trap locations for Blanding's turtles based off trap captures and predicted density (I'm not trying to suggest population density from these maps).

Unfortunately when I run that code the raster looks nothing like the original plot. Do you think using the fxi.contour instead presents similar results to that of the fx.total? I was hoping for more of a color gradient to depict best trap locations, but perhaps the polygons created from fxi.contour will display similar results.

Thank you
cowzrgr8
 
Posts: 3
Joined: Wed Feb 21, 2018 6:31 pm

Next

Return to analysis help

Who is online

Users browsing this forum: No registered users and 20 guests