Skip to content

Instantly share code, notes, and snippets.

@ksonda
ksonda / best-practices-table.md
Created March 10, 2025 20:14
draft geoconnex best practices
{
"@iot.selfLink": "https://wqie.internetofwater.app/FROST-Server/v1.1/Datastreams('0442bf6d-35c8-5a40-33ce-ad664e905735')",
"@iot.id": "0442bf6d-35c8-5a40-33ce-ad664e905735",
"name": "pH at 21COL001_WQX-9830",
"description": "pH at 21COL001_WQX-9830",
"observationType": "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement",
"unitOfMeasurement": {
"name": "None",
"symbol": "None",
"definition": "None"
{
"@context": {
"@vocab": "https://schema.org/",
"xsd": "https://www.w3.org/TR/xmlschema-2/#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"dc": "http://purl.org/dc/terms/",
"dcat": "https://www.w3.org/ns/dcat#",
"freq": "http://purl.org/cld/freq/",
"qudt": "http://qudt.org/schema/qudt/",
"qudt-units": "http://qudt.org/vocab/unit/",
@ksonda
ksonda / R-geoconnex.qmd
Last active September 23, 2024 05:46
R-geoconnex
---
title: "Using the geoconnex Reference Feature Server with R"
format:
html:
code-fold: show
toc: true
toc-location: left
toc-depth: 4
toc-expand: 3
page-layout: full
PREFIX schema: <https://schema.org/>
PREFIX gsp: <http://www.opengis.net/ont/geosparql#>
PREFIX wiki: <https://www.wikidata.org/wiki/>
PREFIX hyf: <https://www.opengis.net/def/schema/hy_features/hyf/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?dataset ?variableName ?temporalCoverage WHERE {
# Bind the @id of the mainstem of interest
BIND(<https://geoconnex.us/ref/mainstems/1009561> AS ?mainstem)
{
"type": "CoverageCollection",
"domainType": "PointSeries",
"parameters": {
"discharge": {
"type": "Parameter",
"description": {"en":"Water discharge in cubic feet per second"},
"observedProperty": {
"label": {"en":"Discharge"},
"id": "http://waterdata.usgs.gov/nwisweb/rdf?parmCd=00060"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<gml:FeatureCollection
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wml2="http://www.opengis.net/waterml/2.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:om="http://www.opengis.net/om/2.0"
xmlns:sa="http://www.opengis.net/sampling/2.0"
xmlns:sams="http://www.opengis.net/samplingSpatial/2.0"
xmlns:swe="http://www.opengis.net/swe/2.0" gml:id="USGS.waterservices" xsi:schemaLocation="http://www.opengis.net/waterml/2.0 http://schemas.opengis.net/waterml/2.0/waterml2.xsd">
<gml:featureMember>
library(sf)
library(mapview)
# read identifiers for Colorado River and Colorado River (TX) into simple features
colorado_river <- sf::read_sf("https://geoconnex.us/ref/mainstems/29559")
colorado_river_tx <- sf::read_sf("https://geoconnex.us/ref/mainstems/2639515")
## Function that constructs query to retrive the latest discharge observation from the USGS