bcgov / bc-aquifer-dashboard

A dashboard/portal for viewing and querying provincial aquifer data
Apache License 2.0
4 stars 1 forks source link

Water level CSV #20

Open GrahamMacGregorBCGov opened 6 years ago

GrahamMacGregorBCGov commented 6 years ago

Import following CSV https://catalogue.data.gov.bc.ca/dataset/provincial-groundwater-observation-well-network-groundwater-levels-data/resource/caa18e44-c1a3-490f-a467-f2352bd8d382

Then Maybe parse to just one year from current date. This can then be Summarized by Observation wells (eg. Average level by Month) If an observation well is found within an aquifer it could trigger a new water level chart over last year and maybe most current water level.

IanLaingBCGov commented 6 years ago

--> cant use d3.csv for cross origin d3.csv("RiparianDisturbance_v6.csv",function(error,data) {

wburt commented 6 years ago

//example to load csv data from bc catalogue var data = { resource_id: 'c8c3c750-bf4d-4213-be58-42c6f42510e8', // the resource id limit: 5, // get 5 results q: 'jones' // query for 'jones' }; $.ajax({ url: 'https://catalogue.data.gov.bc.ca/api/action/datastore_search', data: data, dataType: 'jsonp', success: function(data) { alert('Total results found: ' + data.result.total) } });

IanLaingBCGov commented 6 years ago

@wburt the csv example is adding some digits on the end of the URL that is causing an error. It is the dataType: jsonp that`s troublesome I think: https://catalogue.data.gov.bc.ca/api/action/datastore_search?callback=getCSVcallback&resource_id=c8c3c750-bf4d-4213-be58-42c6f42510e8&limit=5&_=1522188185335

getting rid of the &=1522... from the URL works, but I`m not sure what to specify for dataType

wburt commented 6 years ago
    //item = 'c8c3c750-bf4d-4213-be58-42c6f42510e8';

    var data = {
        resource_id: item, // the resource id
        limit: 100000 // get 5 results            
        };
    var request = $.ajax({
        url: 'https://catalogue.data.gov.bc.ca/api/action/datastore_search',
        data: data,
        dataType: 'json',
        success: function(response) {
            console.log(response);
        }
    });
IanLaingBCGov commented 6 years ago

thanks @wburt, dataType: json works. Can a callback be used with that request?

wburt commented 6 years ago

//This seems to be working

function loadCsv(item, callback) {
    //load csv item from data catalogue-datastore api
    var data = {
        resource_id: item, // the resource id
        limit: 100000 // get 5 results            
        };
    return request = $.ajax({
        url: 'https://catalogue.data.gov.bc.ca/api/action/datastore_search',
        data: data,
        dataType: 'json',
        success: function(response) {
            console.log(response.result.records);
            return callback(null,response.result.records);
        }
    });

}
IanLaingBCGov commented 6 years ago

I have pushed up a new get_CSV_data.js that can grab two well-related csvs (reporting long-term trends) from databc's datastore:

@GrahamMacGregorBCGov Please let me know if those aren't going to work for you. You initially specified your need for ObservationWellDataAll_DailyMean.csv, however, it's not available via databc's datastore - I'll have to grab it from a MoE website.