Hi folks,

Long-time lurker, first time poster here. I have a conundrum that
perhaps you might have come across. I'm getting an error when I try to
compile some of my R spatial code:

Error in write.asciigrid(xx2_res["NPHS"], newHSmap_asc, attr = 1,
na.value = -9999) : 
  Asciigrid does not support grids with non-square cells

This is telling me that the xy grid I'm working with is using cells that
aren't exactly square. This is very curious, so I checked out the
structure of the object I'm working with: 


> str(xx2_res)
Formal class 'SpatialGridDataFrame' [package "sp"] with 6 slots
  ..@ data       :'data.frame': 480760 obs. of  9 variables:
  .. ..$ v      : num [1:480760] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ paID   : num [1:480760] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ patchD : num [1:480760] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ NP1    : logi [1:480760] NA NA NA NA NA NA ...
  .. ..$ preNP2 : logi [1:480760] NA NA NA NA NA NA ...
  .. ..$ NP2    : num [1:480760] NA NA NA NA NA NA NA NA NA NA ...
  .. ..$ out2   : num [1:480760] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ HSvalue: num [1:480760] 0 0 0 0 0 0 0 0 0 0 ...
  .. ..$ NPHS   : num [1:480760] 0 0 0 0 0 0 0 0 0 0 ...
  ..@ grid       :Formal class 'GridTopology' [package "sp"] with 3
slots
  .. .. ..@ cellcentre.offset: Named num [1:2] 780952 363416
  .. .. .. ..- attr(*, "names")= chr [1:2] "s1" "s2"
  .. .. ..@ cellsize         : Named num [1:2] 500 500
  .. .. .. ..- attr(*, "names")= chr [1:2] "s1" "s2"
  .. .. ..@ cells.dim        : Named int [1:2] 808 595
  .. .. .. ..- attr(*, "names")= chr [1:2] "s1" "s2"
  ..@ grid.index : int(0) 
  ..@ coords     : num [1:2, 1:2] 780952 1184452 363416 660416
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : NULL
  .. .. ..$ : chr [1:2] "s1" "s2"
  ..@ bbox       : num [1:2, 1:2] 780702 363166 1184702 660666
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:2] "s1" "s2"
  .. .. ..$ : chr [1:2] "min" "max"
  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
  .. .. ..@ projargs: chr NA


Or, the cell sizes extracted from that structure above:

> print(slot(slot(xx2_res, "grid"), "cellsize"), digits=20)
 s1  s2 
500 500 


Having both s1 and s2 being equal in the cell size slot indicates a
square cell, as was shown in advice given in a similar problem in this
usergroup. When I searched this error elsewhere and here, the problem
tends to be that there is a "fuzziness" in the cell size numbers (way
down in the decimals, like 500.000000002 x 500.000000000004) that is
solved by rounding or forcing. That does not appear to be the case in my
issue.

Have any of you come across this error before? Is there something
obvious I'm missing here, perhaps?

Thanks for any assistance!

Cheers,
Josh

Joshua Mailhiot
Aquatic Science Biologist
Pacific Biological Station 
Fisheries and Oceans Canada
3190 Hammond Bay Road, Nanaimo, BC V9T 6N7
Joshua.Mailhiot@dfo-mpo.gc.ca
Telephone: 250-729-8381

	[[alternative HTML version deleted]]

