catatom2osm.catatom module

Reader of Cadastre ATOM GML files.

class catatom2osm.catatom.Reader(a_path)[source]

Bases: object

Class to download and read Cadastre ATOM GML files.

download(layername)[source]

Download the file for a Cadastre layername.

Parameters

layername (str) – Short name of the Cadastre layer. Any of ‘building’, ‘cadastralzoning’, ‘address’

fix_amp(gml_path, zip_path)[source]

Test if source needs to be escape ampersand.

fix_encoding(gml_path, zip_path)[source]

Test if source needs to be converted to utf-8.

get_atom_file(url)[source]

Try to download the ZIP file for self.zip_code.

Given the url of a Cadastre ATOM service.

get_file_object(gml_path, zip_path='')[source]

Get handler for gml_path (if exist) or for zip_path.

get_gml_from_zip(gml_path, zip_path, group, layername)[source]

Return gml layer from zip if exists and is valid or none.

get_layer_paths(layername)[source]
get_metadata(md_path, zip_path='')[source]

Get the metadata of the source file.

get_path(*paths)[source]

Get path from components relative to self.path.

get_path_from_zip(zf, a_path)[source]

Return full path in zip of this file name.

is_empty(gml_path, zip_path)[source]

Detect if the file is empty.

Cadastre empty files (usually otherconstruction) comes with a null feature and results in a non valid layer in QGIS.

read(layername, allow_empty=False, force_zip=False)[source]

Create a QGIS vector layer for a Cadastre layername.

Derive the GML filename from layername. Downloads the file if not is present. First try to read the ZIP file, if fails try with the GML file.

Parameters
  • layername (str) – Short name of the Cadastre layer. Any of ‘building’, ‘buildingpart’, ‘otherconstruction’, ‘cadastralparcel’, ‘cadastralzoning’, ‘address’, ‘thoroughfarename’, ‘postaldescriptor’, ‘adminunitname’

  • allow_empty (bool) – If False (default), raise a exception for empty layer, else returns None

  • force_zip (bool) – Force to use ZIP file.

Returns

Vector layer.

Return type

QgsVectorLayer