POST
|
I ran into this same problem. for anyone who needs it this is how I solved it. add using System.Reflection; to the using calls of the RunPython.cs add using ArcGIS.Desktop.Core.Geoprocessing; to the using calls of the RunGP.cs This resolved all errors for me cheers
... View more
12-16-2020
03:47 PM
|
0
|
0
|
65
|
POST
|
I have modified my question based on your suggestions, thanks!
... View more
12-14-2020
01:21 PM
|
0
|
0
|
226
|
POST
|
Hello, I have a python process that I am converting from Oracle to POSTGRES and I seem to be having issues accessing the POSTGRES database multiple times in the same python action. For example I can run a search cursor on a table inside the POSTGRES database one time and get results (this search cursor is executed with a WITH clause). when I try to run another search cursor on the same table i get a RUNTIME error. If I skip the second cursor and move along in my process I get another RUNTIME error when I attempt an arcpy.da.Walk on the database itself. To me, and I am a complete novice, it seems like accessing the database multiple times is causing the error, perhaps because of some sort of lock placed on it by POSTGRES. If anyone has any advice i would apricate it. Thanks Example here is a search cursor function that works every time i run it in my python script. this is the first time the database is accessed. def _select_rows_from_table(self, sde_connection_path, table_name, fields, where_clause):
row_array = []
with arcpy.da.SearchCursor(os.path.join(sde_connection_path, table_name), fields, where_clause) as table_cursor:
for a_row in table_cursor:
row = dict()
idx = 0
for field_name in fields:
row[field_name] = a_row[idx]
idx = idx + 1
row_array.append(row)
return row_array I have tried to run many different functions after this and I always get a runtime error. here is an example of one that does not work. the workspace passed is the exact same as the one passed in the first function. def _get_table_mapping(self, workspace):
mapping = dict()
feature_datasets = list()
feature_datasets.append(None)
dataset_walker = arcpy.da.Walk(workspace, datatype=['FeatureDataset'])
for unused1, feat_datasets, unused2 in dataset_walker:
for fds in feat_datasets:
feature_datasets.append(fds)
for a_feat_dataset in feature_datasets:
wspace = workspace
if a_feat_dataset is not None:
wspace = os.path.join(workspace, a_feat_dataset)
walker = arcpy.da.Walk(wspace, datatype=['FeatureClass', 'Table'])
for junk1, junk2, things in walker:
for a_thing in things:
pieces = a_thing.split('.')
base_name = pieces[len(pieces) - 1].lower()
mapping[base_name] = a_thing
return mapping it may also help to know that i can execute all of these against the POSTGRES database inside of ArcGIS. Also as far as I know the database is geodatabse enabled. I can see all of the features in ArcGIS and have published a few services against the data.
... View more
12-14-2020
07:48 AM
|
0
|
2
|
250
|
POST
|
success sort of! so the below will work which is similar to what you suggested however, it only working inside of Arc (for example importing the classes into ArcMap) or in Visual Studio Code. it will not work in Idle for some reason, I have no idea why. so in short if anyone sees this issue try a different IDE before you start going crazy! "objectid = {0}".format(objectid_field)) Update that did not do it! I have been debugging my problem and I think the problem may have to do with the where clause in a search cursor. for context i have another search cursor that works on the same dataset, the only difference this one uses objectid where the other uses a text field. below is my function def _select_row_from_table ( self , sde_connection_path , table_name , fields , where_clause 😞 with arcpy.da.SearchCursor(os.path.join(sde_connection_path, table_name), fields, where_clause) as table_cursor: for a_row in table_cursor: row = dict () idx = 0 for field_name in fields: row[field_name] = a_row[idx] idx = idx + 1 return row the where clause is this currently. i have tried many many things and nothing seems to work. 'objectid = 99' this is not the only thing i have tried, its just the most recent. reminder this is a POSTGRES dataset. any help would be apricated thanks!
... View more
12-08-2020
07:47 AM
|
0
|
0
|
263
|
POST
|
thank you for your response. It is named objectid, i have been staring at this field for a while now and its burned into my brain! I should have also mentioned that if I open the python window in Arc I can create the search query. The only thing i can think of is that the OBJECTID value returned by my program is incorrect but i do not see how. all i am doing is getting that value then dropping it into the query.
... View more
12-08-2020
07:24 AM
|
0
|
0
|
278
|
POST
|
I have a search cursor i am trying to use in a larger program and to spite my best efforts I cannot get it to work, I believe it has to do with the syntax of the WHERE clause within the search cursor. The kicker is I have another search cursor that does work on the same dataset . I am trying to select from a POSTGRES database using the OBJECTID field, I have tried many different things but nothing every time i run it i am getting the below error cannot open 'DATASET' <type 'exceptions.RuntimeError'> this is the text i am using in the search cusor that does work (field is a text field) "STATUS = '1'" This is what i currently have in the where clause of the search cursor that is not working: "OBJECTID = " +object_id_value I have tried implementing the field delimiters via the arcpy (https://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-functions/addfielddelimiters.htm) but got a goose egg on results. I
... View more
12-08-2020
07:09 AM
|
0
|
4
|
286
|
POST
|
Hello, I have some annotation feature classes that I am displaying in runtime via an MMPK. certain features in certain feature classes seem to modify the display slightly, in this example all new lines are being ignored so this: Bt A C is being displayed as below in runtime as this: BtAC I have looked over the attributes and the only meaningful difference is the Angle attribute. This is happening on several features in this feature class and other. Pro Version 2.6.2 ArcGIS Runtime SDK 100.6 any help would be apricated thanks!
... View more
10-29-2020
12:43 PM
|
0
|
1
|
196
|
POST
|
In ArcGIS Pro, there is the option to symbolize a feature dependent on scale. I have several maps I am looking to convert and want to modify the .lyrx file (is JSON format) to accept these alternate symbols. with an open JSON and a simple dataset I found the alternateSymbols list in data['layerDefinitions'][0]['renderer']['groups'][0]['classes']['alternateSymbols'] when i try to import my other symbols with minScale and maxScale Values, i get nothing. If I just dump them into 'classes' they DO show in arcmap, but are not scale dependenent. this is the function I am using a the moment def outload_into_one_file ( detail , normal ) : detail = detail normal = normal out_file = os . path . splitext ( normal ) [ 0 ] + "_COMBINED.lyrx" with open ( detail , "r" ) as jsonFile : detail_data = json . load ( jsonFile ) with open ( normal , "r" ) as jsonFile : normal_data = json . load ( jsonFile ) detail_base = detail_data [ 'layerDefinitions' ] [ 0 ] detail_classes = detail_base [ 'renderer' ] [ 'groups' ] [ 0 ] [ 'classes' ] normal_base = normal_data [ 'layerDefinitions' ] [ 0 ] normal_classes = normal_base [ 'renderer' ] [ 'groups' ] [ 0 ] [ 'classes' ] detail_classes_dict = { } for x in detail_classes : detail_classes_dict . update ( { x [ "label" ] : x } ) for x in normal_classes : x [ 'maxScale' ] = 251 x [ 'minScale' ] = 3000 for x in normal_classes : cls = detail_classes_dict . get ( x [ 'label' ] ) cls [ 'maxScale' ] = 250 cls [ 'alternateSymbols' ] = [ ] cls [ 'alternateSymbols' ] . append ( x ) with open ( out_file , "w" ) as jsonFile : json . dump ( detail_data , jsonFile )
... View more
07-15-2020
07:33 AM
|
0
|
0
|
101
|
POST
|
I am attempting to remove all Annotation Subclass layers from a list that is generated from a Map inside of ArcPro. From what I can tell the subclasses must be a "Layer" inside of Pro. I cannot find a method to conclusively distinguish which layers are annotation subclasses. l = [ list of Layer Objects ] for x in l : if x : try : desc = arcpy . Describe ( x ) print ( desc . featureClass . featuretype ) except : print ( f "{x} cannot be described" ) This will yield "Annotation" for both the Annotation layer, and its subclasses. desc . name This will yield the Name of the Annotation layer for all subclasses for x in l : print x generates an error **NameError: The attribute 'longName' is not supported on this instance of Layer** as soon as it hits the Annotation subclass
... View more
07-02-2020
08:19 AM
|
0
|
0
|
95
|
Online Status |
Offline
|
Date Last Visited |
12-30-2020
03:11 PM
|