Jump to content


Photo

Exporting FlightR's plot_util_distr to ArcGIS

FlightR ArcGIS kernel isopleth utilization distribution

Best Answer Eldar , 25 January 2017 - 07:04 AM

  Hi Jason,

I have changed the function and it produces spatialpoygonsdataframe now. So update the package to github version and try

library(rgdal)
tmp<-plot_util_distr(Result)
writeOGR(tmp$res_buffers, ".", "result", driver="ESRI Shapefile")
 

  Hope this helps,

  Cheers,

    Eldar

Go to the full post


  • Please log in to reply
7 replies to this topic

#1 captaingriz

captaingriz
  • Society Members
  • 8 posts
  • Norwich, VT,
  • United States

Posted 24 January 2017 - 10:04 AM

#Package FLightR version 0.4.6
 
I have been using FlightR to analyze geolocator data for Grasshopper Sparrows, and I have been really pleased. I am wondering, however, if there is a way to export the kernel density results from the plot_util_distr command into ArcGIS. 
 
Exporting the median (w/ 95% CRI) lat/long values for use in ArcGIS (via "add XY data") is easy enough: 
write.csv(run.particle.filter.Results$Results$Quantiles,"GIS_import.csv")
 
But what about exporting the utilization distributions to ArcGIS for replotting and further manipulation?
 
plot_util_distr(particle.filter.results, dates=data.frame(as.POSIXct('2015-12-01'), as.POSIXct('2016-02-01')),
                percentiles=c(0.5,0.9), save.options = list(filename="winter.pdf"))
 
I've tried saving or converting the plot object to a SpatialPolygonsDataFrame but I don't know of a way to coerce a 'list' into a SpatialPolygonsDataFrame.
 
I suppose that I could draw the winter.pdf file with a blank background (then geo-reference the winter.pdf file) and bring that file into ArcGIS with the georeference toolbar. That would not be a parsimonious option for my 30+ birds and I still couldn't manipulate the results in ArcGIS (I could only view them).
Thanks for your help and suggestions everyone,
Jason
 
 


#2 Eldar

Eldar
  • General Members
  • 47 posts
  • Netherlands,
  • Netherlands

Posted 25 January 2017 - 07:04 AM   Best Answer

  Hi Jason,

I have changed the function and it produces spatialpoygonsdataframe now. So update the package to github version and try

library(rgdal)
tmp<-plot_util_distr(Result)
writeOGR(tmp$res_buffers, ".", "result", driver="ESRI Shapefile")
 

  Hope this helps,

  Cheers,

    Eldar



#3 captaingriz

captaingriz
  • Society Members
  • 8 posts
  • Norwich, VT,
  • United States

Posted 25 January 2017 - 09:43 AM

Outstanding! That makes my computational life so much easier.

Thanks Eldar,
Jason



#4 captaingriz

captaingriz
  • Society Members
  • 8 posts
  • Norwich, VT,
  • United States

Posted 06 February 2017 - 09:43 AM

I'm getting a new-to-me error message now with the plot_util_distr and map.FLightR.ggmap commands using the newly-updated version of FLightR:

 

devtools::install_github('eldarrak/FLightR')

 

plot_util_distr(Result)

or

map.FLightR.ggmap(Result) 

 

produce the same error

Error in get("f", environment(CoordMap$train)) : object 'f' not found

 

Tried installing newest version of ggplot and ggmap

devtools::install_github("dkahle/ggmap",force=T) 
devtools::install_github("hadley/ggplot2",force=T)
 
Tried installing development version of those packages using
library(devtools)
dev_mode(on=T)

 

No difference.

This appears to be a known issue with ggmap

https://github.com/d...gmap/issues/144

 

Solution: reinstall version 2.6.1, don't know why this fixes it.

library(versions)
available.versions('ggmap')
installed.versions('ggmap')
install.versions('ggmap', '2.6.1')


#5 Eldar

Eldar
  • General Members
  • 47 posts
  • Netherlands,
  • Netherlands

Posted 06 February 2017 - 09:53 AM

  I cannot reproduce it. Will have a look if you send me the result object that causes the error.

   Eldar


  • captaingriz likes this

#6 captaingriz

captaingriz
  • Society Members
  • 8 posts
  • Norwich, VT,
  • United States

Posted 06 February 2017 - 02:19 PM

Eldar, Definitely not a fault with FLightR but thank you very much for the offer of help. I think this is a Grid x ggmap x ggplot2 problem that I have worked around somehow. I have found that manually loading the grid graphics engine (library(grid)), before running the ggmap command, often makes these errors go away. I have no idea why. Problem solved for now.



#7 Eldar

Eldar
  • General Members
  • 47 posts
  • Netherlands,
  • Netherlands

Posted 06 February 2017 - 02:51 PM

  Good, I have submitted suggestion for correction of this issue to ggmap. Will see when they will reply. For now one should either type

library('grid')

before using ggmap related functions or install my ggmap version

devtools::install_github('eldarrak/ggmap')

  Thanks for solving the issue.



#8 Hendrik

Hendrik
  • General Members
  • 14 posts
  • Auckland,
  • New Zealand

Posted 19 February 2017 - 11:40 PM

Dear Eldar,

 

I have a possibly related error message when running the plotting function:

 

map.FLightR.ggmap(Result)
Error: longitude of center must be between -180 and 180 degrees. note ggmap uses lon/lat, not lat/lon.
In addition: Warning message:
In min(Result$Results$Quantiles$Medianlon[twilights.index][Result$Results$Quantiles$Medianlon[twilights.index] >  :
  no non-missing arguments to min; returning Inf

 

 

Interestingly this only happens when using certain grid boundaries for the spatial extent.

So far I could trigger the error as soon as I extended the right boundary above lon -160 e.g.,

 

Grid<-make.grid(left=160, bottom=-80, right=-140, top=-10,
                distance.from.land.allowed.to.use=c(-Inf, Inf),
                distance.from.land.allowed.to.stay=c(-Inf, Inf))

 

will trigger it while

 

Grid<-make.grid(left=160, bottom=-80, right=-160, top=-10,
                distance.from.land.allowed.to.use=c(-Inf, Inf),
                distance.from.land.allowed.to.stay=c(-Inf, Inf))

 

does not produce an error.

UPDATE: It actually seems only to occur when a position with longitude >-160 (e.g., -140) is plotted!

 

 

My feel is that this is also a ggmap related issue.

 

I don't think it is related as it is a sp error, but I get an error message when running plot_util_distr:

 

plot_util_distr(Result,
+                 dates=data.frame(as.POSIXct('2016-03-03'), as.POSIXct('2016-08-07')),
+                 add.scale.bar=TRUE, percentiles=0.5)
function will plot 308 twilights
Error in sp::CRS(aeqd) : major axis or radius = 0 or not given

 

I am very thankful about your comments on this.

 

All the best and keep up the great work Eldar!,

 

Hendrik







Also tagged with one or more of these keywords: FlightR, ArcGIS, kernel, isopleth, utilization distribution

0 user(s) are reading this topic

0 members(s), 0 guests(s) and 0 anonymous member(s)