[R-sig-Geo] Converting spatialPointsDataFrame into ppp
Roger Bivand
Roger.Bivand at nhh.no
Fri Sep 16 17:30:47 CEST 2011
On Fri, 16 Sep 2011, GodinA wrote:
> Dear all,
>
> I am new to spatial and point process analysis (as well as R), however most
> of my Ph.D. will rely heavily on these tools *sighs :) I am starting a new
> chapter where I intend to model elasmobranch i.e., shark and skate catch in
> the Northwest Atlantic Canadian waters using point process modeling. I am
> interested in investigating the spatial, temporal, and space–time clustering
> of catch events conditioned upon the distribution of fishing locations.
>
> I have been following the R-sig-geo mails and found many great reading
> suggestions, which were very helpful! Thank you. I would like to do some
> exploratory data analysis on a small subset of my database i.e., solely
> shark catch for the year 2009 (546 observations), but I am running (not
> surprisingly) into errors and warnings!
>
> Would be grateful to anyone's help!
> I am trying to convert my SpatialPointsDataFrame into a ppp. Right now, I
> would just like to make a ppp with "catch" as a mark (this is the catch size
> in kg).
>
>> class(SHK09)
> [1] "SpatialPointsDataFrame"
> attr(,"package")
> [1] "sp"
>
> #SHK09 looks as follow
>> head(as.data.frame(SHK09))
> year month day tripID setID gear NAFO x y kept discard fmonth
> fgear
> 1 2009 8 17 345 16 5 22 55.41 -58.46 0 227 Aug
> GN
> 2 2009 2 1 3 2 1 23 52.36 -51.24 0 450 Feb
> OT
> 3 2009 7 28 296 4 5 9 68.37 -59.34 0 250 Jul
> GN
> 4 2009 9 5 339 29 5 9 68.27 -59.53 0 10 Sep
> GN
> 5 2009 8 28 316 44 5 9 68.38 -64.36 0 1400 Aug
> GN
> 6 2009 9 1 316 49 5 9 69.26 -64.50 0 200 Sep
> GN
> fNAFO t.spp.name t.spp.category elasmo.name
> elasmo.category
> 1 2H GREENLAND HALIBUT 0 SHARKS,DOGFISH (NS)
> 1
> 2 2J GREENLAND HALIBUT 0 SHARK,GREENLAND
> 1
> 3 BaffinIsd GREENLAND HALIBUT 0 SHARK,GREENLAND
> 1
> 4 BaffinIsd GREENLAND HALIBUT 0 SHARK,GREENLAND
> 1
> 5 BaffinIsd GREENLAND HALIBUT 0 SHARK,GREENLAND
> 1
> 6 BaffinIsd GREENLAND HALIBUT 0 SHARK,GREENLAND
> 1
> catch logcatch
> 1 227 5.429346
> 2 450 6.111467
> 3 250 5.525453
> 4 10 2.397895
> 5 1400 7.244942
> 6 200 5.303305
>
> #I tried to do the following as suggested by prior email, however, I get
> this following error message
>> coordinates(SHK09) = ~x+y
> Error in `coordinates<-`(`*tmp*`, value = ~x + y) :
> setting coordinates cannot be done on Spatial objects, where they have
> already been set
Well, that is what you would expect.
>
> #so decided to proceed as follow
>> catch <- as(SHK09["catch"], "ppp")
> Error in as(SHK09["catch"], "ppp") :
> no method or default for coercing "SpatialPointsDataFrame" to "ppp"
>
Did you look at the vignette for the spatstat package about handling
shapefiles? You would note that you need the maptools package, which also
contains the as() coercion functions. They are there, rather than in sp or
spatstat, to try to avoid unwanted dependencies between packages.
However, I doubt whether your data are a marked point process - the catch
positions were decided by someone, not, say, the fish? Have you thought of
trying the bubble() function in sp?
Roger
> Ideas?
> Thank you very much in advance!
>
> ~~Aurelie
>
> Aurelie Cosandey-Godin
> Ph.D. Candidate, Department of Biology, Dalhousie University
> Industrial Graduate Fellow, WWF-Canada
> Email: godina at dal.ca | Web: wormlab.biology.dal.ca
> -----------------------------------------------------------------------------------------------------
> Want to learn more about sharks in Atlantic Canada? Visit ShARCC!
> www.atlanticsharks.org
>
>
>
>
>
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Converting-spatialPointsDataFrame-into-ppp-tp2764866p6801137.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list