[R-sig-Geo] Converting image to asc
Kévin Morelle
Kevin.Morelle at ulg.ac.be
Mon Jan 23 10:11:41 CET 2012
Dear list members,
I'm facing the following error when I want to convert an image object
(obtained from the density function of the SpatStat package) into a asc
object using the im2asc function of adehabitat:
mais.asc <- im2asc(mais.dens)
Erreur dans im2asc(mais.dens) :
the grid cellsize should be identical for both X and Y directions.
I previously delimited my study area by a polygon, could it be the
external grid cells (cut by that polygon) that would give this error
(because leading to non-square cells...)?
Below, my code more detailed.
Thanks for any help,
Regards,
Kevin
# Maize fied for the whole region
-------------------------------------------
mais <- readShapePoly("D:/Carto/Landscape/Mais_2009.shp")
# Limiting to my study area (W.sp)
-----------------------------------------------
mais.ze <- crop (mais,W.sp)
# Deriving density of maize field throught the density function
------------------------------------------------------------------------------------
#1. find centroid of maize field
mais.ps <- SpatialPolygons2PolySet(mais.ze)
mais.centroids <- calcCentroid(mais.ps, rollup=1)
mais.df <- as.data.frame(mais.centroids)
#2. convert to point pattern class+apply density function
mais.ppp <- ppp (mais.df$X, mais.df$Y, window = W2)
mais.dens <- density(mais.ppp, sigma=1000)
#3. convert mais.dens to asc for ENFA anaysis (in adehabitat)
mais.asc <- as.asc(mais.mx)
=>Erreur dans im2asc(mais.dens) :
the grid cellsize should be identical for both X and Y directions.
--
Morelle Kevin
Université de Liège - Gembloux Agro-Bio Tech
Unité de Gestion des Ressources forestières et des Milieux naturels
--------
University of Liège - Gembloux Agro-Bio Tech
Unit of Forest and Nature Management
--------
2, Passage des Déportés
B-5030 GEMBLOUX
BELGIQUE
Tél : + 32 (0)81 62.22.14
Fax : + 32 (0)81 62.23.01
E-mail : kevin.morelle at ulg.ac.be
Web : http://www.fsagx.ac.be/gf/
More information about the R-sig-Geo
mailing list