Skip to content

Commit

Permalink
adding files
Browse files Browse the repository at this point in the history
  • Loading branch information
havatv committed Feb 16, 2020
1 parent 4f5c1c3 commit c2e531f
Show file tree
Hide file tree
Showing 143 changed files with 185 additions and 195 deletions.
22 changes: 0 additions & 22 deletions collections/qgis-rscripts3/rscripts/Distance.rsx

This file was deleted.

1 change: 0 additions & 1 deletion collections/qgis-rscripts3/rscripts/Distance.rsx.help

This file was deleted.

9 changes: 0 additions & 9 deletions collections/qgis-rscripts3/rscripts/G_function.rsx

This file was deleted.

12 changes: 0 additions & 12 deletions collections/qgis-rscripts3/rscripts/Minimum_convex_polygon.rsx

This file was deleted.

10 changes: 0 additions & 10 deletions collections/qgis-rscripts3/rscripts/Random_sampling_grid.rsx

This file was deleted.

10 changes: 0 additions & 10 deletions collections/qgis-rscripts3/rscripts/Regular_sampling_grid.rsx

This file was deleted.

43 changes: 0 additions & 43 deletions collections/qgis-rscripts3/rscripts/Tobler.rsx

This file was deleted.

36 changes: 21 additions & 15 deletions collections/qgis_rscripts/rscripts/Distance.rsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
##Basic statistics=group
##Layer1=vector
##Layer2=vector
##Field=Field Layer1
##output= output vector
library(geosphere)
library(rgeos)
line<-gLineMerge(Layer2, byid=FALSE, id = NULL)
x<-coordinates(Layer1)
X<-dist2Line(x, line, distfun=distHaversine)
matrix<-as.matrix(X[,2:3])
X<-cbind(X, as.data.frame(Layer1[[Field]]))
result<-SpatialPointsDataFrame(matrix, as.data.frame(X, row.names=NULL))
proj4string(Layer1)->crs
proj4string(result)<-crs
output<-result
##Input_Point_Layer=vector
##Line_Layer=vector
##ID_Field=Field Input_Point_Layer
##Nearest=output vector
library(geosphere)
library(rgeos)

# Remove the z and m dimensions
PointsXY=st_zm(Input_Point_Layer)
LinesXY=st_zm(Line_Layer)
# Change format
SpatPointsXY=as(PointsXY, "Spatial")
SpatLinesXY=as(LinesXY, "Spatial")

line=gLineMerge(SpatLinesXY, byid=FALSE, id = NULL)
x=coordinates(SpatPointsXY)
X=dist2Line(x, line, distfun=distHaversine)
matrix=as.matrix(X[,2:3])
X=cbind(X, as.data.frame(SpatPointsXY[[ID_Field]]))
result=SpatialPointsDataFrame(matrix, as.data.frame(X, row.names=NULL))
Nearest=st_set_crs(st_as_sf(result),st_crs(Input_Point_Layer))
2 changes: 1 addition & 1 deletion collections/qgis_rscripts/rscripts/Distance.rsx.help
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Layer2": "a line", "ALG_DESC": "This script calculates the distance between two geometries: a line and points.", "ALG_CREATOR": "JEANDENANS L.", "Layer1": "a set of data (points)", "Field": "identification of points", "ALG_HELP_CREATOR": "JEANDENANS L.", "output": "a shapfile with points and the distance."}
{"Line_Layer": "A line layer", "ALG_DESC": "This script calculates the distance from points in a point layer to the nearest line in a line layer. Coordinates have to be in the latitude / longitude ranges.", "ALG_CREATOR": "QGIS community", "Input_Point_Layer": "a set of points (lat/lon)", "Field": "ID field for the points", "ALG_HELP_CREATOR": "QGIS community", "Nearest": "A point layer (the nearest point on the line for each input point) with the distance."}
3 changes: 2 additions & 1 deletion collections/qgis_rscripts/rscripts/G_function.rsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
##showplots
library("maptools")
library("spatstat")
ppp=as(as(Layer, "SpatialPoints"),"ppp")
#ppp=as(as(Layer, "SpatialPoints"),"ppp")
ppp=as(as(Layer, "Spatial"),"ppp")
plot(envelope(ppp, Gest, nsim=Nsim))
19 changes: 15 additions & 4 deletions collections/qgis_rscripts/rscripts/Kernel_density_estimation.rsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
##Layer1=vector
##Layer2=vector
##methode=number 1
##Output= output raster
##Output=output raster
library(rgdal)
library(surveillance)
library(maptools)
Expand Down Expand Up @@ -103,8 +103,18 @@ ZNA = f0$estimate,
H = fhat$H,
W = fhat$W)
}
points<-coordinates(Layer1)
polygon<-Layer2

#points<-coordinates(Layer1)
spatpoints = as(Layer1, "Spatial")
points<-coordinates(spatpoints)
>print("---points-----------------------------------------------------")
>str(points)

#polygon<-Layer2
polygon<-as(Layer2, "Spatial")
>print("---polygon-----------------------------------------------------")
>str(polygon)

if(methode==0){
estimate <- sKDE(U = points, polygon = polygon,
optimal=TRUE, parallel = FALSE)
Expand Down Expand Up @@ -135,6 +145,7 @@ coordinates(Grille)=c("X","Y")
gridded(Grille)<-TRUE
library(raster)
result<-raster(Grille,layer=1, values=TRUE)
proj4string(Layer1)->crs
#proj4string(Layer1)->crs
proj4string(spatpoints)->crs
proj4string(result)<-crs
Output=result
9 changes: 7 additions & 2 deletions collections/qgis_rscripts/rscripts/Minimum_convex_polygon.rsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
##Home Range Analysis=group
##Layer=vector
##Percentage=number 10
##Percentage=number 90
##Field=Field Layer
##Home_ranges=Output vector
library(adehabitatHR)
Home_ranges<-mcp(Layer[,Field],percent=Percentage)

SpatialLayer = as(Layer, "Spatial")
HR<-mcp(SpatialLayer[,Field],percent=Percentage)
Home_ranges<-st_as_sf(HR)


Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
##Point pattern analysis=group
##Layer=vector point
##Simulations=number 100
##Optional_plot_name=string
##Plot_name=string 'K function'
##showplots
library(spatstat)
library(maptools)
sp <- as(Layer, "SpatialPoints")

sp <- as(Layer, "Spatial")
sp <- as(sp, "ppp")

e <- envelope(sp, Kest, nsim = Simulations)
>e
plot(e, main = Optional_plot_name)
plot(e, main = Plot_name)

3 changes: 2 additions & 1 deletion collections/qgis_rscripts/rscripts/Quadrat_analysis.rsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
##showplots
library("maptools")
library("spatstat")
ppp=as(as(Layer, "SpatialPoints"),"ppp")
#ppp=as(as(Layer, "SpatialPoints"),"ppp")
ppp=as(as(Layer, "Spatial"),"ppp")
qc=quadratcount(ppp)
plot(Layer)
plot(qc, add=TRUE)
Expand Down
10 changes: 7 additions & 3 deletions collections/qgis_rscripts/rscripts/Random_sampling_grid.rsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
##Point pattern analysis=group
##Layer=vector
##Layer=vector polygon
##Size=number 10
##Output= output vector
pts=spsample(Layer,Size,type="random")
Output=SpatialPointsDataFrame(pts, as.data.frame(pts))
spatpoly = as(Layer, "Spatial")

pts=spsample(spatpoly,Size,type="random")
spdf=SpatialPointsDataFrame(pts, as.data.frame(pts))

Output=st_as_sf(spdf)
10 changes: 7 additions & 3 deletions collections/qgis_rscripts/rscripts/Regular_sampling_grid.rsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
##Point pattern analysis=group
##Layer=vector
##Layer=vector polygon
##Size=number 10
##Output= output vector
pts=spsample(Layer,Size,type="regular")
Output=SpatialPointsDataFrame(pts, as.data.frame(pts))
spatpoly = as(Layer, "Spatial")

pts=spsample(spatpoly,Size,type="regular")
spdf=SpatialPointsDataFrame(pts, as.data.frame(pts))

Output=st_as_sf(spdf)
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
##Output=output vector
library("spatstat")
library("maptools")
proj4string(Layer)->crs
spatpoints = as(Layer,"SpatialPoints")

crs=st_crs(Layer)
spatpoints = as(Layer, "Spatial")

ripras=ripras(as(spatpoints,"ppp"))
polyg=as(ripras,"SpatialPolygons")
Output1= SpatialPolygonsDataFrame(polyg, data.frame(1))
proj4string(Output1)<-crs
Output<-Output1
SPDF=SpatialPolygonsDataFrame(polyg, data.frame(1))

Output=st_set_crs(st_as_sf(SPDF), crs)
40 changes: 27 additions & 13 deletions collections/qgis_rscripts/rscripts/Tobler.rsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,43 @@
##Basic statistics=group
##Layer=raster
##x_depart= number 0.1
##y_depart= number 0.1
##x_arrivee= number 0.1
##y_arrivee= number 1
##DEM_Layer=raster
# ##Start=point
##x_start=number 10.0
##y_start=number 60.0
# ##Destination=point
##x_destination=number 11.0
##y_destination=number 59.0
##Output= output vector
library(gdistance)
library(rgdal)
datas<-raster(Layer)

dem=raster(DEM_Layer)

heightDiff <-function(x)(x[2] - x[1])
hd <- transition(datas,heightDiff,8)#packages gdistance
hd <- transition(dem,heightDiff,8)#packages gdistance
slope <- geoCorrection(hd, scl=FALSE)#packages gdistance
adj <- adjacent(x = datas, cells = 1:ncell(datas),pairs=TRUE ,directions=8) #packages raster
adj <- adjacent(x=dem, cells=1:ncell(dem), pairs=TRUE, directions=8) #packages raster
speed <- slope
speed[adj] <- exp(-3.5 * abs(slope[adj])+0.05)
speed<-geoCorrection(speed) #packages gdistance
>print("--speed------------------------------------------------------")
>str(speed)

Ax=x_depart
Ay=y_depart
Bx=x_arrivee
By=y_arrivee
Ax=x_start
Ay=y_start
Bx=x_destination
By=y_destination

c1<-c(Ax, Ay)
#c1=Start
>print("--c1------------------------------------------------------")
>str(c1)

c2<-c(Bx, By)
#c2 = Destination
>print("---c2-----------------------------------------------")
>str(c2)

sPath1 <-shortestPath(speed, c1, c2,output="SpatialLines")
Output=SpatialLinesDataFrame(sPath1, data=as.data.frame(c(1:length(sPath1))), match.ID = F)
sldf=SpatialLinesDataFrame(sPath1, data=as.data.frame(c(1:length(sPath1))), match.ID = F)
Output=st_as_sf(sldf)

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions collections/qgis_rscripts2/rscripts/Distance.rsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
##Basic statistics=group
##Layer1=vector
##Layer2=vector
##Field=Field Layer1
##output= output vector
library(geosphere)
library(rgeos)
line<-gLineMerge(Layer2, byid=FALSE, id = NULL)
x<-coordinates(Layer1)
X<-dist2Line(x, line, distfun=distHaversine)
matrix<-as.matrix(X[,2:3])
X<-cbind(X, as.data.frame(Layer1[[Field]]))
result<-SpatialPointsDataFrame(matrix, as.data.frame(X, row.names=NULL))
proj4string(Layer1)->crs
proj4string(result)<-crs
output<-result
1 change: 1 addition & 0 deletions collections/qgis_rscripts2/rscripts/Distance.rsx.help
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Layer2": "a line", "ALG_DESC": "This script calculates the distance between two geometries: a line and points.", "ALG_CREATOR": "JEANDENANS L.", "Layer1": "a set of data (points)", "Field": "identification of points", "ALG_HELP_CREATOR": "JEANDENANS L.", "output": "a shapfile with points and the distance."}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
##Layer=vector point
##Nsim=number 10
##showplots

library("maptools")
library("spatstat")

ppp=as(as(Layer, "Spatial"),"ppp")
ppp=as(as(Layer, "SpatialPoints"),"ppp")
plot(envelope(ppp, Gest, nsim=Nsim))
Loading

0 comments on commit c2e531f

Please sign in to comment.