Skip to main content

Provides a wrapper to the RAMM API and additional tools for positional referencing

Project description

pyramm

Python wrapper for the RAMM API.

Users must have their own login for the RAMM database.

Installation

pip install pyramm

Issues

Please submit an issue if you find a bug or have an idea for an improvement.

Initialise

You must first initialise the connection to the RAMM API as follows. Note that the database argument defaults to "SH New Zealand" if it is not provided.

from pyramm.api import Connection
conn = Connection(username, password, database="SH New Zealand")

Alternatively the username and password can be stored in file called .pyramm.ini. This file must be saved in the users home directory ("~" on linux) and contain the following:

[RAMM]
USERNAME = username
PASSWORD = password

You are then able to initialise the RAMM API connection without providing your login credentials each time.

from pyramm.api import Connection
conn = Connection()

Table and column names

A list of available tables can be accessed using:

table_names = conn.table_names()

A list of columns for a given table can be accessed using:

column_names = conn.column_names(table_name)

Table data

Some methods are attached to the Connection object to provide convenient access to selected RAMM tables. These helper methods implement some additional filtering (exposed as method arguments) and automatically set the DataFrame index to the correct table column(s).

Tables not listed in the sections below can be accessed using the general get_data() method:

df = conn.get_data(table_name)

General tables:

roadnames = conn.roadnames()
carrway = conn.carr_way(road_id=None)
c_surface = conn.c_surface(road_id=None)
top_surface = conn.top_surface()
surf_material = conn.surf_material()
surf_category = conn.surf_category()
minor_structure = conn.minor_structure()

HSD tables:

hsd_roughness = conn.hsd_roughness(road_id, latest=True, survey_year=None)
hsd_roughness_hdr = conn.hsd_roughness_hdr()
hsd_rutting = conn.hsd_rutting(road_id, latest=True, survey_year=None)
hsd_rutting_hdr = conn.hsd_rutting_hdr()
hsd_texture = conn.hsd_texture(road_id, latest=True, survey_year=None)
hsd_texture_hdr = conn.hsd_texture_hdr()

Centreline

The Centreline object is provided to:

  • assist with generating geometry for table entries (based on road_id, start_m and end_m values),
  • find the displacement (in metres) along the nearest geometry element given a point (latitude, longitude).

The base geometry used by the Centreline object is derived from the carr_way table.

Create a Centreline instance:

centreline = conn.centreline()

Append geometry to table:

For a table containing road_id, start_m and end_m columns, the geometry can be appended using the append_geometry() method:

df = centreline.append_geometry(df, geometry_type="wkt")

The geometry_type argument defaults to "wkt". This will provide a WKT LineString for each row.

Alternatively, geometry_type can be set to "coord" to append a northing and easting column to the DataFrame.

Find carriageway and position from point coordinates:

The carriageway and position information (e.g. Rs/Rp) can be determined for a point coordinate using the position() method:

point = Point((172.618567, -43.441594))  # Shapely Point object
position = centreline.position(point, point_crs=4326, road_id=None)

The point coordinate reference system defaults to WGS84 but can be adjusted using the point_crs argument. The value must be an integer corresponing to the EPSG code (e.g. 4326 for WGS84).

If the road_id argument is provided then the position will be determined only for the specified road. Otherwise the position will be determined for the nearest road.

Partial centreline

Sometimes it is necessary to match only to selected parts of the RAMM centreline. In this case a partial centreline can be generated and used for the matching:

# Generate a partial centreline containing only road_id 3656 between route position 10m
# and 100m:
partial_centreline = conn.centreline(lengths={3656: [10, 100]})

point = Point((172.608406, -43.451023))
position = partial_centreline.position(point)

The lengths argument is a Python dictionary containing road_id keys and start/end position pair values. Some examples include:

  • {3656: None} includes the entire centreline for road_id 3656.
  • {3656: [10, 100]} includes only the section of centreline for road_id 3656 between route position 10m and 100m.
  • {3656: [500, None]} includes only the section of centreline for road_id 3656 from route position 500m.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyramm-1.30.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

pyramm-1.30-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file pyramm-1.30.tar.gz.

File metadata

  • Download URL: pyramm-1.30.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for pyramm-1.30.tar.gz
Algorithm Hash digest
SHA256 575e1adfac5176ed45ee174a88014611a331c43a5c1d4ff3909c3cc15bb46beb
MD5 353bf75a2857311234bf5678100670f9
BLAKE2b-256 84f669fbd542cb223f17ebd91dbe2296ba3280e7822269cae6c6eda957da83b0

See more details on using hashes here.

File details

Details for the file pyramm-1.30-py3-none-any.whl.

File metadata

  • Download URL: pyramm-1.30-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for pyramm-1.30-py3-none-any.whl
Algorithm Hash digest
SHA256 da3be3386ddd142c3c999649fab2dadf1f1ea3c8596e24eb79c341d4e039a69f
MD5 e4e3b80a9de2e3a8b677313f94acd0b1
BLAKE2b-256 f91d28ca61768b7e29cd3264fa37a8a573ae55b5051758f0a35e6c9a5593c364

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page