Skip to content

Instantly share code, notes, and snippets.

@seanlinmt
Created October 30, 2020 05:26
Show Gist options
  • Save seanlinmt/f98c75a6d728125bf2fb6aecdb9a8562 to your computer and use it in GitHub Desktop.
Save seanlinmt/f98c75a6d728125bf2fb6aecdb9a8562 to your computer and use it in GitHub Desktop.
Extracting features from an ArcGIS server using arcpy
import arcpy
arcpy.env.overwriteOutput = True
baseURL = "https://services.arcgis.com/XTtANUDT8Va4DLwI/ArcGIS/rest/services/NZ_School_Zone_boundaries/FeatureServer/0/query"
where = "1=1"
fields = "OBJECTID,School_ID,School_name,Office,Approval_date,Effective_date,Institution_type,Shape__Area,Shape__Length"
query = "?where={}&outFields={}&returnGeometry=true&f=json".format(where, fields)
fsURL = baseURL + query
fs = arcpy.FeatureSet()
fs.load(fsURL)
arcpy.CopyFeatures_management(fs, "H:/temp/data.gdb/school_zones")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment