Is there a better way of getting that geometry into the second query? Not happy with line 28
from __future__ import print_function
from arcrest.ags import FeatureLayer
import arcpy
import json
if __name__ == "__main__":
arcpy.env.overwriteOutput = True
lgaUrl = "http://services.thelist.tas.gov.au/arcgis/rest/services/Public/CadastreAndAdministrative/MapServer/4"
flLGA = FeatureLayer(
url=lgaUrl)
lgaWhereClause = "NAME = 'Launceston'"
outSR = '28355'
## outFC="C:\Scripts\data.gdb\LGA"
## # get lga geometry
## lgaGeom = flLGA.query(where=lgaWhereClause,out_fields='shape',returnGeometry=True,returnFeatureClass=True,out_fc=outFC,outSR=outSR)
lgaGeom = flLGA.query(where=lgaWhereClause,out_fields='shape',returnGeometry=True,outSR=outSR)
geomText = lgaGeom.toJSON
geomRings = json.loads(geomText)
for key, value in geomRings.iteritems():
if key == 'features':
features = str(value)
features = features.replace("[{u'geometry': ","").replace(", u'attributes': {}}]","").replace("{u'rings':","{'rings':")
# change to Crown Licenses
crownUrl = "http://services.thelist.tas.gov.au/arcgis/rest/services/Public/CadastreAndAdministrative/MapServer/3"
flCrown = FeatureLayer(
url=crownUrl)
crownWhereClause = "1=1"
outFC="C:\Scripts\data.gdb\CrownLicenses"
geometryType = "esriGeometryPolygon"
# get crownLicenses
crownLicenses =
38.
flCrown.query(where=crownWhereClause,geometry=features,out_fields='objectid,pid,shape',returnGeometry=Tr
e,returnFeatureClass=True,out_fc=outFC,geometryType=geometryType,inSR=outSR,outSR=outSR)