I am trying to use the GIS library to extract parcel data for my City from our County's data. I'm using a spatial filter, but for some reason I am not getting all the data returned. There are random holes in my data. We are interested in about 15% of the records, so I'd rather not have to extract all the data to get what we need.
import arcpy
from arcgis.gis import GIS
from arcgis.geometry import Geometry
from arcgis.features import FeatureLayer
from arcgis.geometry import filters
import pandas as pd
# Define the geometry
geometry = Geometry({
"rings": [
[
[-121.261, 44.2128],
[-121.2618, 44.3237],
[-121.0991, 44.3257],
[-121.1004, 44.212]
]
],
"spatialReference": {"wkid": 4326}
})
# Connect to the GIS
gis = GIS()
# URL of the Feature Layer
url = 'https://[service url]/FeatureServer/0'
feature_layer = FeatureLayer(url)
query_result = feature_layer.query(geometry_filter=filters.intersects(geometry), out_fields='*', return_geometry=True)
# Convert the query result to a DataFrame
df = query_result.sdf
# Save the DataFrame to a CSV file
output_csv = r'C:\Users\dummy\Desktop\output.csv'
df.to_csv(output_csv, index=False)
