POST
|
Hi Duncan, Unfortunately, no, there isn't a different parameter control that will disable the selection toggle. If the tool expects and requires a selection, you could do something like what the Eliminate tool does, which checks if the input has a selection upfront in the execution code. In Python, you could use Describe's FIDSet property such as below: in_features = arcpy.GetParameterAsText(0)
desc = arcpy.Describe(in_features)
if not getattr(desc, 'FIDSet', ''):
arcpy.AddError('Input must have a selection.')
sys.exit() Note: I've used `getattr` to add some flexibility, since if the input is a feature class (not a layer), `FIDSet` isn't available from Describe.
... View more
02-06-2024
11:22 AM
|
1
|
0
|
173
|
POST
|
Hi Kim, Yes, there's a way to do this. It's not that obvious. For some parameters, there are extra control types that will support a different appearance and behaviors. What you're seeing is the default control for a parameter with a Value Table data type. By default, someone can add multiple sets of values. But, you can modify this default behavior by setting the parameter object's controlCLSID property. So, for example, with my own code, if I create a Value Table parameter with the default control, you get this (similar to your example): param1 = arcpy.Parameter(
displayName='Arterials Weights',
name='arterials_weights',
datatype='GPValueTable',
parameterType='Required',
direction='Input',
)
param1.columns = [['GPString', 'A'], ['GPString', 'B'], ['GPString', 'C'], ['GPString', 'D'], ['GPString', 'E']] If I use the same parameter information, but then also set the controlCLSID value to a string of '{1A1CA7EC-A47A-4187-A15C-6EDBA4FE0CF7}', I get the following appearance, limiting the Value Table to single set of values. param1 = arcpy.Parameter(
displayName='Arterials Weights',
name='arterials_weights',
datatype='GPValueTable',
parameterType='Required',
direction='Input',
)
param1.columns = [['GPString', 'A'], ['GPString', 'B'], ['GPString', 'C'], ['GPString', 'D'], ['GPString', 'E']]
param1.controlCLSID = '{1A1CA7EC-A47A-4187-A15C-6EDBA4FE0CF7}' There's some other examples here: https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/parameter-controls.htm. It's not a complete list, and it doesn't include this one (it should). Does that help? Let me know if you have any questions. -Dave
... View more
01-31-2024
06:09 PM
|
2
|
2
|
206
|
IDEA
|
While we can't change the parameter type property, there is an approach to mimic the behavior you're looking for. The strategy is to flip this around, and define the parameter as optional. And then in the tool's validation code, using your specific criteria, make the parameter appear required through validation, by forcing a parameter error. If you use either the 530 or 735 error ID in validation, the parameter will then show as required. There's more information here in the Parameter topic: -Dave
... View more
01-30-2024
11:14 AM
|
0
|
0
|
59
|
POST
|
@SSISC_FieldCrew, to start, I would recommend updating a new field, at least until you're sure you have the logic the way you want. To follow along with what Dan showed, I tried the following: Expression: plant(!INV_SP_PLA!) Code Block: plant_dictionary = {
"ABUT THE": "Velvet leaf",
"ACRO REP": "Russian knapweed",
"AEGI CYL": "Jointed goatgrass",
"AEGO POD": "Goutweed / bishop's weed",
"AILA ALT": "Tree of heaven",
"ALHA MAU": "Camel thorn",
"ALLI PET": "Garlic mustard"
}
def plant(val):
"""Demo"""
if val in plant_dictionary.keys():
new_val = plant_dictionary[val]
return new_val
else:
return val
Given the below table, the updated values are shown in the `new` field: I included an `else` condition to return the original value if it's not in the dictionary. Like Joshua mentioned, variations in the original field values would result in some values not being updated.
... View more
01-11-2024
02:10 PM
|
1
|
1
|
597
|
IDEA
|
02-21-2023
02:24 PM
|
0
|
0
|
612
|
IDEA
|
01-22-2021
03:26 PM
|
0
|
0
|
1428
|
IDEA
|
Hi Dan, It's still a private specification, and is likely to change in the future. -Dave
... View more
01-22-2021
03:23 PM
|
0
|
0
|
1434
|
POST
|
Hi Eric, Eric Heinrichs wrote: So, just to clarify, I should be able to run it in the future with just a Standard license? Yes! In all likelihood the fix will be in the next set of releases, 10.5.1 and Pro 2.0. -Dave
... View more
01-20-2017
02:14 PM
|
1
|
0
|
407
|
POST
|
Hi Dan, Very likely that Pro 1.4 ships with Python 3.5. -Dave
... View more
09-19-2016
08:59 AM
|
2
|
0
|
725
|
DOC
|
Thanks Dan. We are aware that this will change how people interact with Python. It's a change and of course that will cause some initial pain. I hope this spells out what to expect and how to adapt. -Dave
... View more
07-08-2016
12:52 PM
|
0
|
0
|
20748
|
DOC
|
With ArcGIS Pro 1.3, there are some significant changes to Python. These changes primarily affect how you run standalone scripts with Python. The experience of Python within the ArcGIS Pro app is unchanged. Documentation can be found here http://pro.arcgis.com/en/pro-app/arcpy/get-started/installing-python-for-arcgis-pro.htm, but additional information is included below. Just one install of Python There is no longer a secondary install of Python needed to run standalone scripts with Pro. In ArcGIS Pro 1.0, 1.1 and 1.2 a lightweight version of Python was used within the application, but to run standalone Python scripts you had to install a secondary “Python for ArcGIS Pro”. At 1.3, ArcGIS Pro will install Python into the ArcGIS\Pro\bin\Python\envs\arcgispro-py3. This Python is used within the ArcGIS Pro application and it is also the Python you use to run standalone scripts. ArcGIS Pro 1.3 uses conda Over the last few years, conda from Continuum analytics has gained significant traction in the Python community as a package and environment manager. At 1.3, ArcGIS Pro includes conda, and the Python that you use with arcpy and ArcGIS Pro is in a conda environment named “arcgispro-py3”. With an install of ArcGIS Pro for “all users”, arcgispro-py3 will be found at C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3 . With an “only for me” install of ArcGIS Pro, arcgispro-py3 will be found at C:\Users\<user name>\appdata\local\Programs\ArcGis\Pro\bin\Python\envs\arcgispro-py3 Note: Conda is written and implemented with Python. So if you browse into ArcGIS\Pro\bin\Python\, you’ll see an install of Python. This is not the Python you’re looking for. You will not be able to use the arcpy module when running with this interpreter. Questions & Answers Note: All answers assume an install for “all users” (e.g., c:\Program Files\ArcGIS…), for user install, or install to custom location, simply update the path. Q: How do I run a standalone script? A: In previous releases of ArcGIS, a Python script was run from a command prompt like below: c:\data> c:\python34\python.exe my_script.py Now, you’ll run you the same script like below: c:\data> "c:\Program Files\ArcGIS\Pro\bin\Python\scripts\propy.bat" my_script.py Here propy.bat acts as a replacement for calling python.exe. Q: Do you have to activate the conda environment to run a standalone script? A: No, you can simply replace calls to c:\python34\python.exe with calls to c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe Or, you can also call ArcGIS\Pro\bin\python\scripts\propy.bat as mentioned above Q: If I can run envs\arcgispro-py3\python.exe, why would I want to use propy.bat? A: In future releases, you’ll be able to create, and change conda environments within ArcGIS Pro. So, while working on a given Pro project you could create and use a new conda environment with specific sets and versions of Python packages. When running standalone scripts, if you run envs\arcgispro-py3\python.exe (ArcGIS Pro's default conda environment) it would NOT necessarily have the same set of packages as you are using inside the ArcGIS Pro application. This is where propy.bat comes in, it determines the application’s active conda environment and activates it in your standalone script. Q: There is also proenv. What is the difference between propy & proenv? A: As follows propy.bat : is a replacement for python.exe, it activates the ArcGIS Pro conda environment (arcgispro-py3) and then launches python, you can call propy.bat it with or without a py script as an argument. With a script as argument which will: Activate the ArcGIS Pro conda environment Start Python Run the script specified Exit Python and the environment If you can call propy.bat without argument, the conda environment will be activated, and python will be launched in interactive window mode (REPL). proenv.bat : activates the ArcGIS Pro environment, and leaves the user in at the windows command prompt. From there you can easily call arcgispro-py3\python.exe by typing Python to start an interactive terminal session (REPL session), or type ‘python’ followed by the name of the script you wish to run. C:\my_proj>"c:\Program Files\ArcGIS\Pro\bin\Python\Scripts\proenv.bat"
Activating environment "c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py
3"...
[arcgispro-py3] c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>cd c:\my_proj
[arcgispro-py3] C:\my_proj>python
Python 3.4.4 |Continuum Analytics, Inc.| (default, Feb 16 2016, 09:54:04) [MSC v
.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import arcpy
>>> Q: When in the command prompt, why does proenv.bat change my current working directory? A: This behavior will be reviewed in the next release. To avoid this behavior you can launch Python Command Prompt (which calls proenv.bat) from the start menu instead of calling it from the Windows Command Prompt. Q: Are admin permissions required to install conda packages? A: If you have an "all users" install of ArcGIS Pro, the default install location is within the Program Files folder. To make changes to this folder location will require the applications to have elevated (admin) credentials. And since the Python environments is stored within the ArcGIS Pro application, then yes installing/removing/updating packages as well as creating and deleting environments will require elevated credentials. To get elevated credentials (admin privileges) from the Windows Application launcher you can right click on Command Prompt, or Python Command Prompt and choose Run as Administrator. Q: When I launch the Python Command Prompt I get an error “Access is denied. Could Not Find proenv.txt. Insufficient privileges. A: This is a warning telling you that you cannot use conda commands to modify conda environments or packages. However, this does not impact using Python itself (including proenv & propy.bat). See previous question regarding administrative permissions. Something else you’d like to ask? Something missing from this Q & A? Please go to https://community.esri.com/community/developers/gis-developers/python and post there. Integrate Development Environments (IDEs) As mentioned above, environments are a ‘best practice’ with the Python community. However you have to tell the IDE which environment it needs to use. For information on using most of the popular IDEs with a conda environment see https://docs.continuum.io/anaconda/ide_integration Do note that PyScripter does not work well with virtual environments, therefore cannot be used with Python included in ArcGIS Pro 1.3. Some good alternatives for PyScripter are PyCharm : a newer and extremely popular IDE with lots of bells and whistles. Python Tools for Visual Studio : a plugin for Microsoft’s very powerful IDE, requires MS Visual Studio (there is a free community edition). WingIDE : another very popular full fledged IDE, there is a free community edition and a more full featured “pay” edition. Spyder : an IDE with a focus on Scientific Python. Very easy to install with conda, simply C:\data> "c:\Program Files\ArcGIS\Pro\bin\Python\Scripts\proenv.bat"
C:\data> conda install spyder Then you can launch spyder from the Windows start menu. Below are examples showing how to update IDE settings for Python Tools for Visual Studio and PyCharm to use arcgispro-py3. The examples use path to environment at C:\Program Files\ArcGIS\Pro\bin\python\envs\arcgispro-py3 which is where you’ll find it if you installed ArcGIS pro for “all users”. If you installed “Only for me” the default path is here C:\Users\ghis3080\AppData\Local\Programs\ArcGIS\Pro\bin\python\envs\arcgispro-py3 Python Tools for Visual Studio Relevant document from Microsoft is here: https://github.com/Microsoft/PTVS/wiki/Python-Environments Select Tools\Options then in the options go to the Python Tools\Environment Options in the tree view, click the Add Environment setting, for a name you can use “arcgispro-py3” (or a name of your choice). Then add the following settings Path : C:\Program Files\ArcGIS\Pro\bin\python\envs\arcgispro-py3\python.exe Windows Path : C:\Program Files\ArcGIS\Pro\bin\python\envs\arcgispro-py3\pythonw.exe All subsequent settings are optional. PyCharm Community edition In File\Settings…, choose Project then Project Interpreter Ignore the drop down list for Project Interpreter, and click the cog button to Add Local, and in the file browser pick C:\Program Files\ArcGIS\Pro\bin\python\envs\arcgispro-py3\python.exe Note that the default for “me only” install is in C:\Users\<user_name>\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3 . This path may not be visible from the file browser. This shortcut can be copy/pasted %LOCALAPPDATA%\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe No other change should be required. To run your script, right click it in the Project window, and choose either Run or Debug Restart PyCharm for the Python Console to use the arcgispro-py3 environment. For more information on conda in ArcGIS Pro, see: Python in ArcGIS Pro 1.3 Harnessing the Power of Python in ArcGIS Using the Conda Distribution
... View more
07-08-2016
09:59 AM
|
15
|
55
|
45892
|
POST
|
Right, it's only in ArcGIS Pro. In ArcMap, you'd have to save as you go as Rebecca Strauch suggested, as the code isn't retained.
... View more
05-31-2016
03:07 PM
|
0
|
0
|
1856
|
POST
|
Hi Darren, In ArcGIS Pro there is. If you look under the folder C:\Users\<user_name>\AppData\Local\ESRI\Local Caches, there is a file name py_repl.history that includes code run from the Python window. -Dave
... View more
05-31-2016
02:41 PM
|
1
|
2
|
1856
|