Identifiers and keys

RRC districts and counties

Districts are the RRC's administrative geography, they are not numeric, they do not nest cleanly inside anything you already have, and half the datasets are partitioned by them. Here is how to handle both districts and counties.

Two geographies run through RRC data: counties, which you already understand, and districts, which you probably do not. Both appear as short codes, both look numeric, and exactly one of them is.

Districts are the RRC's own geography

The Railroad Commission divides Texas into oil and gas districts, each served by a district office. The district is an administrative unit: it is where your forms get filed, which field rules apply, and how the RRC's own reports are partitioned. It is not a census unit, not a geological unit, and not derivable from anything else you have.

The codes you will meet in current files are 01 through 06, then 7B, 7C, 08, 8A, 09 and 10. Note what happened at seven and eight: those districts were split, and the split was expressed by appending a letter rather than by renumbering everything after them. That decision is why district codes are text.

Historical rows can carry codes that are no longer issued. Treat the district column as an open domain and let unknown values through rather than rejecting them; EZRRC publishes the district code set with validity windows so retired codes still resolve to a label.

District codes are text, in fields that look numeric

This is the single most common district bug. The COBOL layouts declare district fields as numeric — the Full Wellbore Database's root record defines field_district as a two-byte numeric field — and yet the value can be 7B. A parser that coerces the field to an integer will either crash or, worse, silently null out every row in districts 7B, 7C and 8A. Those are not small districts.

The upstream parser handles it by falling back to the raw string when the numeric conversion fails:

if data_type == 'number':
    stripped = val.strip()
    if not stripped or stripped == '0' * len(stripped):
        return None
    try:
        return int(stripped)
    except ValueError:
        return stripped        # not purely numeric — keep it as text

The production tables take the same position from the other direction: every district_no column in the PDQ dataset is loaded as text, never as a number.

Follow that rule everywhere:

  • Store district as text or varchar(2), never integer.
  • Compare with '08', not 8. WHERE district_no = 8 will not match '08'.
  • Zero-pad on the left when you build a district code from a number.
  • Sort with an explicit ordering if you need 7B between 06 and 7C; lexicographic sorting puts 10 before 7B.
-- Filter correctly: quoted, zero-padded, text comparison
SELECT district_no, count(*)
  FROM texas.pdq_og_lease_cycle
 WHERE district_no IN ('08', '8A', '7C')
   AND cycle_year_month >= '202601'
 GROUP BY district_no;

Districts do not nest inside counties, or vice versa

A district contains many counties. A county belongs to one district — usually. Offshore and bay waters complicate the picture, and the RRC maintains an "associated onshore county" concept precisely because offshore activity has to be attributed somewhere on land for reporting.

Two consequences:

  • Do not derive a district from a county with a hand-written lookup. Use the RRC's own county table, which carries the district number alongside the county number, name, FIPS code and an onshore flag.
  • Do not assume a district total equals the sum of its counties' totals unless the source table says so. Different tables aggregate on different rules.

Counties: three codes for one place

A Texas county can appear under three different identifiers in this data, and they do not all agree.

The Census FIPS county code is the national standard: three digits, under state FIPS 48. Anderson is 48001.

The RRC county number is what the RRC uses in its own files. In Texas it lines up with the FIPS county code, which is why an RRC county code can be resolved against a standard FIPS county table directly:

SELECT name
  FROM national.us_county
 WHERE statefp = '48'
   AND countyfp = %(code)s;

That is the lookup the upstream pipeline performs, and it is also why the county segment of a Texas API number resolves the same way. It is a genuine convenience, and it is a Texas-specific one — do not carry the assumption into New Mexico or Oklahoma data.

The county name appears denormalised into many extracts as free text. Sometimes padded, sometimes truncated to fit a fixed-width field, occasionally abbreviated. DE WITT and DEWITT are the same county. Never join on the name.

The RRC's own county reference table, distributed inside the PDQ dataset, is the authoritative crosswalk: county number, county FIPS code, county name, district number, district name, an onshore flag and an associated-onshore-county flag. If you need to map between any two of these, start there rather than building your own.

Offshore

Texas state waters extend well offshore, and the RRC regulates them. Offshore activity is assigned to districts and to nominal counties, and the wellbore file carries a water/land code distinguishing offshore, bay, inland waters and land. An offshore well has coordinates in the Gulf and a county attribution on the coast. If you are mapping wells and something appears to be drilling in open water, that is usually correct rather than a data error — check the water/land code before you filter it out.

Districts in file names

Several RRC datasets are published as one file per district rather than one file statewide. The inspections and violations extract is the clearest example: the file name itself carries the district, as in VIOLATIONS_DIST8A.txt. The district-level oil and gas ledgers are distributed the same way.

Two things follow. First, "the dataset" is a set of files and you need all of them for statewide coverage. Second, the district is sometimes only present in the file name and not in the rows, so a naive concatenation of every file loses the partition key. EZRRC materialises the district as a real column on those datasets so the concatenated table is still correct.

Practical checklist

  • District is text. Store it as text, compare it as text, pad it to two characters.
  • 7B, 7C and 8A exist. Any integer-typed district column has already lost them.
  • Use the RRC county table for county-to-district and county-to-FIPS mapping.
  • Never join on county name.
  • Offshore rows are real; check the water/land code before treating a Gulf coordinate as bad data.
  • When a dataset is published per district, confirm the district is a column and not just a file name.

Next: operators and P-5 numbers — the last of the three identifiers, and the one where names lie the most.