2

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.

  • Ok Thank you for the clarification. I will update the post. – mel Oct 5 '17 at 10:16
  • i edited your post to make the question easier to read. Is that normal you have a folder named MyProject1 (for adresses) and another named MyProject for similar data ? Please check the location of your data to make sure. – gisnside Oct 7 '17 at 4:19
  • @gisnside: I checked and this is normal. This is how the folders have been built. I could change the name of myproject1 but it would not change the MyProject folder that has been created when we installed ArcGIS Pro on our machine. – mel Oct 10 '17 at 12:00
1

It works. There was a syntax error. Instead of writing:

"c:\\path\\Projects\\MyProject1\\sde.sde\\layer"

I was supposed to write:

r'c:\\path\\Projects\\MyProject1\\sde.sde\\layer'

I was wondering if this is typical with ArcGIS Pro because the esri tutorials online do not have this syntax.

0

I belive you are missing the out_table and in_key_field_option parameters.

Make Query Table syntax should be:

MakeQueryTable_management (in_table, out_table, in_key_field_option, {in_key_field}, {in_field}, {where_clause})

The paramaters enclosed in curly brackets are optional, the rest are mandatory.

Example:

arcpy.MakeQueryTable_management(in_table=tableList, out_table='whatever', in_key_field_option='USE_KEY_FIELDS', in_key_field=keyField)
  • Ok make sense. I will try and post an update if needed. – mel Oct 5 '17 at 12:10
  • I tried your solution and it does not work. Traceback (most recent call last): arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. ERROR 000152: Invalid input data Failed to execute (MakeQueryTable). I checked my work environment based on this post: community.esri.com/thread/111160. I am not sure what is missing. – mel Oct 5 '17 at 13:12
  • @mel: What i posted is still a part of the solution. You should edit your question accourding to this and then you will get more help – BERA Oct 6 '17 at 5:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.