Closed MikeMillerGIS closed 7 years ago
I think the solution will be to have a 'Source Where Clause' property that is similar to the current 'Replace By' clause for the Target dataset. We could probably default that to the definition query when a map layer is selected as an input.
The tools basically support Where clauses already because the Preview functionality has a row limit parameter that constructs a where clause. This functionality would have to be updated to utilize both Where clauses for the Preview functionality.
Talking with @ChrisBuscaglia, we would prefer the tool utilize a lyrx file and not store the expression. The lyrx file would be used to limit the results. If the user selects a layer in the TOC, the lyrx file could be written to the same workspace as the xml
@MikeMillerGIS
Derived output GP tools (similar to what DA is) works on a selection set from a map layer. I was suggesting that DA will also work this way.
Workflow:
Am I understanding the requirement correctly?
Chris
@ChrisBuscaglia @MikeMillerGIS I am using the .lyrx file approach for the new joined layer approach in development. We can take a look at that and discuss how to extend to other layers for the definition query. I was only concerned about the case where a user selects a feature service etc. that is not a map layer and they still want to have a definition query.
@SteveGrise
Feature services can be added to the map as a layer, the intermediate dataset created is a FGDB.
If a user selects a subset of the feature service, the intermediate dataset would be a subset of the feature service (.lyrx created from it). Subsequent runs would use the .lyrx file to select the feature service input (source) and then create the intermediate dataset again from it.
Looks like I can already use .lyrx files as inputs to the tools, will need to do some testing to verify functionality and ensure Definition queries work as expected.
Append will not accept a .lyrx file as input:
As discussed, can we try layer = arcpy.mp.layer('path to lyrx') layer_object = layer.listLayers()[0]
Seems to be working with a few changes to other code: layer = arcpy.mp.LayerFile(source) view = layer.listLayers()[0]
@MikeMillerGIS @pLeBlanc93 I'm struggling to pick up a layer file as a parameter. From what I am seeing the .lyrx file is converted to a layer before it is passed to the GP tool, then I don't have a way to get the file path of the original file...
I think I have a solution with: source = arcpy.GetParameter(0) # source dataset to analyze sourceStr = arcpy.GetParameterAsText(0) # source dataset to analyze
then I replace the source value when the sourceStr value ends with .lyrx: def checkIsLayerFile(val,valStr):
if valStr.lower().endswith('.lyrx'):
return valStr
else:
return val
Yes, GP wraps layer(x) files that are passed as parameters as a special geoprocessing
object that is slightly different.
Grabbing the parameter both ways was the best way I came up with as well.
@pLeBlanc93 thanks!
verified creating new config maintains the path to the chosen lyrx file. Have not verified if only subset of data copied over due to current append data issue.
Verified only subset of data was copied over
When selecting a layer, the path to the dataset is stored, regardless if you picked a layer in the toc, a lyrx file or a location on disk. I would like to be able to load only a subset of source data. Can we add the definition expression to the xml or point to a lyrx file file or some other alternative?
This is required for the UN work we are doing.