POST
|
This is has been fixed ArcGIS Pro version 3.2. In the Updating Data Sources help topic, go to the CIM Section, and check out the third code sample: # Reference project, map and layer
p = arcpy.mp.ArcGISProject(r'C:\Projects\USA.aprx')
m = p.listMaps('USA')[0]
l = m.listLayers('States')[0]
# Get the layer's CIM definition
lyrCIM = l.getDefinition('V3')
# Update the sql query where clause for the layer
sql = lyrCIM.featureTable.dataConnection.sqlQuery
newsql = sql.replace("WHERE SUB_REGION = 'Mtn'", "WHERE SUB_REGION = 'Pacific'")
lyrCIM.featureTable.dataConnection.sqlQuery = newsql
# Set the layer's CIM definition
l.setDefinition(lyrCIM) The above sample changes the sql query, but other properties of the Query Layer, such as the Display Field, can also be updated using similar logic.
... View more
11-07-2023
05:26 PM
|
1
|
0
|
254
|
IDEA
|
This is possible using ArcGIS Pro version 3.2. In the Updating Data Sources help topic, go to the CIM Section, and check out the third code sample: # Reference project, map and layer
p = arcpy.mp.ArcGISProject(r'C:\Projects\USA.aprx')
m = p.listMaps('USA')[0]
l = m.listLayers('States')[0]
# Get the layer's CIM definition
lyrCIM = l.getDefinition('V3')
# Update the sql query where clause for the layer
sql = lyrCIM.featureTable.dataConnection.sqlQuery
newsql = sql.replace("WHERE SUB_REGION = 'Mtn'", "WHERE SUB_REGION = 'Pacific'")
lyrCIM.featureTable.dataConnection.sqlQuery = newsql
# Set the layer's CIM definition
l.setDefinition(lyrCIM) The above sample changes the sql query, but other properties of the Query Layer can also be updated.
... View more
11-07-2023
05:22 PM
|
0
|
0
|
415
|
IDEA
|
10-25-2023
01:18 PM
|
0
|
0
|
355
|
IDEA
|
Layer.dataSource will give you the URL of basemaps, or any service layer. There is also a new feature available with ArcGIS Pro version 3.2 that will help with your workflow - the ArcGISProject class now has a listBasemaps function that will return all the basemaps that are available in a project. You can then use the return object from listBasemaps in Map.addBasemap(). Note that addBasemap is available in version 3.1 and earlier. In regards to Layer.serviceProperties available in ArcMap 10x, all the service properties for any service layer are available by reading the the layer's CIM using ArcGIS Pro. There will be new code samples added to the help soon for this workflow. For more information, see these topics: https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/updatingandfixingdatasources.htm and https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/python-cim-access.htm
... View more
10-17-2023
02:43 PM
|
0
|
0
|
390
|
POST
|
Check out sample #6 here...it should be a good starting point https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/convertwebmaptoarcgisproject.htm
... View more
05-04-2023
01:03 PM
|
2
|
0
|
424
|
IDEA
|
Is your File GDB feature class residing in a feature data set? If so, there might be another line you need to add to the CIM script.
... View more
05-01-2023
11:45 AM
|
0
|
0
|
950
|
IDEA
|
Alfred, Try a basic workflow first, and see if you can get it to work. Here is a sample using the CIM: import arcpy
aprx = arcpy.mp.ArcGISProject("C:\\Temp\\Shp2FGDB.aprx")
m = aprx.listMaps('SHP')[0]
lyr = m.listLayers('ShpStates')[0]
lyrCIM = lyr.getDefinition("V3")
lyrCIM.featureTable.dataConnection.workspaceConnectionString = "DATABASE=C:\\Temp\\States.gdb"
lyrCIM.featureTable.dataConnection.workspaceFactory = "FileGDB"
lyrCIM.featureTable.dataConnection.dataset = "States"
lyr.setDefinition(lyrCIM)
aprx.saveACopy("C:\\Temp\\Output.aprx")
print('done') And here is the same workflow using updateConnectionProperties and the connectionProperties dictionary. import arcpy
aprx = arcpy.mp.ArcGISProject("C:\\Temp\\Shp2FGDB.aprx")
m = aprx.listMaps('SHP')[0]
lyr = m.listLayers('ShpStates')[0]
find_dict = {'connection_info': {'database': 'C:\\Temp'},
'dataset': 'ShpStates.shp',
'workspace_factory': 'Shape File'}
replace_dict = {'connection_info': {'database': 'C:\\Temp\\States.gdb'},
'dataset': 'States',
'workspace_factory': 'File Geodatabase'}
lyr.updateConnectionProperties(find_dict, replace_dict)
aprx.saveACopy("C:\\Temp\\\Output.aprx")
print('done')
... View more
04-21-2023
02:02 PM
|
0
|
0
|
1013
|
IDEA
|
Can you show me your code? For the shapefile example, are you re-sourcing something like, c:\data1\shapefile1.shp to c:\data2\shapefile2.shp?
... View more
04-13-2023
06:54 AM
|
0
|
0
|
1071
|
IDEA
|
Alfred, There are a few new things in the 3.1 Updating Data Sources help that might help with this. 1.) In the first batch of samples, look at sample #6. New at 3.1, you dont need to know anything about the source of the existing layer. You can supply None in the first parameter. E.g. aprx.updateConnectionProperties(None, r'C:\Projects\YosemiteNP\New_Data\Yosemite.gdb') 2.) Check out the sub sections entitled Updating data sources via the CIM and Changing a layer's dataset. Changing a layer's dataset via the CIM might be easier than using the ConnectionProperties dictionary in your case. Those aforementioned sections might be more in line with what you are trying to accomplish. There is a trail of breadcrumbs that will lead you to a list of the workspace factory values. (But I admit that it's not the easiest thing to find. I will investigate a way to make this easier in the future.) If you follow the link to the Python CIM Access topic, then to the CIM Spec, they are listed in the CIM spec here. Search for WorkspaceFactory on that page. Workspace factory types. Property Value Description SDE 0 Enterprise geodatabase. FileGDB 1 File geodatabase. Raster 2 Raster. Shapefile 3 Shapefile. OLEDB 4 OLEDB. Access 5 Microsoft Access. DelimitedTextFile 6 Delimited text file. Custom 7 Custom. Sql 8 SQL query layer. Tin 9 TIN. TrackingServer 10 Tracking server. NetCDF 11 NetCDF. LASDataset 12 LAS dataset. SQLite 13 SQLite. FeatureService 14 Feature service. ArcInfo 15 Arc/INFO Coverage. Cad 16 CAD. Excel 17 Microsoft Excel. WFS 18 Web feature service. StreamService 19 Stream service BIMFile 20 BIM file. InMemoryDB 21 In memory database. NoSQL 22 NoSQL. BigDataConnection 23 Big Data connection. KnowledgeGraph 24 Knowledge Graph connection. NITF 25 NITF connection.
... View more
04-10-2023
01:40 PM
|
0
|
0
|
1097
|
POST
|
Hello James, I would recommend taking it to Support. The other bugs mentioned in this thread are related to specific workflows.
... View more
08-05-2022
10:11 AM
|
0
|
0
|
1592
|
DOC
|
@jsingh_ripco @HeatherAlexander @CarlMorrison with regards to the exporting issues, you can log a tech support issue here: https://support.esri.com/en/products/desktop/arcgis-desktop/arcgis-pro. That way, an analyst can take a look at your project.
... View more
06-29-2022
02:21 PM
|
0
|
0
|
3274
|
POST
|
David, Yes, the 2.8 ArcGIS Pro fixes will be included in ArcGIS Server 10.9.1.
... View more
09-03-2021
01:19 PM
|
1
|
0
|
805
|
POST
|
I might have a workaround for this. The following script will add a relate to a layer in a ArcGIS Pro project. This should work if run outside of ArcGIS Pro, like in a Python IDE or the python command line. The relate will get saved with the ArcGIS Pro project. It uses arcpy CIM, which you can learn about here. aprx = arcpy.mp.ArcGISProject(r"C:\temp\RelateTest_NoRelate.aprx")
m = aprx.listMaps()[0]
lyr = m.listLayers()[0]
# Get the layer's CIM definition
lyrCIM = lyr.getDefinition('V2')
# Create a new CIM data connection to the feature class to be used in the relate
dc = arcpy.cim.CreateCIMObjectFromClassName('CIMStandardDataConnection', 'V2')
# Specify the geodatabase
dc.workspaceConnectionString = "DATABASE=c:\\temp\\Data\\FGDB.gdb"
# Specify the workspace type
dc.workspaceFactory = "FileGDB"
# Specify the dataset name
dc.dataset = "us_cities"
# Create a new CIM relate
r = arcpy.cim.CreateCIMObjectFromClassName('CIMRelateInfo', 'V2')
# Specify the data connection to the data - use the one you created above
r.dataConnection = dc
# Set all the other relate properties
r.foreignKey = "ST_ABBREV"
r.primaryKey = "STATE_ABBR"
r.cardinality = "esriRelCardinalityOneToMany"
r.name = "cim_relate"
# Relates must be stored in a list, even if there is just one
my_relates = []
my_relates.append(r)
lyrCIM.featureTable.relates = my_relates
# Set the layer's CIM definition
lyr.setDefinition(lyrCIM)
# Save a copy of the project
aprx.saveACopy(r"c:\temp\RelateTest_CIM.aprx")
print('done')
... View more
04-09-2021
03:59 PM
|
0
|
1
|
1534
|
POST
|
Jorge, thanks for the feedback. Yes, we know in some cases referencing a project via CURRENT and executing updateConnectionProperties is slow. You can speed up the time by setting the validate parameter in updateConnectionProperties to False. It is also faster if you run the script out of the app. That being said, I havent seen speeds as slow as 4 mins per layer. What type of data are the layers?
... View more
09-28-2020
10:21 AM
|
0
|
1
|
2263
|
Title | Kudos | Posted |
---|---|---|
1 | 11-07-2023 05:26 PM | |
2 | 05-04-2023 01:03 PM | |
1 | 09-03-2021 01:19 PM | |
1 | 01-02-2013 08:59 AM | |
2 | 07-31-2020 03:30 PM |
Online Status |
Offline
|
Date Last Visited |
02-20-2024
04:38 PM
|