This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(sf) | |
| library(raster) | |
| library(dplyr) | |
| library(tidyr) | |
| waffle <- function(f, the_stats, the_res = 10000) { | |
| ## Create Raster | |
| r <- raster(extent(f)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- NOTE : | |
| -- This gist has two separate parts : one for the geometry generator, one for the filling color | |
| -- inputs : lines, slope raster | |
| -- STEP 1/2 - On geometry generator, set this expression to have interpolated points : | |
| collect_geometries( | |
| array_foreach( | |
| generate_series(0, length($geometry), 5), -- we add lines every 5 meters | |
| line_interpolate_point($geometry, @element) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Use symbology > centroid > geometry generator | |
| # Main spikes : | |
| with_variable( | |
| 'coords', | |
| array(x(centroid($geometry)),y(centroid($geometry))), | |
| make_triangle( | |
| make_point(@coords[0] - 8000, | |
| @coords[1]), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| from PyQt5.QtCore import QCoreApplication, QVariant | |
| from qgis.core import (QgsVectorLayer, QgsFields, QgsField, QgsProject,QgsLayoutItemMap,QgsFeature,QgsGeometry,QgsCoordinateReferenceSystem, | |
| QgsProcessing, | |
| QgsFeatureSink, | |
| QgsProcessingAlgorithm, | |
| QgsProcessingParameterFeatureSource, | |
| QgsProcessingParameterFeatureSink) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def getCompositionExtents(crsCode=2154) : | |
| # layer | |
| vl = QgsVectorLayer("Polygon?crs=EPSG:%s"%(crsCode), "Extent Polygons", "memory") | |
| # defining CRS | |
| crs = vl.crs() | |
| crs.createFromId(crsCode) | |
| vl.setCrs(crs) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(rgdal) | |
| library(maptools) | |
| library(spdep) | |
| library(bezier) | |
| library(rgeos) | |
| bati = readOGR("D:/DATAS/APUR", "EMPRISE_BATIE") | |
| coords.total = coordinates(bati) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| creerGrille = function(pol, size=50000) { | |
| r = raster(extend(extent(pol), size)); res(r) = size; r[]=1 | |
| grille = rasterToPolygons(r) | |
| grille = grille[which(gIntersects(grille, pol, byid=T)), ] | |
| grille = grille[-which(gTouches(grille, reg, byid=T)), ] | |
| return(grille) | |
| } | |
| extractFrequencies = function(grille, r, values) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # code used for the following map : http://datagistips.blogspot.fr/ | |
| library(raster) | |
| library(rgdal) | |
| library(rgeos) | |
| clc = raster("DATAS/CLC12_RIDF_RGF.tif") # here is the 200m Corine Land Cover GeoTiff | |
| reg = readOGR("DATAS", "idf_geofla") # ile de france GéoFla Departments | |
| # RECLASS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(rgdal) | |
| library(spatstat) | |
| library(maptools) | |
| library(raster) | |
| f <- readOGR("IN_NYC/sample_nyc.shp", "sample_nyc") | |
| # CREATE SEGMENTS | |
| segmts <- as.psp(as(f, "SpatialLines")) # coercing SpatialLines objects to psp Line Segment Pattern objects splits polylines to lines |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(RCurl) | |
| library(rjson) | |
| whatGoogleSuggestsFor <- function(question, domain="fr") { | |
| # Domain : here, just France or USA | |
| # You could add URLs for some other countries | |
| if (domain == "fr") { | |
| baseU <- "https://www.google.fr/s?gs_rn=45&sclient=psy-ab" | |
| } else { |