Skip to content

Instantly share code, notes, and snippets.

View RCura's full-sized avatar

Robin Cura RCura

View GitHub Profile
library(shiny)
require(maptools)
shinyServer(function(input, output) {
uploadShpfile <- reactive({
if (!is.null(input$shpFile)){
shpDF <- input$shpFile
prevWD <- getwd()
uploadDirectory <- dirname(shpDF$datapath[1])
library(tidyverse)
library(duckdb)
library(DBI)
# création de la BDD en mémoire
connexion <- dbConnect(drv = duckdb(), dbdir=":memory:")
# Création d'une vue correspondant au fichier (csv ici)
dbExecute(connexion, statement = "CREATE VIEW matable AS SELECT * FROM 'stations.csv'")
@RCura
RCura / app.R
Last active September 16, 2021 14:56
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
@RCura
RCura / shinyApp.R
Created May 20, 2014 10:29
Shiny / R : csv to shapefile
require(shiny)
require(sp)
require(rgdal)
runApp(
list(
ui = bootstrapPage(
fileInput('inputdata', 'Input file',accept=c('.csv')),
plotOutput("xyPlot"),
downloadButton('downloadShp', 'DownloadSHP')
),
@RCura
RCura / download_overpass.R
Created January 25, 2021 17:26
OSM download
myQuery <- "node['natural'='tree'](50.4353,4.8307,50.4788,4.9018);out;"
myJSONQuery <- curl::curl_escape(paste("[out:json];", myQuery, sep=""))
myURL <- paste("https://overpass-api.de/api/interpreter?data=", myJSONQuery, sep = "")
myURL
rawJson <- jsonlite::fromJSON(myURL)
json_data <- rawJson %>%
purrr::pluck("elements")
sf_data <- json_data %>%
@RCura
RCura / python_step3_ogr.py
Created November 14, 2012 07:47
Ogr split by attribute
# -*- coding: utf-8 -*-
from osgeo import ogr
roadShpPath = "D:\\DonneesM2\\UMZ_2000_Cut.shp"
fieldToUse = 'Type'
driver = ogr.GetDriverByName("ESRI Shapefile")
datasource = driver.Open(roadShpPath)
layer = datasource.GetLayer()
@RCura
RCura / comtes_us_2018.csv
Created May 15, 2020 15:15
Densité des Comtés US
STATEFP COUNTYFP COUNTYNS NAME NAMELSAD TOT_POP areakm2 densitekm2
31 039 00835841 Cuming Cuming County 8940 1488.3432196816361 6.006679025226661
53 069 01513275 Wahkiakum Wahkiakum County 4426 742.5452485698621 5.960579518250841
35 011 00933054 De Baca De Baca County 1781 6045.909576780487 0.2945793312622452
31 109 00835876 Lancaster Lancaster County 317272 2192.1201123408173 144.7329451583776
31 129 00835886 Nuckolls Nuckolls County 4195 1491.3637168744444 2.812861780486222
72 085 01804523 Las Piedras Las Piedras Municipio NA 87.78087137695171 NA
46 099 01265772 Minnehaha Minnehaha County 192876 2107.8901870150967 91.50192035056835
48 327 01383949 Menard Menard County 2139 2336.8517291110265 0.9153340682053918
06 091 00277310 Sierra Sierra County 2987 2491.993948322783 1.1986385448529586
BEGIN:VCALENDAR
VERSION:2.0
PRODID:Robin
X-WR-CALNAME:Horaires Marées Herbaudière 2020-2021
NAME:Horaires marées Herbaudière 2020-2021
BEGIN:VEVENT
UID:CAL-MAREES-HERBAUDIERE-00001@cura.info
DTSTAMP:20200420T200000
DTSTART:20200101
SUMMARY:BM: 02h33 (NA) / 14h56 (56)
@RCura
RCura / arts.svg
Created March 22, 2020 16:50
logos trivial pursuit
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@RCura
RCura / encadre_latex.tex
Created May 31, 2019 13:40
encadre_latex.tex
% ###### CREATION D'ENCADRES ###### %
% Encadré pris dans la thèse de Seb Rey
\usepackage[most]{tcolorbox}
\newtcbtheorem[number within=chapter]{encadre}{Encadré}{
outer arc=0pt,
arc=0pt,
breakable,
enhanced,
colback=white,