POST
|
Hi Jeff - many thanks. Apologies for the delayed response. Thanks for the tip on layers being both group AND service layers, didn't think to check that. One final question that is puzzling. In my example mxd. The first set of "World_Imagery" layers is not recognised as a Service Layer. The other two World_Imagery groups can now be identified as supporting service layers after editing my code based on your suggestions. Any ideas why the first set of service layers fails the if lyr.supports("SERVICEPROPERTIES"): test. I guess I could identify the world imagery layer by name, but I'd have to identify all 'older' Esri service layers by name, which is not ideal. Cheers Sam
... View more
10-31-2011
12:50 AM
|
0
|
0
|
380
|
POST
|
Hi Jeff - many thanks for your time. Yep - I think I can work round the remove WMS bug using the top group layer that you suggested. Unfortunately, a can of worms has now opened! I've written a script to test for different types of layers in a given mxd to assist with general data management. However, I have two further queries that have come out of this: #1 (the main problem): I'm trying to identify different layers that support services, using the: lyr.supports("SERVICEPROPERTIES") property of the Layer class in the mapping module. It seems that I can identify WMS successfully, but I'm NOT able to test ArcGIS Server map services hosted on the arcgisonline servers. For example the World Imagery layer set fails the lyr.supports("SERVICEPROPERTIES") test. Please see below code. Also, as requested, please find the map package to mxd/data that I've been using: here #2: Regarding layers that are NOT Feature, Raster or Group Layers, such as CAD annotations, I've been trying to find a way to test what type of layers these are. I've resorted to the Describe class to test that the lyr.source is a 'FeatureClass' dataType. Then hook on to the featureType to expose what type of feature it is. In this case CAD annotations = "CoverageAnnotation". Basically, is this the best way to test Layers in mxd that support DATASOURCE, but are that are not Feature Layers ? Hope this is all clear from the code and the map package...many thanks for your help! import arcpy, os, string
mxdPTH = "c:\temp\example05_services.mxd"
mxd = arcpy.mapping.MapDocument(mxdPTH)
try:
#loop through data frames
for df in arcpy.mapping.ListDataFrames(mxd):
#get layers list & loop through
LyrList = arcpy.mapping.ListLayers(mxd, "", df)
for lyr in LyrList:
#test for group layer:
if lyr.isGroupLayer == True:
print "Group Layer Type: " + lyr.name
#test for raster layer:
elif lyr.isRasterLayer == True:
print "Raster Layer Type: " + lyr.name
#test for feature layer:
elif lyr.isFeatureLayer == True:
print "Feature Layer Type: Layer Name: " + lyr.name
#test for service layer:
elif lyr.supports("SERVICEPROPERTIES"):
print "Layer Supports 'SERVICEPROPERTIES': Service Type: " + lyr.serviceProperties["ServiceType"] + ": Layer Name: " + lyr.name
#test for non-Feature Layers that DO support DATASOURCE
elif lyr.supports("DATASOURCE"):
#invoke describe class
desc = arcpy.Describe(lyr.dataSource)
#test for FeatureClass Type
if desc.datasetType == "FeatureClass":
print "Non Feature-Layer Type: Using Describe Class: FeatureClass Type: " + str(desc.featureType) + ": Layer Name: " + lyr.name
else:
print "Non Feature-Layer Type: Using Describe Class: Non-FeatureClass Type: " + str(desc.datasetType) + lyr.name
#catch other layer types
else:
print "Other Layer Type: Layer Name: " + lyr.name
#get table list & loop
TabList = arcpy.mapping.ListTableViews(mxd, "", df)
for tab in TabList:
print "Table: " + tab.name
del mxd
del TabList
del LyrList
except Exception, e:
import traceback
map(arcpy.AddError, traceback.format_exc().split("\n"))
arcpy.AddError(str(e))
print "Exception: " + str(e)
... View more
10-25-2011
04:07 AM
|
0
|
0
|
380
|
POST
|
Hi - I'm trying to remove WMS layers from an mxd using arcpy. I can successfully remove "MapServer" type services using the below code, but not WMS? Any ideas? Is arcpy.mapping.RemoveLayer the best approach ? I have hundreds of mxds to crawl through and want to remove WMS layers from them. Here's my mxd with two different WMS layers in for reference: here
import arcpy, os
inFName = "wms.mxd"
outFName = "wms_removed.mxd"
pth = r"c:\temp"
inFULLPTH = os.path.join(pth,inFName)
outFULLPTH = os.path.join(pth,outFName)
mxd = arcpy.mapping.MapDocument(inFULLPTH)
for df in arcpy.mapping.ListDataFrames(mxd):
LyrList = arcpy.mapping.ListLayers(mxd, "", df)
print LyrList
for lyr in LyrList:
if lyr.supports("SERVICEPROPERTIES"):
if lyr.serviceProperties["ServiceType"] == "WMS":
print "Removing: " + lyr.name + ": " + lyr.serviceProperties["ServiceType"]
arcpy.mapping.RemoveLayer(df, lyr)
mxd.saveACopy(outFULLPTH)
del mxd
... View more
10-21-2011
02:48 PM
|
0
|
5
|
2452
|
POST
|
Hi Jeff - I'm new to this issue today after finding my python script threw the same error as @dmcclimans found, i.e. python crashes when using findAndReplaceWorkspacePaths on mxds that contain image service layers. I've upgraded to SP3 (build 3200) but I still get the same error. Was this issue definitely fixed with SP3 ?
... View more
10-21-2011
12:15 PM
|
0
|
0
|
654
|
POST
|
Okay I'm answering my own question but this might be useful for others... I achieved the raster to 'banded' polygons by this method: 1. Convert asc to integer tif (Conversion Toolbox) 2. Use the raster calculator tool with the following formula: "grid01.tif" - Mod("grid01.tif",10), this reduces all values in the range of say between 30 to 39 to 30 within my grid01.tif 3. Convert the integer raster to a polygon (using Conversion Toolbox) 4. Edit the polygon attribute table to represent the range of values & add a category based symbology to achieve a banded contour look. I hope this works for others... Cheers
... View more
03-14-2011
07:27 AM
|
1
|
0
|
655
|
POST
|
After a full format of the hard drive and reinstall of the operating system and ArcGIS = problem fixed.
... View more
03-14-2011
06:41 AM
|
0
|
0
|
800
|
POST
|
Using: ArcGIS (ArcView) 10. Have extensions 3DA, SA and xtoolsPro. Hi I have a asc file representing a depth grid. I have an area within this grid that I want to generate a polygon feature class that represents depth grouped into 10m depth ranges. I'll can then symbolise this based on the 10m range classification and importantly undertaken spatial analysis on the polygons with other feature classes. Essentially certain depth ranges represent constraints for my exercise. I can get close to achieving the desired polygon feature class, via two methods, but both seem massively convoluted. Is there a better way? Option 1: via xtoolsPro & SA: 1. convert asc to raster (using conversion toolbox) 2. generate contours at 10m intervals (using SA toolbox) 3. generate a polygon of the extent of a raster (I had this previously, my client's licence area) 4. Split extent polygon by polylines (using xtoolspro) = this gives closed polygons of depth areas at 10m intervals BUT the polygons have no attributes are carried through using xtoolsPro. 5. then I was going to somehow query the polygons and calculate field to populating a depth range. could do this manually or via python maybe? Option 2: via SA only. 1. convert asc to raster (using conversion toolbox) 2. generate a Integer raster from the original float raster (using map algebra tool in SA toolbox) 3. Convert integer raster to polygon (using conversion toolbox) 4. create a new field called 'depth range' in the polygon layer attribute table 5. query by attribute and calculate field, and populate the depth range field for each individual polygon that represents each pixel. 6. merge features based on there depth range. I can script in python (still learning!), which could help with automating the calculate field operations but thought there must be a better way of doing this? Also, I checked out creating a TIN from the raster, but couldn't see an easy way to extract polygons based on ranges of values (I didn't understand TIN tags by the way). Please help? Hope this is clear. Cheers - Sam
... View more
03-09-2011
05:13 AM
|
0
|
2
|
1205
|
POST
|
Hi Stuart - thanks for the link - managed to reauthorise ArcGIS. Unfortunately, I've waived the white flag I'm afraid! I've sent the machine for a full rebuild of the OS. I uninstalled about 50% of my applications (major ones like ArcGIS, Visual Studio and any I could see that were developed using python, eg Inkscape & Blender), in the hope that helped. Gutted the registry of all Esri/ArcGIS keys and removed associated folders. After a complete install of ArcGIS Desktop, still the error. I couldn't believe it! Really appreciate your time and efforts on this. I've learnt a lot regarding the inner workings of ArcGIS! The turn around time for my machine is two days = therefore probably the best bet. Hate giving up though. Great support - thanks. Cheers-Sam
... View more
03-02-2011
12:04 PM
|
0
|
0
|
800
|
POST
|
Hi Stuart...again for more info...I've uninstalled Bentley, AutoDesk 3DS max and Tableau Public and rebooted. 1. Now, there is no folder 'Macrovision Shared' in C:\Program Files (x86)\Common Files. 2. I can't open arcMap/arcCatalog - I get the attached licence error. 3. I can't authorise a SU licence with a ES valid code. See attached error. I tried a second ESU code just to check it wasn't a limit issue. Also, the two ArcGIS files are still in: C:\ProgramData\FLEXnet, though. Clean uninstall/reinstall of ArcGIS Desktop or maybe a 'repair' using the install DVD? I'll check for a reply later, it's 19:00 here. Cheers Sam
... View more
03-01-2011
09:00 AM
|
0
|
0
|
2034
|
POST
|
Hi Stuart...getting closer! Your question = I've downloaded trial copies of Bentley, Autodesk 3DS Max and Tableau Public in the past. I use none of these now. Below is a copy of the now existing fnp_registrations.xml. Here's the contents of fnp_registrations.xml: <?xml version="1.0" encoding="UTF-8" ?> <Activation_Service_Users> <Publishers> <Publisher> <Name>Autodesk</Name> <Products> <Product>Autodesk 3ds Max 2011 32-bit</Product> </Products> </Publisher> <Publisher> <Name>Tableau Software Inc.</Name> <Products> <Product>Tableau Public 5.1</Product> </Products> </Publisher> </Publishers> </Activation_Service_Users> Only Autodesk 3DS Max and Tableau Public are mentioned. Next, I've just renamed the FNPLicensingService.exe after close all apps. Interesting (this may have been the case a few steps ago though). Using IDLE and import arcview and import arcpy calls, I don't get the normal import arcpy RunTime error (going back through the thread I reported this on 02-20-2011 02:45 AM). However, when try calling any arcpy functions/classes, they fail. E.g when I try an export statement on a mxd. The IDLE throws a restart message and does not complete the export? But, launching ArcMap/ArcCatalog = I get the attached licence error message and neither application opens. So that rename definitely did something. Also, importantly no new FNPLicencingService.exe was created. Renaming back to FNPLicensingService.exe. ArcMap opens fine under SU licence. Bingo. Doesn't this mean that neither a new SU authorisation nor a new installation of ArcGIS Desktop DOES NOT CREATE A NEW FNPLicensingService.exe file. This is confirmed by the date modified = 14/06/2010. This is, I think, the date when I installed ArcGIS for the first time on this machine or thereabouts. Corrupted FNPLicensingService.exe file causing the problem? How about uninstalling everything that FlexNet uses (including ArcGIS) and reinstalling ArcGIS which hopefully creates a brand new FNPLicensingService.exe file? Or is there a FlexNet repair function? What do you reckon? Cheers - Sam
... View more
03-01-2011
08:35 AM
|
0
|
0
|
2034
|
POST
|
Hi Stuart. Thanks for the clarification. Okay, followed your instructions: 1. Deauthorising the current SU licence 2. Delete the files: ARCGIS_0038ce00_tsf.data_backup.001 and ARCGIS_0038ce00_event.log in the folder: C:\ProgramData\FLEXnet. Note I've taken a screenshot of the contents prior the delete, attached - are these right? 3. I removed the publisher lines from the file: C:\Program Files (x86)\Common Files\Macrovision Shared\FLEXnet Publisher\fnp_registrations.xml. Note there was an additional file in there, named: FNPLicensingService.exe. Haven't touched that. 4. rebooted 5. reauthorised I different ESU code. Result = still the import arcpy error. I noticed this folder: C:\ProgramData\ESRI, and have taken a screenshot of the contents. Anything in there that we can edit? Notice, the date modified of the styles_idx.dat (144mb) is Jan 2011? I wonder why this date? It seems (very roughly) around the time I've started having problems - could be a coincidence though. Finally, I noticed within ArcGIS Administrator during the reauthorisation that I had to complete my details from blank, empty input cells. This is the first time I'd noticed the input fields were blank, usually they are complete. I think, even on a full uninstall/reinstall of ArcGIS Desktop, the fields were complete with my details. Cheers
... View more
03-01-2011
07:14 AM
|
0
|
0
|
2034
|
POST
|
Stuart. Appreciate the continued assistance. Thanks. Reading your comments. One thing to note. I am not the bona fide administrator for floating licences for my organisation, as I don't have admin rights to the particular servers where the FlexNet Licence Manager installation sits. So, just to check with you. Because I don't have FlexNet Licence Manager installed locally and I don't have access to the file ArcGIS_xxxxxxxx_tsf.data to delete it, as it sits on a virtual server in a different office. Does this make a difference to the import arcpy error? I have tried deauthorising/authorising already, i.e. deauthorising one arcview ESU code, then authorising a different arcview ESU code. I have tried authorising an ESU by 'over the internet' and by downloading and using an 'authorization.respc'. Again, neither authorisations helped with the problem. I don't think I can use the .prvc method, as when using the new customer portal (), EsriUK only allow software downloads. They have prohibited access to any licence information. However, I understand from EsriUK that access is going to be rolled out in the future. I'll try to deauthorise/authorise using a further ESU code again. After that, I think it's got to be an OS reinstall. Cheers
... View more
03-01-2011
04:57 AM
|
0
|
0
|
2034
|
POST
|
Updated. Some progress.... I just changed my licence to a (newly setup) ArcView Floating licence via ArcGIS Administrator. Bingo. IDLE imported arcpy with no errors = therefore, clearly there is a problem with IDLE recognising the single use licence. Unfortunately, I do not have access any extensions over the floating licence, which are essential to my work, therefore need to get the single use licence working! After changing back to singleuse ArcView in ArcGIS Administrator, and reopening a shell causes me to get the import arcpy error again. However, keeping the IDLE shell open even after resetting to singleuse still allows me to carry on calling arcpy functions and classes. Once arcpy is successfully imported I guess it continues to function until the IDLE session ends. Is there anyway to interrogate/analyse my setup or possible problems when I've set the using python using the concurrent licence. Any traceback options? After a successful import arcpy using the floating licence. I tried sys.path, see below. The first entry is a .py that I launched from the IDLE - I'll assume that's normal? Successfully imported arcpy using floating licence: import sys sys.path ['W:\\Projects\\GIS\\_GISRoot\\GISUtilities\\code\\python\\scripts\\updateTextElements', 'C:\\Python26\\ArcGIS10.0\\Lib\\idlelib', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\bin', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\arcpy', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\ArcToolbox\\Scripts', 'C:\\Windows\\system32\\python26.zip', 'C:\\Python26\\ArcGIS10.0\\DLLs', 'C:\\Python26\\ArcGIS10.0\\lib', 'C:\\Python26\\ArcGIS10.0\\lib\\plat-win', 'C:\\Python26\\ArcGIS10.0\\lib\\lib-tk', 'C:\\Python26\\ArcGIS10.0', 'C:\\Python26\\ArcGIS10.0\\lib\\site-packages'] Failed import arcpy using singleuse licence: >>> import sys >>> sys.path ['C:\\Windows\\system32', 'C:\\Python26\\ArcGIS10.0\\Lib\\idlelib', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\bin', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\arcpy', 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.0\\ArcToolbox\\Scripts', 'C:\\Windows\\system32\\python26.zip', 'C:\\Python26\\ArcGIS10.0\\DLLs', 'C:\\Python26\\ArcGIS10.0\\lib', 'C:\\Python26\\ArcGIS10.0\\lib\\plat-win', 'C:\\Python26\\ArcGIS10.0\\lib\\lib-tk', 'C:\\Python26\\ArcGIS10.0', 'C:\\Python26\\ArcGIS10.0\\lib\\site-packages'] Anything incorrect here? Anyone think of another way to test this? Getting close?! Cheers - Sam
... View more
02-28-2011
09:39 AM
|
0
|
0
|
2034
|
POST
|
Hi Stuart Okay I've removed the non 2.6 keys. I've renamed the Esri key in: HKEY_CURRENT_USER\Software\ESRI, and then allowed it to be rebuilt. See attached screenshot. But no luck with the import arcpy error. I've taken a screenshot of the other key location: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ESRI\License10.0. See attached. Do these values look correct? Also, see the values under: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python10.0 as well. Do these look okay? I can't see an environmental variable named ESRI_SOFTWARE_CLASS. So I've attached an xls of all my system variables (and one user variable called 'path'). Maybe you can see an error in this these values or compare with yours? I assume uninstalling/reinstalling just the python component of ArcGIS 10 isn't worth a try? Cheers - Sam
... View more
02-28-2011
09:02 AM
|
0
|
0
|
2034
|
POST
|
Hi Stuart. Thanks. I've put through the changes you suggest, but still have the arcpy error. Note, I didn't know how to set the PYTHONPATH variable to 'empty'. I can't seem to okay the variable edit dialog box when the value is empty. Therefore, I added the following to the PYTHONPATH (none of the paths are enclosed by double quotes, I don't know if this matters?): C:\Program Files (x86)\ArcGIS\Desktop10.0\bin;C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy;C:\Program Files (x86)\ArcGIS\Desktop10.0\ArcToolbox\Scripts I can confirm that the only folder is c:\python26\ArcGIS10.0\ (see attached). Finally, yep I think I had (in desperation a few weeks ago) installed a 64bit version of python on this machine. I did have a registry stuff within this location: HKLM\SOFTWARE\Python. I have deleted these (hope that was the thing to do). Also, I've attached a screenshot of: HKLM\SOFTWARE\Wow6432Node\Python. Can you see I've got legacy stuff from 2.5 and 2.7 versions of python? See attached screenshot for the values. Delete the non 2.6 keys? Cheers
... View more
02-27-2011
11:01 PM
|
0
|
0
|
4007
|
Title | Kudos | Posted |
---|---|---|
1 | 03-14-2011 07:27 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|