Back to How-To
How-To

Oil and Gas DLS Legal Land Descriptions in Snowflake — Township Canada

Convert DLS legal land descriptions to GPS coordinates inside Snowflake SQL for oil and gas well data, pipeline routes, and regulatory reporting.

Convert Oil and Gas DLS Legal Land Descriptions in Snowflake

Oil and gas companies on Snowflake store thousands of well records identified by DLS legal land descriptions — LSD 06-22-049-11W5, NE-36-042-03W5, SE-14-062-20W5. Every well licence, pipeline application, and production report in the warehouse references a location in this format. The problem: DLS notation tells you where a well sits on the survey grid, but it does not give you GPS coordinates for mapping, spatial analysis, or joining against other geospatial datasets.

Township Canada's Snowflake External Function converts DLS legal land descriptions to GPS coordinates directly in SQL. No exports, no Python scripts, no broken data lineage.

Why Oil and Gas Data Teams Need This

Canadian energy companies file well licences and production data using DLS notation — the Dominion Land Survey grid that divides western Canada into sections, townships, and ranges. The Alberta Energy Regulator alone tracks over 672,000 wells by their DLS address. Saskatchewan and Manitoba use the same system.

Inside Snowflake, a wells table might have 10,000 to 100,000 rows, each with a legal land description like LSD 14-27-048-05W5. That description identifies a precise 40-acre parcel near Drayton Valley, Alberta — but until you convert it to GPS coordinates (52.908, -115.243), you cannot:

  • Plot wells on a map dashboard
  • Calculate distance between wellpads and facilities
  • Join well locations against pipeline geometries or lease boundaries
  • Run proximity analysis for new drilling applications
  • Feed location data into BI tools like Tableau or Power BI

The traditional workaround — export to CSV, convert externally, re-import — breaks data lineage and drifts out of sync the moment the source table updates from new AER filings.

How It Works

The Township Canada Snowflake External Function connects your Snowflake account to the Township Canada Batch API through an AWS Lambda proxy. Once configured, you call TOWNSHIP_CONVERT() like any built-in SQL function:

SELECT
    well_id,
    uwi_location,
    TOWNSHIP_CONVERT(uwi_location):latitude::FLOAT AS latitude,
    TOWNSHIP_CONVERT(uwi_location):longitude::FLOAT AS longitude
FROM aer_wells
WHERE province = 'AB';

Snowflake batches rows automatically (up to 100 per request), sends them through the API, and maps GPS coordinates back to each row. A table with 12,000 well records processes in about two minutes.

The setup takes under an hour for a data engineer: deploy the Lambda function, configure API Gateway, create IAM roles, and register the integration in Snowflake. The step-by-step guide covers the full process.

Real-World Scenario: Enriching a Production Database

A midstream operator in Alberta tracks 8,500 active wells across the Western Canadian Sedimentary Basin. Their wells table in Snowflake includes legal land descriptions from AER public data — locations like NW-25-024-01W5, SE-07-054-12W5, and LSD 09-15-062-20W5.

The analytics team needs enriched GPS coordinates to build a facility proximity dashboard. With the Snowflake External Function, they run:

CREATE TABLE wells_enriched AS
SELECT
    w.*,
    TOWNSHIP_CONVERT(w.lld):latitude::FLOAT AS lat,
    TOWNSHIP_CONVERT(w.lld):longitude::FLOAT AS lng
FROM production_wells w;

The enriched table stays in Snowflake, linked to the source. When new well licences appear in the source table, the team re-runs the query on the incremental rows — no export step, no manual intervention. Results feed directly into Tableau dashboards and dbt models.

For teams that also need to work with individual well locations outside the warehouse, the oil and gas conversion guide covers single-location and batch conversion workflows.

What DLS Formats Are Supported

The External Function handles every standard DLS format used in oil and gas:

  • Quarter sections: NE-14-032-21W4 (northeast quarter, Section 14, Township 32, Range 21, West of 4th Meridian)
  • Legal Subdivisions: LSD 06-22-049-11W5 (Legal Subdivision 6, Section 22, Township 49, Range 11, West of 5th Meridian)
  • Sections: 22-049-11W5 (full 640-acre section)
  • UWI format: The location portion of a Unique Well Identifier (e.g., 14-27-048-05W5) converts directly

Input does not need to be perfectly formatted. Township Canada's parser handles common variations — with or without dashes, abbreviated meridians (W4 vs W4M), and extra whitespace.

For well data referenced in NTS notation (common for BC operations in the Montney and Horn River basins), the same function converts NTS grid references to GPS.

Getting Started

  1. Get a Township Canada API key from the API portal — available on any API plan starting at $20/month
  2. Follow the Snowflake External Function setup guide to deploy the Lambda proxy and configure the integration
  3. Run your first TOWNSHIP_CONVERT() query against a test table

The function also works with Databricks via a Python UDF if your team uses both platforms. DLS grid boundaries are available as a Delta Sharing dataset for spatial joins.