|
POST
|
Use a workspace and specify a remote database filter. For a python toolbox (.pyt) this is: import os
import arcpy
etc...
class Tool(object):
etc...
def getParameterInfo(self):
param0 = arcpy.Parameter(
displayName="Input Workspace",
name="in_workspace",
datatype="DEWorkspace",
parameterType="Required",
direction="Input")
# Set the filter to accept only remote/enterprise geodatabases
param0.filter.list = ["Remote Database"]
return [param0]
def execute(self, parameters, messages):
"""The source code of the tool."""
path = parameters[0].valueAsText
fc = "Zone"
fc_path = os.path.join(path, fc)
... View more
06-19-2023
02:20 PM
|
2
|
0
|
1794
|
|
POST
|
Unrelated to your issue, but this line is not correct temp = arcpy.env.scratchGDB + "\\temp" From the Scratch GDB documentation: The Scratch GDB environment is read-only; you cannot set the location directly. Instead use Scratch Workspace temp = arcpy.env.scratchWorkspace + "\\temp"
... View more
06-16-2023
01:30 PM
|
0
|
1
|
1493
|
|
POST
|
@Trippetoe wrote: Maybe i'm quibbling here (plus don't fully understand conda environments), but isnt the purpose of a conda environments to remove dependencies on other 'environments'? I think the error message is a little misleading. But regardless, the version of arcpy in your cloned environment needs to match the version of ArcGIS Pro to ensure binary compatibility, this is a common issue with other python packages that use C/C++ extension libraries. If your script that uses arcgis API doesn't use arcpy (and doesn't require any arcpy functionality), you can create a stand-alone conda env with arcgis that doesn't include arcpy and thus doesn't depend on a specific version of ArcGS Pro. E.g. from the command line: conda create -n arcgisapi -c esri arcgis https://developers.arcgis.com/python/guide/anaconda
... View more
06-09-2023
06:12 PM
|
0
|
0
|
4551
|
|
POST
|
Region Group (Spatial Analyst) Lookup (Spatial Analyst) on count
... View more
05-23-2023
02:21 AM
|
0
|
0
|
934
|
|
POST
|
Please clarify whether you mean "6 features" or 6 feature classes. A geodatabase (either file or enterprise) can hold multiple feature classes. A feature class can have multiple features. To use a file system analogy, a directory/folder (geodatabase) can hold many text files (feature classes). A text file can store many lines of text (features). Truncate means to remove all features from a feature class, the feature class is not removed. The code I provided does that for the 6 specified feature classes. Do you actually mean you have 6 features you need to delete from a single feature class in one gdb and then replace those features with 6 features selected from another feature class in a different gdb? If so, truncate is definitely not what you want. You need to select the features you want to delete (e.g. select by attribute/location tools or make feature layer tool with a where clause) in your script and then run delete features tool.
... View more
05-18-2023
05:20 PM
|
0
|
0
|
1393
|
|
POST
|
Get the output csv filename as a parameter (output direction) and use df.to_csv to write it out. input_csv = arcpy.GetParameterAsText(0)
output_csv = arcpy.GetParameterAsText(1)
df = pandas.read_csv(input_csv)
#do some calcs
df.to_csv(output_csv, index=False)
... View more
05-18-2023
04:41 AM
|
1
|
0
|
4134
|
|
POST
|
The main issue you'll find is that arcpy.mp.ArcGISProject("CURRENT") won't work outside of ArcGIS Pro. This includes scripts run from an IDE or external python interpreter or script tools/python toolbox tools started from ArcGIS Pro but running in the background. You can use arcpy.mp outside of ArcGIS Pro, but to instantiate an ArcGISProject object, you need to use arcpy.mp.ArcGISProject(r"Drive:\Path\to\project.aprx) and understand that any changes you make won't be reflected in an open ArcGIS Pro project, but you need to save the ArcGISProject object and then open it in Pro to see changes.
... View more
05-16-2023
06:04 PM
|
0
|
0
|
1323
|
|
POST
|
Assuming two separate geodatabases with all feature classes having the same name and schema: feature_classes = ["fc1", "fc2", "fc3", "etc..."]
for feature_class in feature_classes:
arcpy.management.TruncateTable(f"dir:/path/to/connection1.sde/schema.{feature_class}")
arcpy.management.Append([f"dir:/path/to/connection2.sde/schema.{feature_class}"],
f"dir:/path/to/connection1.sde/schema.{feature_class}",
"TEST")
... View more
05-09-2023
04:44 PM
|
0
|
1
|
1418
|
|
POST
|
Have you tried without explicitly requesting the SHAPE field? # fields I want to include in SEDF
fields2use = ['A', 'B', 'CAPCLASS', 'LANES', 'SPEED']
... View more
05-06-2023
07:07 PM
|
2
|
1
|
3695
|
|
POST
|
Not an answer to the question as asked, but you may wish to consider expanding your toolkit... Look at open-source options such as GDAL/OGR for commandline data conversion or QGIS for a full GIS suite. Converting a bunch of KMZs to something ArcGIS can consume is pretty trivial.
... View more
04-30-2023
06:00 PM
|
1
|
0
|
1569
|
|
POST
|
And `yield` is the syntax for creating a generator function.
... View more
04-28-2023
12:23 PM
|
0
|
0
|
1313
|
|
POST
|
Inline variable substitution But I didn't know that was applicable to tools as well as model builder.
... View more
04-22-2023
12:36 AM
|
2
|
0
|
1599
|
|
POST
|
@AFackler_NAPSG wrote: Not sure how exactly to run that tool, but Pro is locally installed version 3.0.3 Example at the bottom of the page Dan linked to.
... View more
04-18-2023
12:17 AM
|
0
|
1
|
2080
|
|
POST
|
The ToolValidator class is used by script tools in custom toolboxes (legacy .tbx or new .atbx), not by Python Toolboxes (.pyt). In python toolboxes (.pyt) all the validation is done is the updateMessages and updateParameters methods of the tool class itself Customize tool behavior in a Python toolbox
... View more
04-11-2023
06:13 PM
|
1
|
2
|
4868
|
|
IDEA
|
Yes, this is a very different idea to "Link - Allow support for virtual / computed fields in Oracle/SQL Server versioned geodatabases" or native database functionality. It's more akin to storing label/popup definitions in a layer (lyrx/aprx map layer) in that the virtual fields would be properties of the layer, not the data source and could be generated on the fly using Arcade or python expressions. A simple use case that I constantly run up against - data source: read-only corporate data. I need to do some calcs on an attribute (concat two or more fields, split a field, change case of some text values, etc.) e.g for using in symbology. I know I can manually change symbology entries or group them, but that's manual and tedious and I know I can export the table or feature class to a copy that I can edit, but that's an issue for data management. And query layers are fiddly and don't work on non-GDB datasources.
... View more
04-10-2023
11:35 PM
|
0
|
0
|
2473
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-24-2022 03:08 PM | |
| 1 | 07-30-2025 03:00 PM | |
| 1 | 06-10-2025 08:06 PM | |
| 5 | 05-20-2025 07:56 PM | |
| 1 | 05-04-2025 10:34 PM |