pnvdb Documentation Release 0.1.0 Jan Tore Kyrdalen Oct 31, 2017
Contents 1 Installation 3 2 Getting started 5 3 Methods 7 3.1 status................................................... 7 3.2 objekt................................................... 7 3.3 objekt_type................................................ 8 3.4 vegreferanse............................................... 9 3.5 posisjon.................................................. 9 3.6 areas................................................... 9 3.7 objekt_typer............................................... 10 3.8 hent.................................................... 10 4 Classes 11 4.1 Nvdb................................................... 11 4.2 Objekt.................................................. 11 4.3 Objekt_type............................................... 11 4.4 Vegreferanse............................................... 12 4.5 Posisjon.................................................. 12 4.6 Area................................................... 12 i
ii
pnvdb Documentation, Release 0.1.0 pnvdb stands for python veg database and is a python wrapper for the NVDB Rest API Data pulled from the API is licensed under Norsk lisens for offentlige data NLOD Contents: Contents 1
pnvdb Documentation, Release 0.1.0 2 Contents
CHAPTER 1 Installation pip install pnvdb 3
pnvdb Documentation, Release 0.1.0 4 Chapter 1. Installation
CHAPTER 2 Getting started Start with initalizing an instance of pnvdb: import pnvdb nvdb = pnvdb.nvdb(client='your-app-name', contact='your-contact-information') Now we can test our connection to NVDB: print(nvdb.status()) To work with a spesific nvdb object, we can initialize it like this: objekt = nvdb.objekt(objekt_type=67, nvdb_id=86543444) This will get us access to a number of attributes assosiated with this object. Let s print them out: print(objekt.metadata) print(objekt.vegreferanser) print(objekt.egengeometri) print(objekt.geometri) print(objekt.barn) These are all dictionaries containing information to this spesific object. 5
pnvdb Documentation, Release 0.1.0 6 Chapter 2. Getting started
CHAPTER 3 Methods The following methods are avaliable in the Nvdb class in pnvdb. initialize it as following: import pnvdb nvdb = pnvdb.nvdb(client='your-app-name', contact='your-contact-information') status Method for getting information about the current status of the API API endpoint status Code example: >>> status = nvdb.status() >>> print(status['datakatalog']['versjon']) 2.10 objekt Method for creating a spesific nvdb python Objekt API endpoint vegobjekter Code example: >>> obj = nvdb.objekt(objekt_type=67, nvdb_id=89204552) >>> print(obj.metadata) {'versjon': 3, 'type': {'navn': 'Tunnelløp', 'id': 67}, 'startdato': '2014-01-17', 'sist_modifisert': '2017-10-23 15:15:50'} 7
pnvdb Documentation, Release 0.1.0 metadata - Dictionary geometri - Well known text foreldre - List of Objekt barn - List of Objekt vegreferanser - List of Vegreferanse Methods dump() objekt_type Method for creating a spesific nvdb python Objekt_type API endpoint vegobjekttyper Code example: >>> obj = nvdb.objekt_type(objekt_type=67) >>> print(obj.metadata) {'objektliste_dato': '2012-05-08', 'sosinvdbnavn': 'Tunnelløp_67', 'sorteringsnummer ': 5460, 'navn': 'Tunnelløp', 'kategorier': [], 'veiledning': '', 'stedfesting': 'LINJE', 'id': 67, 'beskrivelse': 'Utgravd eller utstøpt passasje gjennom jord/ fjell eller under større lokk. Har normalt inngang og utgang i dagen. I spesielle tilfeller, f.eks når forgreninger eller kryss, kan det være utgang mot annet tunnelløp eller inngang fra annet tunnelløp. Se også Undergang, Skredoverbygg og Høydebegrensning.'} metadata - Dictionary relasjonstyper - Dictionary egenskapstyper List of dictionaries styringsparametere - Dictionary foreldre - List of Objekt barn - List of Objekt Methods dump() - returns the raw result form the API 8 Chapter 3. Methods
pnvdb Documentation, Release 0.1.0 vegreferanse Returns Vegreferanse of specified location API endpoint veg Code example: >>> vegref = nvdb.vegreferanse('1600ev6hp12m1000') >>> print(vegref.geometri) POINT Z (270765 7038663 51.14699567634733) detaljert - dictionary veglenke - dictionary geometri - Well known text posisjon Returns a Posisjon object API endpoint posisjon Code example: >>> pos = nvdb.posisjon(x=269815,y=7038165) >>> print(pos.vegreferanse) 1600 Rv706 hp52 m344 vegreferanse - Vegreferanse areas Returns an Area object for different type of areas API endpoint omrader Avaliable areas : * regioner * fylker * vegavdelinger * kommuner * kontraktsomrader * riksvegruter Code example: >>> for fylke in nvdb.fylker(): >>> print(fylke.metadata['navn']) Østfold Akershus Oslo... 3.4. vegreferanse 9
pnvdb Documentation, Release 0.1.0 metadata - Dictionary kartutsnitt - Dictionary senterpunkt - Dictionary objekt - Objekt objekt_typer Returns Objekt_type of every avaliable obj type in nvdb Code example: >>> objects = nvdb.objekt_typer() >>> print(objects[0].metadata) {'objektliste_dato': '2012-05-08', 'sosinvdbnavn': 'Skjerm_3', 'navn': 'Skjerm', 'id ': 3, 'kategorier': [], 'stedfesting': 'LINJE', 'sorteringsnummer': 4760, 'veiledning': '', 'beskrivelse': 'En frittstående konstruksjon som skal være et hinder for f.eks støyutbredelse'} hent Return a generator object that can be itterated over to fetch the results of the query. API endpoint vegobjekter Code example: >>> area_filter = {'fylke':'2'} # Akershus >>> objekt_type = 581 # Tunnels >>> objects = nvdb.hent(objekt_type, area_filter) >>> for obj in objects: >>> for egenskap in obj.egenskaper: >>> if egenskap['id'] == 5225: >>> print(egenskap['verdi']) Furusmotunnelen Blåkollen tunnel Hagantunnelen... 10 Chapter 3. Methods
CHAPTER 4 Classes Nvdb The main class for interfacing with the API. Objekt Class for individual nvdb-objects. metadata - Dictionary geometri - Well known text foreldre - List of Objekt barn - List of Objekt vegreferanser - List of Vegreferanse Objekt_type Class for individual nvdb-object types. (Data catalogue) metadata - Dictionary relasjonstyper - Dictionary 11
pnvdb Documentation, Release 0.1.0 egenskapstyper List of dictionaries styringsparametere - Dictionary foreldre - List of Objekt barn - List of Objekt Vegreferanse Class for working with road refferences. detaljert - dictionary veglenke - dictionary geometri - Well known text Posisjon Class for connecting coordinates to road refferences Vegreferanse Area Class for area objects. metadata - Dictionary kartutsnitt - Dictionary senterpunkt - Dictionary objekt - Objekt Link to pnvdb on Github 12 Chapter 4. Classes