[R-sig-Geo] converting shapes to raster

Antonio Silva aolinto.lst at gmail.com
Thu Feb 4 17:49:59 CET 2016


Dear list members



In order to run a niche overlap analysis with nicheOverlap (dismo package)
I need to convert some shapefiles to raster. I dropped a shapefile as
example at https://www.dropbox.com/s/g6o0vfdx7lr34ma/Species1Shape.rar?dl=0

Marine fish abundance data is aggregated in quadrants of 10 x 10 nautical
miles. As I have a coast line some quadrants are cut and also I have a
blank area (land area).

I tried many things like:

shp.frtcost <- readShapePoly("BL10_FRT_COSTEIRA.shp")

plot(shp.frtcost,axes=TRUE,xlim=c(-48,-45),border="grey")

text(coordinates(shp.frtcost),labels=as.character(shp.frtcost at data
$DENS),cex=0.7)

r <- raster(extent(shp.frtcost),nrows=10,ncols=15)

# or raster(extent(shp.frtcost),nrows=10,ncols=15,vals=shp.frtcost at data
$DENS)

r <- rasterize(shp.frtcost,r,fun="first")

plot(shp.frtcost,axes=TRUE,xlim=c(-48,-45),border="grey")

plot(r,add=TRUE)



Shape and raster don't overlay correctly and also I could not pass
densities values to raster.


Limits indicated at extent function do not indicate the limits of my grid.



Thanks for any help.



Best regards


Antônio Olinto Ávila da Silva
Instituto de Pesca (Fisheries Institute)
São Paulo, Brasil

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list