Context
I am currently working on the migration from ArcMap 10.3 to ArcGIS Pro. We have several tools that won't work anymore in ArcGIS Pro and I am checking what native solutions could be used before going to a customized development.
One of the tool we currently have generates a html page when clicking on a parcel and queries 5 different layers (all the layers have the same ID or parcel number).
I would like to migrate it in ArcGIS Pro using arcpy and reportlab if possible. I thought about reportlab as the html template is basically a table.
What has been done
I already used the SearchCursor to extract the fields I was interested in and the where_clause to select only rows I wanted. However, I managed to do it within 1 layer at a time.
I checked the forums to see if I could perform spatial queries with arcpy, and I found the MakeQueryLayer, however I do not wish to create a new layer but just extract information related to a parcel number over 5 feature layers and display it in a pdf.
I am trying with MakeQueryTable following ArcGIS Pro help/examples online :
import arcpy
tableList = ["c:\\path\\Projects\\MyProject1\\sde.sde\\A.CAD_Adresses\\A.CAD_ADRESSE", "c:\\path\\Projects\\MyProject\\sde.sde\\A.CAD_Communes\\A.CAD_COMMUNE", "c:\\path\\Projects\\MyProject\\sde.sde\\A.CAD_Immeubles\\A.CAD_BIENS_FONDS"]
fieldList = [["A.CAD_ADRESSE", 'EGID'], ["A.CAD_COMMUNE", 'TITRE'], ["A.CAD_BIENS_FONDS", 'EGRID'], ["A.CAD_BIENS_FONDS", 'MUTNUM']]
keyField = "A.CAD_BIENS_FONDS.EGRID"
arcpy.MakeQueryTable_management(tableList, keyField, fieldList)
I keep getting a runtime error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 6316, in MakeQueryTable
raise e
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\management.py", line 6313, in MakeQueryTable
retval = convertArcObjectToPythonObject(gp.MakeQueryTable_management(*gp_fixargs((in_table, out_table, in_key_field_option, in_key_field, in_field, where_clause), True)))
File "c:\programfiles\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 506, in <lambda> return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Objet : erreur lors de l’exécution de l’outil
I also had to adapt the syntax as I also got errors. I followed this post
For this example I only worked with 3 layers, I have 5 to deal with. But the IDs in common will be the EGID and/or the EGRID number.