[R] using shapefiles in adehabitat/ converting shapefile to spatial pixel data frame
Michael Sumner
mdsumner at gmail.com
Fri Feb 24 01:36:38 CET 2012
The error you are getting says that the coordinates provided do not
define a regular grid (within the tolerance allowed).
Are the points in your CSV file really a regular grid, or do they
represent a surface by way of irregular points? You could check this
manually by plotting:
depth<-read.csv("depthmap.csv")
plot(depth$x, depth$y)
(Otherwise, this is a text file - csv is "comma separated values" and
has nothing to do with an ESRI Shapefile. )
If your points really are a regular grid, or "near enough" to one you
can use the tolerance argument to SpatialPixels, see
library(sp)
?SpatialPixels
vignette("sp")
for some introduction to these data structures and tools.
Also, R-Sig-Geo is a better target list for these topics so please use that.
Cheers, Mike.
On Thu, Feb 23, 2012 at 11:06 PM, Soanes, Louise
<Louise.Soanes at liverpool.ac.uk> wrote:
> Hello
> I wonder if anybody can help,
> I am using the package adehabitatHR to estimate the potential distribution of a species using the command "domain"
>
> In the example given in the AdehabitatHS manual a map containing elevation information is loaded (class= spatial pixels data frame) as well as the GPS points of the animals being tracked, these are then plotted on each other and estimation of habitat suitability performed.
>
> I have a map containing sea depth information in the form of a shapefile which I want to relate to some GPS tracks I have, however I believe that the shapefile with my sea depth information has to be of the class spatial pixels data frame before I can perform many of the analysis in AdehabitatHS,
>
> I have tried converting the shapefile to a spatial pixel data frame using the sp package by exporting the data from the attribute table in my depth shapefile then importing it into R as a csv file (see my attempts below)
>
>>depth<-read.csv("depthmap.csv")
>>pts = depth[c("x", "y")]
>>y = SpatialPixels(SpatialPoints(pts))
>
> suggested tolerance minimum: 1
> Error in points2grid(points, tolerance, round) :
> dimension 1 : coordinate intervals are not constant
>
>> depth<-read.csv("a.csv")
>> coordinates(depth) <- c("x", "y")
>> points2grid(depth)
> suggested tolerance minimum: 1
> Error in points2grid(depth) :
> dimension 1 : coordinate intervals are not constant
>
> Bur these do not seem to work, does anyone have any ideas?
>
> Many thanks
> Louise Soanes
>
>
> School of Environmental Sciences
> University of Liverpool
> Brownlow Hill
> L69 3GP
>
> http://sites.google.com/site/puffinislandseabirdresearch/
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsumner at gmail.com
More information about the R-help
mailing list