Canton of Basel City open government data related to Food unlisted

loleg

Files Size Format Created Updated License Source
2 75kB csv zip 1 year ago Statistics Portal
This Data Package was created at the Open Food Hackdays 2018 in Basel. The metadata here is provided as "best effort", without any guarantee of correctness. To contribute, please visit the GitHub repository. Data The Canton of Basel-City publishes a variety of geographic and statistical data on read more
Download Developers

Data Files

Download files in this dataset

File Description Size Last changed Download
t07-1-aggregated 2kB csv (2kB) , json (14kB)
foodstats-basel_zip Compressed versions of dataset. Includes normalized CSV and JSON data with original data and datapackage.json. 8kB zip (8kB)

t07-1-aggregated  

This is a preview version. There might be more data in the original version.

Field information

Field Name Order Type (Format) Description
Jahr 1 integer (default)
Getreide 2 integer (default)
Kartoffeln 3 string (default)
Silo-,Grün-mais 4 integer (default)
Freiland-gemüse 5 integer (default)
Wiesen und Weiden 6 integer (default)
Rebland 7 integer (default)
Obstanlagen 8 integer (default)
Übrige Flächen 9 integer (default)
Total 10 integer (default)
davon im Ausland 11 integer (default)
Rindvieh 12 integer (default)
davon Kühe 13 integer (default)
Pferde 14 integer (default)
Ponys, Esel 15 integer (default)
Schweine 16 integer (default)
Schafe 17 integer (default)
Ziegen 18 integer (default)
Geflügel 19 integer (default)
Bienenvölker 20 string (default)
Landwirtschaftsbetriebe – Alle 21 integer (default)
Landwirtschaftsbetriebe – hauptber. Landwirte 22 integer (default)
Anzahl Betriebe – 0,00-3,00 ha 23 integer (default)
Anzahl Betriebe – 3,01-10,00 ha 24 integer (default)
Anzahl Betriebe – 10,01-20,00 ha 25 string (default)
Anzahl Betriebe – 20,01+ ha 26 integer (default)
Fläche – pro Betrieb 27 number (default)
Beschäftigte – Vollzeit 28 integer (default)
Beschäftigte – Teilzeit 29 integer (default)
Beschäftigte – Männer 30 integer (default)
Beschäftigte – Frauen 31 integer (default)
Beschäftigte – Total 32 integer (default)

Integrate this dataset into your favourite tool

Use our data-cli tool designed for data wranglers:

data get https://datahub.io/loleg/foodstats-basel
data info loleg/foodstats-basel
tree loleg/foodstats-basel
# Get a list of dataset's resources
curl -L -s https://datahub.io/loleg/foodstats-basel/datapackage.json | grep path

# Get resources

curl -L https://datahub.io/loleg/foodstats-basel/r/0.csv

curl -L https://datahub.io/loleg/foodstats-basel/r/1.zip

If you are using R here's how to get the data you want quickly loaded:

install.packages("jsonlite", repos="https://cran.rstudio.com/")
library("jsonlite")

json_file <- 'https://datahub.io/loleg/foodstats-basel/datapackage.json'
json_data <- fromJSON(paste(readLines(json_file), collapse=""))

# get list of all resources:
print(json_data$resources$name)

# print all tabular data(if exists any)
for(i in 1:length(json_data$resources$datahub$type)){
  if(json_data$resources$datahub$type[i]=='derived/csv'){
    path_to_file = json_data$resources$path[i]
    data <- read.csv(url(path_to_file))
    print(data)
  }
}

Note: You might need to run the script with root permissions if you are running on Linux machine

Install the Frictionless Data data package library and the pandas itself:

pip install datapackage
pip install pandas

Now you can use the datapackage in the Pandas:

import datapackage
import pandas as pd

data_url = 'https://datahub.io/loleg/foodstats-basel/datapackage.json'

# to load Data Package into storage
package = datapackage.Package(data_url)

# to load only tabular data
resources = package.resources
for resource in resources:
    if resource.tabular:
        data = pd.read_csv(resource.descriptor['path'])
        print (data)

For Python, first install the `datapackage` library (all the datasets on DataHub are Data Packages):

pip install datapackage

To get Data Package into your Python environment, run following code:

from datapackage import Package

package = Package('https://datahub.io/loleg/foodstats-basel/datapackage.json')

# print list of all resources:
print(package.resource_names)

# print processed tabular data (if exists any)
for resource in package.resources:
    if resource.descriptor['datahub']['type'] == 'derived/csv':
        print(resource.read())

If you are using JavaScript, please, follow instructions below:

Install data.js module using npm:

  $ npm install data.js

Once the package is installed, use the following code snippet:

const {Dataset} = require('data.js')

const path = 'https://datahub.io/loleg/foodstats-basel/datapackage.json'

// We're using self-invoking function here as we want to use async-await syntax:
;(async () => {
  const dataset = await Dataset.load(path)
  // get list of all resources:
  for (const id in dataset.resources) {
    console.log(dataset.resources[id]._descriptor.name)
  }
  // get all tabular data(if exists any)
  for (const id in dataset.resources) {
    if (dataset.resources[id]._descriptor.format === "csv") {
      const file = dataset.resources[id]
      // Get a raw stream
      const stream = await file.stream()
      // entire file as a buffer (be careful with large files!)
      const buffer = await file.buffer
      // print data
      stream.pipe(process.stdout)
    }
  }
})()

Read me

This Data Package was created at the Open Food Hackdays 2018 in Basel. The metadata here is provided as “best effort”, without any guarantee of correctness. To contribute, please visit the GitHub repository.

goodtables.io

Data

The Canton of Basel-City publishes a variety of geographic and statistical data on the subject of food. These are open data, but not yet state-of-the-art Open Government Data (OGD), i.e. they have not yet been published in a completely standardized way. A series of datasets have been recommended for use and improvement at the Open Food Data Hackdays from the Statistical Portal (statistik.bs.ch)

From these, we focused on the Agriculture (farms, land use, animals) data to create this aggregate dataset, compiled from:

These topics can also be found in the Indicators portal and in the Basel Atlas, and from there downloaded/exported as CSV.

Preparation

LibreOffice Calc was used to collate the years 2011-2016 from the source spreadsheets. Some manual tweaking was required to standardize the rows (there were some years missing in the 2nd spreadsheet), and columns (some of which were defined across rows, etc.)

The Data Package schema was inferred using the Python library CLI.

License

This package is licensed by its maintainers under the Public Domain Dedication and License.

If you intended to use these data in a public or commercial product, please check the data sources themselves for any specific restrictions.

Data Protection regulations and other terms of use of statistik.bs.ch apply.

Datapackage.json