Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
spatialspecial [2019/04/15 20:52] qcbs [Exercice 7] |
spatialspecial [2019/04/15 20:58] (current) qcbs [Exercice 7] |
||
|---|---|---|---|
| Line 237: | Line 237: | ||
| \\ | \\ | ||
| \\ | \\ | ||
| - | ===== Using PostgreSQL/PostGIS and GRASS in R ===== | + | ===== Using PostgreSQL/PostGIS, GDAL, sf and GRASS in R ===== |
| {{::spatial_special_r_code.r|Download the R file containing the code for this part of the workshop}} | {{::spatial_special_r_code.r|Download the R file containing the code for this part of the workshop}} | ||
| + | |||
| * Package [[http://cran.r-project.org/web/packages/rpostgis/index.html|rpostgis]] | * Package [[http://cran.r-project.org/web/packages/rpostgis/index.html|rpostgis]] | ||
| Line 269: | Line 270: | ||
| To create a new R Processing script, click on the R logo on the top of the processing toolbox pane, and select Create New R Script. When you are done typing the script, give it an appropriate name and save it in the default folder that opens. | To create a new R Processing script, click on the R logo on the top of the processing toolbox pane, and select Create New R Script. When you are done typing the script, give it an appropriate name and save it in the default folder that opens. | ||
| ===== Exercice 5 ===== | ===== Exercice 5 ===== | ||
| - | Open the Processing Toolbox. Make sure that R is activated as a provider in the Toolbox options. Find "R Scripts > Create a new R script" in the toolbox. Copy and past this Processing/R script that creates 100 points distributed randomly on the earth in the latitude/longitude reference system (EPSG 4326) and that are imported as a QGIS layer. | + | Create a new R script in the toolbox by copying and pasting this Processing/R script that creates 100 points distributed randomly on the earth in the latitude/longitude reference system (EPSG 4326) and that are imported as a QGIS layer. |
| Overlay the result on top of the TM_World_Borders shapefile. | Overlay the result on top of the TM_World_Borders shapefile. | ||
| Line 313: | Line 314: | ||
| #data2=tapply(Layer$new_area,Layer$IHO_Sea,mean) | #data2=tapply(Layer$new_area,Layer$IHO_Sea,mean) | ||
| library('dplyr') | library('dplyr') | ||
| - | library('sf') | ||
| Layer=data.frame(Layer) | Layer=data.frame(Layer) | ||
| data2=Layer%>%group_by(IHO_Sea)%>%summarize(mean=mean(new_area)) | data2=Layer%>%group_by(IHO_Sea)%>%summarize(mean=mean(new_area)) | ||
