Skip to content

projecting GIS coordinates for analysis with spatstat package

3 messages · Markus Weisner, David Winsemius

#
https://answers.google.com/answers/threadview?id=577262
On Mar 1, 2009, at 3:22 PM, Markus Weisner wrote:

            
#
With a conversion strategy in hand, you could relabel the results of a  
density map:

library(MASS)
mapfit <- kde2d(datat$xcoord, data$ycoord)
contour(mapfit)

The aspect ratio is "off" with this plot and the spatialstats package  
give you a less distorted map. On my Mac I can resize the quartz  
window and the lebeling remains in the proper aspect, but I don't know  
if that works for all other platforms.

So you could then multiply your ycoord by 69.10537434873548 and your x  
coord by 45.23874340706528 and get miles (from Greenwich, UK to the  
East and the Equator to the South) as your axis labels

mapdat$xmiles <- mapdat$xcoord*45.23874340706528
  mapdat$ymiles <- mapdat$ycoord*69.10537434873548
  mapfit.mi <- kde2d(mapdat$xmiles, mapdat$ymiles)
  contour(mapfit.mi)

If the conversion worked then your coordinates have about a 12 mile E- 
W range and a 6-7 mile N-S range, correct? When I do the same sort of  
on a renamed dataset, data2:

 > data2$ymiles <- data2$ycoord*69.10537434873548
 > data2$xmiles <- data2$xcoord*45.23874340706528
 > coordinates(data2) <- c("xmiles","ymiles")
 > ppp_data = as(data2["itype"], "ppp")
Warning message:
In ppp(cc[, 1], cc[, 2], window = W, marks = marks) :
   data contain duplicated points
 > density_data = density.ppp(ppp_data)
 > plot(density_data, col=brewer.pal(9, "Reds"))

I get a maximal density of 6 per <something> .  6 events per square  
mile certainly looks like a sensible estimate for that datatset. All  
you are missing now are the axis labels or perhaps an overlay of a  
local map. Sarkar's book may be helpful for that purpose.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Event.per.sq.mile.pdf
Type: application/pdf
Size: 110759 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090301/0254181a/attachment-0003.pdf>
-------------- next part --------------

--  
David Winsemius
On Mar 1, 2009, at 4:20 PM, David Winsemius wrote: