[R-sig-Geo] Deal with multiple factorlevel in one grid square
Alexander.Herr at csiro.au
Alexander.Herr at csiro.au
Thu May 25 02:28:40 CEST 2017
Hiya,
Do you want a raster with attribute information (ie several attributes from your shape file)? You can achieve this with a workflow that uses
raster::extract() to assigne unique IDs of polygon to raster cells
create a RAT for you raster
assign to the unique IDs of raster RAT the attributes of your polygon unique IDs (many to one relationship) with something like merge() or functions in libraries like diplyr or data.table
Cheers
Herry
-----Original Message-----
From: R-sig-Geo [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of Patrick Schratz
Sent: Wednesday, 24 May 2017 10:48 PM
To: Michael Sumner <mdsumner at gmail.com>; Miriam Püts <miriam.puets at thuenen.de>
Cc: r-sig-geo at r-project.org
Subject: Re: [R-sig-Geo] Deal with multiple factorlevel in one grid square
Do you want to do what is called “zonal statistics” in ArcGIS with “majority" option?
You may check out this SO question and try the “mode” function within raster::extract() - maybe it does what you need.
(I’m also unsure if I understand the question correctly)
Cheers, Pat
PhD Student at Department of Geography - GIScience group Friedrich-Schiller-University Jena, Germany
Tel.: +49-3641-9-48973
Web: https://pat-s.github.io
On 24. May 2017, 12:35 +0200, Miriam Püts <miriam.puets at thuenen.de>, wrote:
> Hi Mike,
>
> I will try to explain it a bit more in detail. Maybe it is easier to understand if I start from the end. In the end I would like to have an ASCII file to read into Ecospace, which has the same extensions and coordinates as other files I already created. This ASCII should contain information about the sediment type within each predefined cell. To create this ASCII file I have a shape file with the polygons representing the sediment type and my grid which I applied to other variables to have the same extend. Now I would like to create a grid containing the information on sediment. Here, per grid cell the sediment type which covers the most of the cell should be defined and connected with the coordinates for the grid cell.
>
> I hope this makes it more clear...
>
>
> <°)))>< >°)))>< >°)))>< >°)))><
>
> Miriam Püts
> Marine Lebende Ressourcen/ Marine Living Resources Thünen-Institut für
> Seefischerei/ Thünen Institute of Sea fisheries Palmaille 9
> 22767 Hamburg (Germany)
>
> Tel: +49 40 38905-105
> Mail: miriam.puets at thuenen.de
>
>
> Von: "Michael Sumner" <mdsumner at gmail.com
> An: "Miriam Püts" <miriam.puets at thuenen.de>, r-sig-geo at r-project.org
> Gesendet: Mittwoch, 24. Mai 2017 11:55:14
> Betreff: Re: [R-sig-Geo] Deal with multiple factorlevel in one grid
> square
>
>
>
> raster::extract(grid, poly, weights = TRUE) is a start. It returns a list which is painful to deal with at first, but can be collected into one data frame for standard summarizing.
>
> I'm still a bit confused about whether you want an estimate of a cell overlap in a polygon or something else.
>
> Cheers, Mike
> On Wed, 24 May 2017, 17:12 Miriam Püts < [ mailto:miriam.puets at thuenen.de | miriam.puets at thuenen.de ] > wrote:
>
>
> Hi everyone,
>
> I have the following problem: I have a personalized grid and a shape file with polygons representing sediment types. Now I would like to apply this grid to the Polygons to identify the sediment type most common within each grid. I tried it with rasterize, but here I can only chose last or first. Die you have any suggestions how I might get the sediment type for each raster cell?
>
> Thank you for your help!
>
> <°)))>< >°)))>< >°)))>< >°)))><
>
> Miriam Püts
> Marine Lebende Ressourcen/ Marine Living Resources Thünen-Institut für
> Seefischerei/ Thünen Institute of Sea fisheries Palmaille 9
> 22767 Hamburg (Germany)
>
> Tel: +49 40 38905-105
> Mail: [ mailto:miriam.puets at thuenen.de | miriam.puets at thuenen.de ]
>
> _______________________________________________
> R-sig-Geo mailing list
> [ mailto:R-sig-Geo at r-project.org | R-sig-Geo at r-project.org ] [
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo |
> 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
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list