Reference
DataEuropa.DataEuropa — Module
DataEuropaJulia client for the data.europa.eu open data portal: Search API, Registry (RDF) and SPARQL.
Exports: search, search_datasets, iter_datasets, fetch_datasets, get_dataset, distributions, download_distribution, load_distribution, facet_values, count_datasets, catalogues, get_rdf, sparql.
DataEuropa.cache_off — Method
cache_off()Turn off the response cache for this session (cached files stay; see clear_cache).
DataEuropa.cache_on — Function
cache_on(dir=nothing; ttl=nothing) -> StringTurn on the on-disk response cache for this session. Returns the cache folder.
Cached: dataset records (get_dataset, distributions), the catalogue list (catalogues), and searches with limit=0 (facet_values, count_datasets). Other searches, SPARQL and file downloads are never cached.
dir defaults to DATAEUROPA_CACHE_DIR, else the operating system's cache folder. ttl is how long a response stays valid, in seconds; it defaults to DATAEUROPA_CACHE_TTL, else one day. The cache is off unless this is called or DATAEUROPA_CACHE=1 is set.
DataEuropa.catalogues — Method
catalogues() -> Vector{String}Ids of all harvested catalogues.
DataEuropa.clear_cache — Method
clear_cache() -> IntDelete all cached responses. Returns how many were deleted.
DataEuropa.count_datasets — Function
count_datasets(q=nothing; kwargs...) -> IntNumber of hits for a query, without transferring records.
DataEuropa.distributions — Method
distributions(id; lang="en", files_only=false) -> DataFrameDistributions (files, services, pages) of a dataset, one row each. The url column is the download URL if present, otherwise the access URL.
The kind column says what each one is: "file", "service" (WMS, WFS, APIs, feeds), "page" (a web page), "none" (no usable URL, e.g. a localhost placeholder) or "unknown". files_only=true keeps only files.
DataEuropa.download_distribution — Method
download_distribution(url_or_row, dest; verify=true, resume=true, max_bytes=nothing) -> StringDownload a distribution (URL string, or a row of distributions) to dest: a file path, or an existing directory to save it in under its own name. Returns the local path. dest is required: nothing is written to the working directory unless you pass it (e.g. ".").
If the row has a checksum (checksum and checksum_algorithm; MD5, SHA-1 or SHA-256), the file is checked against it. On a mismatch the file is deleted and an error is thrown; verify=false skips the check. byte_size is not checked: on the portal it is often a placeholder (0, 1, 1024).
The file is written as <file>.part and renamed when complete. If a download is interrupted, calling download_distribution again for the same URL and destination continues where it stopped, when the server supports ranges and identifies the file (ETag or Last-Modified); a file that changed meanwhile is downloaded again from the start. resume=false always starts from the start.
max_bytes stops a download that is (or is announced as) larger, deletes the partial file and throws an error. Default: no limit.
DataEuropa.facet_values — Function
facet_values(facet, q=nothing; top=50, kwargs...) -> DataFrameValues and counts of a facet ("country", "format", "categories", "catalog", ...).
DataEuropa.fetch_datasets — Function
fetch_datasets(q=nothing; max_results=1000, lang="en", kwargs...) -> DataFrameCollect up to max_results datasets (scroll) into a DataFrame.
DataEuropa.get_dataset — Method
get_dataset(id; raw=false, lang="en")Full metadata for one dataset. With raw=true returns the untouched JSON object; otherwise a NamedTuple summary with an extra keywords and raw field.
DataEuropa.get_rdf — Function
get_rdf(id, fmt="ttl") -> StringDataset metadata as RDF text from the Registry API ("ttl" Turtle or "jsonld").
DataEuropa.iter_datasets — Function
iter_datasets(q=nothing; max_results=nothing, page_size=500, kwargs...) -> ChannelLazily iterate raw dataset records of a large result set using the scroll API.
DataEuropa.load_distribution — Method
load_distribution(url_or_row; format=nothing, sheet=nothing) -> DataFrameDownload a distribution and read it into a DataFrame. Accepts a URL, or a row of distributions. Reads CSV and JSON; XLSX after using XLSX, Parquet after using Parquet2. The format comes from format if given ("csv", "json", "xlsx", "parquet"), else from the row's format id, its media type, then the URL's file extension. sheet picks an XLSX sheet by name or 1-based index (default: the first).
CSV: the delimiter (, ; tab |) is taken from the header line, text is read as UTF-8 with a Latin-1 fallback, only empty cells count as missing, and dates stay text. JSON: an array of objects, or an object holding exactly one such array; keys become columns.
Throws ArgumentError for services (WMS, WFS, APIs), compressed archives, HTML pages served instead of data, and formats it cannot tell or read; and an error for files that fail their checksum (see download_distribution).
DataEuropa.load_geodata — Method
load_geodata(url_or_row; layer=nothing, crs=nothing, max_mb=200, max_features=10_000) -> DataFrameDownload a geodata distribution, or read a feature service, into a DataFrame with a geometry column, as GeoDataFrames.jl does. Needs using GeoDataFrames first. GDAL does the reading, so any vector format it knows works: GeoJSON, Shapefile, GeoPackage, KML/KMZ, GML, GPX, MapInfo TAB, FlatGeobuf, file geodatabase. The coordinate reference system is in the table's "crs" metadata.
ZIP archives (how shapefiles are published) are opened in place. Inside, the one geodata file is read (a .shp with its .dbf/.shx/.prj, .gpkg, .geojson, .kml, .gml, .gpx, .tab, .fgb, or a .gdb folder); if there are several, layer picks one by file name (without extension), otherwise an error lists them. Archives inside archives are not opened.
layer picks a layer by name or 1-based position in files with several (GeoPackage, file geodatabase); by default the first is read, with a note if there are more.
The source coordinate reference system is kept. crs (e.g. "EPSG:4326") reprojects; a file without one (a shapefile without .prj) is read as stored, with a warning.
Files over max_mb megabytes (default 200) are not downloaded; max_mb=nothing lifts the limit.
Feature services are read too: WFS (service=WFS URLs, WFS format ids) and OGC API Features (collection or landing-page URLs, OGCFEAT format ids). GDAL pages through the results. Each collection or feature type is a layer. At most max_features features (default 10,000) are read, with a warning when there are more; max_features=nothing reads all.
Throws ArgumentError for other services (WMS, ...), web pages, HTML served instead of data, and files or services GDAL cannot read; and an error for checksum mismatches.
DataEuropa.pick_lang — Function
pick_lang(x, lang="en")Collapse a {lang: text} object to one string (requested language, then English, then any).
DataEuropa.search — Function
search(q=nothing; filters="dataset", facets=nothing, limit=10, page=0, sort=nothing,
country, catalog, format, license, category, publisher, keywords, hvd,
min_date, max_date, date_type, bbox, aggregation=false, extra=Dict())Raw Search API call; returns the result object (count, results, facets, ...). country takes ISO-2 codes ("pt"), format ids such as "CSV", category DCAT-AP theme codes ("ENVI"). Use facet_values to discover ids. sort e.g. "modified+desc".
bbox is (min_lon, min_lat, max_lon, max_lat) in WGS84 degrees. A dataset matches when its spatial extent overlaps the box, so datasets covering all of Europe or the world match any box. Datasets without a spatial extent (about half the portal) never match.
With limit=0 the result can come from the response cache (see cache_on).
DataEuropa.search_datasets — Function
search_datasets(q=nothing; lang="en", kwargs...) -> DataFrameSearch datasets and return a DataFrame (total hits in metadata(df, "count")). Accepts every keyword of search.
DataEuropa.sparql — Method
sparql(query) -> DataFrame | BoolRun a SPARQL SELECT (returns a DataFrame of plain string values) or ASK (returns Bool).
Internal helpers
Not exported; call as DataEuropa.summarise_dataset.
DataEuropa.summarise_dataset — Function
summarise_dataset(d, lang="en") -> NamedTupleFlatten one raw dataset record to the commonly needed fields.