Rasterize function

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Rasterize function

Jeri Wisman
Hi all -

I am working on a code trying to "rasterize" spatial polygons created by kernelUD but somewhere in the code the values are getting lost and not translating when I created a raster dateframe and try to tie in the polygon lat/lon values into the raster frame. Attached is my code and data.

Thanks!
Jeri Wisman | Masters Candidate
Old Dominion University
Department of Biological Sciences
Mills Godwin Building, Room 312
Norfolk VA 23529 USA

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

COTE_2017_KernelDensity_code_JLW.R (4K) Download Attachment
cote_2017_alldata_1km_16825.csv (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Rasterize function

Michael Sumner-2
On Wed, 18 Apr 2018 at 00:08 Jeri Wisman <[hidden email]> wrote:

> Hi all -
>
> I am working on a code trying to "rasterize" spatial polygons created by
> kernelUD but somewhere in the code the values are getting lost and not
> translating when I created a raster dateframe and try to tie in the polygon
> lat/lon values into the raster frame. Attached is my code and data.
>

Hi, this is not really acceptable as a question to this list, because we
have to go through your script to figure out what you are referring to.

But, my guess is you want the "field" argument to ?rasterize:

> If x is a Spatial*DataFrame, this can be the column name of the variable
to be transferred. If missing, the attribute index is used (i.e.
> numbers from 1 to the number of features).

Your line

r.polys <- rasterize(shp, r)

will put the row number of shp into the appropriate pixel of r.polys, but
you might want to set

r.polys <- rasterize(shp, r, field = "somename")

where "somename" is a member of names(shp).

Just a guess.

Cheers, Mike



> Thanks!
> *Jeri Wisman* | Masters Candidate
> Old Dominion University
> Department of Biological Sciences
> Mills Godwin Building, Room 312
> Norfolk VA 23529 USA
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo