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: miriam.puets at thuenen.de
Deal with multiple factorlevel in one grid square
7 messages · Miriam Püts, Michael Sumner, Patrick Schratz +1 more
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 <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: miriam.puets at thuenen.de
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org 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]]
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]]
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
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
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
5 days later
Hi all, @Pat: yes, that is almost what I need. If I would do it in ArcGIS I would use Polygon to raster (with a second raster as reference) and then choose majority. there a way to do it in R? If I use raster::extract() I would extract data from the raster object for the locations of other spatial data, but I need spatial data for the raster object... Cheers, Miriam <?)))>< >?)))>< >?)))>< >?)))>< 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 ----- Urspr?ngliche Mail ----- Von: "Alexander Herr" <Alexander.Herr at csiro.au> An: "patrick schratz" <patrick.schratz at gmail.com>, mdsumner at gmail.com, "miriam puets" <miriam.puets at thuenen.de> CC: r-sig-geo at r-project.org Gesendet: Donnerstag, 25. Mai 2017 02:28:40 Betreff: RE: [R-sig-Geo] Deal with multiple factorlevel in one grid square 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
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
maybe fasterize? Only on GitHub, and requires sf. (Mixing raster and sf is piece-meal, but very doable). https://github.com/ecohealthalliance/fasterize
On Tue, 30 May 2017, 21:55 Miriam P?ts <miriam.puets at thuenen.de> wrote:
Hi all, @Pat: yes, that is almost what I need. If I would do it in ArcGIS I would use Polygon to raster (with a second raster as reference) and then choose majority. there a way to do it in R? If I use raster::extract() I would extract data from the raster object for the locations of other spatial data, but I need spatial data for the raster object... Cheers, Miriam <?)))>< >?)))>< >?)))>< >?)))>< 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 ----- Urspr?ngliche Mail ----- Von: "Alexander Herr" <Alexander.Herr at csiro.au> An: "patrick schratz" <patrick.schratz at gmail.com>, mdsumner at gmail.com, "miriam puets" <miriam.puets at thuenen.de> CC: r-sig-geo at r-project.org Gesendet: Donnerstag, 25. Mai 2017 02:28:40 Betreff: RE: [R-sig-Geo] Deal with multiple factorlevel in one grid square 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
Dr. Michael Sumner Software and Database Engineer Australian Antarctic Division 203 Channel Highway Kingston Tasmania 7050 Australia [[alternative HTML version deleted]]