Skip to content

Instantly share code, notes, and snippets.

View FrieseWoudloper's full-sized avatar

Willy Tadema FrieseWoudloper

View GitHub Profile
@FrieseWoudloper
FrieseWoudloper / jachthavens.R
Last active February 9, 2016 14:57
R-script voor het downloaden en converteren van een JSON-bestand met locaties van jachthavens converteren naar shape-bestand
library(httr)
library(jsonlite)
library(XML)
library(sp)
library(rgdal)
###########################
# Downloaden JSON-bestand #
###########################
r <- POST('http://toerisme.groningen.nl/over-groningen/groningen-op-de-kaart/zoeken?q=+Zoeken+op+woord,+bedrijfsnaam+of+plaats+&plaats=&branches[]=238',
<?xml version="1.0" encoding="UTF-8" ?>
<sld:StyledLayerDescriptor version="1.0.0"
xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:deegreeogc="http://www.deegree.org/ogc"
xmlns:app="http://www.deegree.org/app">
<sld:NamedLayer>
<sld:Name>BP:Bestemmingsplangebied</sld:Name>
<sld:LayerFeatureConstraints>
@FrieseWoudloper
FrieseWoudloper / index.html
Last active August 12, 2016 09:07
Cafés in Groningen
<!-- Voorbeeld waarin dynamische gegevens uit OpenStreetMap met behulp van Overpass API en -->
<!-- de osmtogeojson JavaScript library worden weergeggeven in Leaflet. -->
<!-- Afgeleid van: Alex Morega, https://github.com/mgax/workshop-geocj2015-overpass/blob/master/cafes.html -->
<!doctype html>
<meta charset="utf-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css">
<style>
html, body, #map { height: 100%; margin: 0; }
</style>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@FrieseWoudloper
FrieseWoudloper / tile.R
Created November 27, 2015 18:22
R-script voor het downloaden en georefereren van een OpenStreetMap tile
setwd("D:/temp")
# Functie om op basis van latitude, longitude en zoomniveau de bijbehorende OpenStreetMap tile te berekenen
# Zie http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
deg2num <- function(lat_deg, lon_deg, zoom) {
lat_rad <- lat_deg * pi /180
n <- 2.0 ^ zoom
xtile <- floor((lon_deg + 180.0) / 360.0 * n)
ytile = floor((1.0 - log(tan(lat_rad) + (1 / cos(lat_rad))) / pi) / 2.0 * n)
@FrieseWoudloper
FrieseWoudloper / NGR_CSW.MD
Last active July 5, 2018 06:24
CSW Nationaal Georegister (NGR)

Op deze plek bewaar ik mijn experimentjes met de Catalog Service for the Web (CSW) van het Nationaal Georegister (NGR).

De documentatie van PDOK vind je hier.
Ook handig: documentatie van GeoNetwork en deze site.

Het endpoint van de service is http://nationaalgeoregister.nl/geonetwork/srv/dut/csw?
Let op: er is ook een endpoint voor INSPIRE-services. Dat is http://nationaalgeoregister.nl/geonetwork/srv/dut/inspire?

De requests in dit document zijn URL encoded. Bij sommige requests is dit namelijk een vereiste, dus heb ik het maar voor alle gedaan. Met deze [online tool](http://mey

@FrieseWoudloper
FrieseWoudloper / Parse_WFS_response.R
Created July 31, 2018 19:50
Parse WFS response in R
install.packages("XML")
library(XML)
doc <- xmlParse("http://geodata.nationaalgeoregister.nl/cbsgebiedsindelingen/wfs?request=GetCapabilities", isURL = TRUE)
output_formats <- unlist(xpathApply(doc, "//ows:Operation[@name='GetFeature']/ows:Parameter[@name='outputFormat']/ows:AllowedValues/ows:Value/text()", xmlValue))
print(output_formats)
feature_types <- unlist(xpathApply(doc,"//wfs:FeatureType/wfs:Name/text()", xmlValue))
head(feature_types)
esri2sf <- function(url, outFields=c("*"), where="1=1", token='') {
library(httr)
library(jsonlite)
library(sf)
library(dplyr)
layerInfo <- jsonlite::fromJSON(
httr::content(
httr::POST(
url,
query=list(f="json", token=token),
@FrieseWoudloper
FrieseWoudloper / AGOL.R
Last active August 9, 2018 15:18
ArcGIS Online hosted feature service in lezen in R
# Living Atlas of the world
# Rijksmonumenten
# https://www.arcgis.com/home/item.html?id=da0ee4c59ec44cff9683016c58a67470
# https://services.arcgis.com/nSZVuSZjHpEZZbRo/arcgis/rest/services/Rijksmonumenten/FeatureServer
library(sf)
library(tmap)
library(httr)
library(dplyr)
library(jsonlite)
@FrieseWoudloper
FrieseWoudloper / verblijfsobjecten_in_zuidhorn.R
Last active September 5, 2018 08:14
R script om te demonstreren hoe je WFS paging kunt implementeren in R
library(sf)
library(tmap)
library(magrittr)
library(httr)
library(xml2)
url <- parse_url("geodata.nationaalgeoregister.nl/bag/wfs?")
url$scheme <- "https"
# Request server limit