Parcel Feature Relationships and Querying
This notebook demonstrates the following:
- How to query a feature layer
- How to find parcel features within a parcel record.
- How to find parcel features by an attribute.
- 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 Name | Type |
---|---|
GlobalID | GUID |
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 Name | Type |
---|---|
CreatedByRecord | GUID |
RetiredByRecord | GUID |
from arcgis.gis import GIS
from arcgis.features.layer import FeatureLayerCollection
from arcgis.features.layer import FeatureLayer
base_server_url = (
"https://rextapilnx02eb.mysite.com/server/rest/services/WashingtonCounty/"
)
gis = GIS(
"https://myenterprisesite.com/portal/",
"my_user_name",
"my_secure_password",
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
# 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.mysite.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
objectid | name | globalid | SHAPE | |
---|---|---|---|---|
0 | 123 | Record001 | {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:
- Extract the globalID of the record
- Access the parcel polygon feature layer
- Query the features in the parcels feature layer associated to the record
parcels(CreatedByRecord) = records(GlobalID)
- 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.mysite.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
m = gis.map()
m
m.content.draw(parcels_subset)