Part 4 - Query Parcels

Parcel Feature Relationships and Querying

This notebook demonstrates the following:

  1. How to query a feature layer
  2. How to find parcel features within a parcel record.
  3. How to find parcel features by an attribute.
  4. Build up a dict of parcel features for Parcel Fabric capabilities.

Records

A Parcel Fabric contains a Records which represents the legal document information about a parcel or set of parcels. The geometry of a record is the outer boundary of any parcel polygon features associated with a particular record. The record feature and parcel feature(s) are related by GUID fields (GlobalID) in each.

Field NameType
GlobalIDGUID

Parcel features

A parcel type consists of a pair of feature classes.

  • A polygon feature class representing the area of a parcel.
  • A COGO enabled line feature class representing the boundary of a parcel.

Parcel features (both lines and polygons) relate to a Record and to themselves:

Field NameType
CreatedByRecordGUID
RetiredByRecordGUID
from arcgis.gis import GIS
from arcgis.features.layer import FeatureLayerCollection
from arcgis.features.layer import FeatureLayer
base_server_url = (
    "https://rextapilnx02eb.esri.com/server/rest/services/WashingtonCounty/"
)
gis = GIS(
    "https://rextapilnx02eb.esri.com/portal/",
    "gisproadv2",
    "portalaccount1",
    verify_cert=False,
)

# generate the enpoint urls for feature server, version management and parcel fabric
service_endpoints = ["FeatureServer", "VersionManagementServer"]
service_urls = {url: base_server_url + url for url in service_endpoints}

parcel_fabric_flc = FeatureLayerCollection(service_urls["FeatureServer"], gis)
parcel_fabric_flc.layers[0].properties.name
Setting `verify_cert` to False is a security risk, use at your own risk.
'WashCoFabricSubset'
# Get the URL of the Records feature layer
records_fl_url = [n for n in parcel_fabric_flc.layers if n.properties.name == "Records"]
records_fl_url = records_fl_url[0].url
records_fl_url
'https://rextapilnx02eb.esri.com/server/rest/services/WashingtonCounty/FeatureServer/1'

Find a parcel record by its name

  • Access the Records feature layer
  • Create a WHERE clause and list of fields to return
  • Query the records feature layer
  • Return the result as a spatial data frame
record_name = "Record001"  # name to search
out_fields = ["name", "globalId"]  # fields to return

where = f"name = '{record_name}'"

records_fl = FeatureLayer(records_fl_url, gis)
record_row = records_fl.query(
    where=where,
    out_fields=out_fields,
).sdf

record_row
objectidnameglobalidSHAPE
0123Record001{4B753DC5-AEDD-4703-AE56-B236EBB5DEFB}{"rings": [[[2474616.7778283805, 503108.655806...

Find parcel features by Record GlobalID

In the cell above, the Records feature layer was queried by using its name. The GlobalID value for 'Record001' is now available to use in a search for its associated parcel features.

The proceeding cells will show the following:

  1. Extract the globalID of the record
  2. Access the parcel polygon feature layer
  3. Query the features in the parcels feature layer associated to the record

parcels(CreatedByRecord) = records(GlobalID)

  1. Draw the subset on a map
record_globalid = record_row.at[0, "globalid"]
record_globalid
'{4B753DC5-AEDD-4703-AE56-B236EBB5DEFB}'
# Get the URL of the parcel polygon feature layer
parcels_fl_url = [n for n in parcel_fabric_flc.layers if n.properties.name == "Tax_PF"]
parcels_fl_url = parcels_fl_url[0].url
parcels_fl_url
'https://rextapilnx02eb.esri.com/server/rest/services/WashingtonCounty/FeatureServer/15'
out_fields = ["name", "globalId"]
where_clause = f"CreatedByRecord = '{record_globalid}'"
parcels_fl = FeatureLayer(parcels_fl_url, gis)

parcels_subset = parcels_fl.query(where=where_clause, out_fields=out_fields)
parcels_subset
<FeatureSet> 12 features
map = gis.map("USA", zoomlevel=16)
map.draw(parcels_subset)
map.zoom_to_layer(parcels_subset)

API Ref Documentation

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.