Skip to content

Instantly share code, notes, and snippets.

@n-a-t-e
n-a-t-e / chs_charts_maplibre.html
Last active March 15, 2023 22:04
CHS Charts in Maplibre
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>CHS Charts via WMS in Mapbox</title>
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<script src="https://unpkg.com/maplibre-gl@2.4.0/dist/maplibre-gl.js"></script>
@n-a-t-e
n-a-t-e / erddap_dataset_logs.sh
Last active February 22, 2023 17:59
ERDDAP dataset logs in GoAccess
sudo cat /var/log/httpd/ssl_access_log* |
# only look at these types of queries
grep -E -i " /erddap/(tabledap|griddap|rss|files|info)/[a-zA-Z0-9_]+[\.\/\?]" |
# ignore these queries
grep -v -E " /erddap/\w+/(index|allDatasets|documentation)" |
# turns requests like /erddap/tabledap/DFO_MEDS_BUOYS.htmlTable?STN_ID&time>=now-1week&distinct() into /DFO_MEDS_BUOYS
sed -r 's/(.*) \/erddap\/\w+\/([a-zA-Z0-9_]+)[\.\/\?].* HTTP/\1 \/\2 HTTP/g' |
sudo goaccess - -o /var/www/html/erddap_logs/index3_no_crawlers.html --log-format=COMMON --ignore-crawlers
@n-a-t-e
n-a-t-e / unicode.csv
Created December 14, 2022 22:26
unicode csv test
id symbol food price
1 🐟 pêches €4
2 🍕 pizza ¥1
3 🥦 légumes ₹2
@n-a-t-e
n-a-t-e / nc_to_tiles.sh
Created December 5, 2022 20:36
NetCDF to XYZ tiles using GDAL and Docker
#!/bin/bash
docker run -it -v `pwd`/tiles:/tiles --name gdal --rm osgeo/gdal /bin/bash -c "
wget https://hpfx.collab.science.gc.ca/20221201/WXO-DD/model_ciops/salish-sea/500m/00/001/20221201T00Z_MSC_CIOPS-SalishSea_SeaSfcHeight_Sfc_LatLon0.008x0.005_PT001H.nc
echo -e '-2 red\n0 50 180 50\n2 blue\nnv 0 0 0 0' > colors.txt
gdal_translate -a_nodata 10000000000 *.nc out.tif
gdaldem color-relief -alpha out.tif colors.txt out.tif
gdal_translate -of VRT -ot Byte -scale out.tif temp.vrt
time gdal2tiles.py --process=8 --zoom 0-11 temp.vrt --tilesize=256 --xyz
cp -r temp/* /tiles"
@n-a-t-e
n-a-t-e / erddap_compliance.md
Last active November 3, 2022 18:26
erddap compliance link

ERDDAP link to compliance results from datasets pages

This is how I added a link from ERDDAP dataset pages to the results of the IOOS Compliance checker for that page.

Example: https://data.cioospacific.ca/erddap/tabledap/BCSOP_daily.html, see "Compliance Results" link in top right corner

Editing erddap's setup.xml file, this goes in <startHeadHtml5>/<head>:

const data = {
AphiaID: 1,
rank: "Superdomain",
scientificname: "Biota",
child: {
AphiaID: 2,
rank: "Kingdom",
scientificname: "Animalia",
child: {
AphiaID: 51,
@n-a-t-e
n-a-t-e / baynes_sound_data_from_ONC.md
Last active February 18, 2022 16:32
Baynes sound data from ONC ERDDAP

Update Bayne Sound Database

This python tool is use to query the ONC ERDDAP server matching the terms below for a given time range:

  • Baynes Sound Carbon Dioxide Sensor
  • Baynes Sound Conductivity Temperature Depth

And the region

  • Latitude: [49.45, 49.70]
  • Longitude: [-124.966, -124.7]

Methodology

@n-a-t-e
n-a-t-e / ceda_api_endpoints.md
Last active January 27, 2022 23:02
ceda API endpoints

CEDA API Endpoint requirements

/pointQuery

Either pointPKs or polygon is required. If any other variable is left out it will include all data for that variable.

  • timeMin
  • timeMax
  • depthMin
  • depthMax
  • polygon
@n-a-t-e
n-a-t-e / changes-ogsl.md
Last active March 15, 2022 16:53
OGSL ERDDAPs suggest changes for CDE

OGSL ERDDAPs suggest changes

https://erddap.ogsl.ca/erddap/tabledap/binned_8f48_5f3e_04f3.html cdm_data_type is Point, could be TimeSeries with timeseries_id=station_id

https://erddap.ogsl.ca/erddap/tabledap/in-situ_8f48_5f3e_04f3.html cdm_data_type is Point, could be TimeSeries with timeseries_id=station_id

https://erddap.ogsl.ca/erddap/tabledap/tabular_nc_0a89_74aa_5dea.html cdm_data_type is Point, could be TimeSeries with timeseries_id=station_id

For the rest of the datasets, at least one supported CF standard name is required (eg sea_water_temperature)

@n-a-t-e
n-a-t-e / changes.md
Last active March 15, 2022 16:07
Atlantic ERDDAPs suggest changes for data explorer