POST
|
Hi James Thanks for that. I did get it to work, using a shapefile as the input parameter. At the moment what I comes out is the same as what I put in, but of course in the code you would do some sort of a transformation i.e. the Clip_Analysis which is in your original code. My code now is this: import arcpy feature_class = arcpy.GetParameterAsText(0) #arcpy.Clip_analysis(lyr1, lyr2, feature_class) feature_class_lyr = arcpy.MakeFeatureLayer_management (feature_class, "feature_class_lyr") feature_set = arcpy.FeatureSet(feature_class) arcpy.SetParameter(1, feature_set) So the input parameter in the toolbox script is set to shapefile, which, if executed from ArcMap looks for an actual shapefile, but from webappbuilder and Portal looks for a zip file (I was wondering if that would work). The output parameter is set to "Output" in the toolbox script and the type is Feature Set. If you then publish this as a geoprocessing service and then use geoprocessing URL in webappbuilder it works (setting the input as shape file of course). Note that in this case (following your example) I am creating a Feature set directly from the feature class (i.e.the shapefile). It looks like you can only create a Feature set from a feature class, so if you need a feature layer for the output to add to the map, I suppose the order is: Input shapefile create feature layer to do certain operations. use CopyFeatures_management to create a feature class from the (now changed) feature layer. Create a feature set from the feature class The feature set is the output added to the map. Would this be right? Thanks Hugo
... View more
04-07-2017
12:13 AM
|
1
|
0
|
384
|
POST
|
Hi I have a python script that outputs to a feature layer. The input is a CSV, but also could be something else. Using this on the desktop in ArcMap works. I then publish this as a geoprocessing service. However when I add the geoprocessing services as a geoprocessing widget in webappbuilder I get an error that I need to specify the feature layer output. What I really want to do is to load a shapefile or a CSV and add that to the map. I had a look at https://github.com/magis-nc/esri-webappbuilder-widget-FileImporter but to create a geoprocessing service, here also I have three output layers (point, line and polygon). The GP service cannot be created in webappbuilder because the feature layer outputs cannot be defined in webappbuilder (in the tool the output must be set to feature layer). Do I have to connect the feature layer output to an existing layer in Portal perhaps? Anyway the short question is when the output of a geoprocessing service is a feature layer, how can this be made to work in webappbuilder with the layer added to a map. A code example that I can use to get me started (i.e. something I can publish as a geoprocessing service) would be great of course. Thanks Hugo
... View more
04-05-2017
02:24 AM
|
0
|
3
|
1457
|
POST
|
Thanks a million, you saved my bacon, it works! I spent hours on this so your reply is greatly appreciated! Thanks again Cheers Hugo
... View more
08-04-2016
01:16 AM
|
0
|
0
|
1027
|
POST
|
Hi I am uploading a File geodatabase using the new arcgis.gis API. Because my Portal is 10.4.1, I should be able to publish the contents of the file geodatabase as feature services. I can upload and publish a shape file, but with similar code, uploading a file geodatabase works, but publishing fails. Here is the code for the uploading the file geodatabase: from arcgis.gis import * gis = GIS("http://<myportalserver>/arcgis","<username", "<password>") data = "C:\\temp\\fgdbtest.zip" # File geodatabase zipped up item_properties = {} item_properties ["type"] = "fileGeodatabase" # I need the type definition, otherwise add did not work fgdbdata = gis.content.add(item_properties, data)# this works, the item is uploaded fgdbdata.publish() # ERROR: I get an error that Nonetype has no attribute publish(), so obviously fgdbdata is empty or None. Yet almost the same code does work when uploading a shape file. Does anyone have an example where a File geodatabase is uploaded as a new item and then the feature classes within published as feature services? Thanks Hugo
... View more
08-03-2016
02:59 AM
|
0
|
3
|
3303
|
POST
|
Hi Curtis Sorry to get back to you so late and thanks for the information. I did resolve this issue some time ago, and you are right, it has to do with having name and label the same, and using simple naming for workbench tools in the toolbox. I think I also make the mistake to confuse the toolbox and toolbox alias (one has the .tbx extension and the other does not). Lastly, one has to close ArcCatalog for any changes in naming etc to take affect, and for python one has to close and restart Idle to recognise the changes made in toolbox and tool names. Cheers Hugo Hi Hugo, While you mentioned that there is "no discernable pattern" for this issue, is there another computer with ArcGIS available to you, to determine whether this issue is reproducible? When it comes to naming, I'm quite cautious and keep all three toolbox names the same (name & label & alias) and stick with alphanumeric characters (staying away from special characters like spaces, dashes & underscores). Similarly, I keep the ETL Tool names simple and identical (name & label). Then for my "first cut" of the Python script, I usually add the ETL Tool to a model and then export to Python. Long ago, I ran into an issue where I could not invoke one of my tools. I noticed that it had the same tool name as another tool, but in a different toolbox. When I renamed the tool to a unique name, then it ran fine again. Unfortunately, I don't currently have the details for this issue, so I don't know whether this was an issue with ArcGIS Geoprocessing or whether I simply hadn't set all of the names/aliases appropriately. While trying to reproduce this issue just now, I created two toolboxes named ETLToolbox and ETLToolbox2, each containing the two ETL Tools named mif2gmlETLTool and mif2gmlETLTool2. My Python script successfully invoked each ETL Tool in each of the toolboxes: import arcpy arcpy.CheckOutExtension("DataInteroperability") arcpy.ImportToolbox("C:/data/ETLToolbox.tbx") arcpy.ImportToolbox("C:/data/ETLToolbox2.tbx") arcpy.mif2gmlETLTool_ETLToolbox("C:\\data\\province.mif", "C:\\data\\out\\province1.gml") arcpy.mif2gmlETLTool2_ETLToolbox("C:\\data\\province.mif", "C:\\data\\out\\province2.gml") arcpy.mif2gmlETLTool_ETLToolbox2("C:\\data\\province.mif", "C:\\data\\out\\province3.gml") arcpy.mif2gmlETLTool2_ETLToolbox2("C:\\data\\province.mif", "C:\\data\\out\\province4.gml") Hopefully something in this post might be helpful. If you have a reproducible scenario, then I'm sure Esri support would like to hear about it! (And so would I!) Curtis Fast. Safe Software, Inc.
... View more
04-18-2012
09:14 PM
|
0
|
0
|
350
|
POST
|
Hi I am trying to import a CSV file into annotation. As a start I tried to make up a CSV file to see if I could import it. I get all sorts of errors though. Is there an example out there somewhere of how to import a CSV file into feature linked annotation? Thanks Hugo
... View more
02-19-2012
03:35 PM
|
0
|
0
|
678
|
POST
|
Hi I have a problem with accessing Data Interoperability (FME) workbenches version 10.0 from python (arcpy) using ArcGIS Desktop 10, service pack 1. The purpose is to run several FME translators as batch scripts without having to open ArcCatalog. It should be possible to import the ArcGIS toolbox in the arcpy environment and then run the workbenches in the toolbox. For example I have a toolbox named "SDE Loads.tbx" which contains several FME workbenches. To import in arcpy then would do the following: arcpy.ImportToolbox("D:/FME/SDE Loads.tbx") A toolbox has a name alias and each FME workbench in the toolbox also has an alias. The way that python is supposed to call an FME workbench (to execute the FME translation) is with the following format: FMEworkbenchAlias_ToolboxAlias(input parameters) However for me this rarely works as most times, the workbench aliases in the toolbox cannot be found. If other objects are created in the toolbox, such as models, they can always be found. This proves that both the toolbox as well as tools in the toolbox can be found by arcpy, with the exception of FME workbenches. Note that the way I check whether models, scripts or FME workbenches can be found in the toolbox is with the following code (necessary python indents may disappear when uploading this message): tools = arcpy.ListTools("*_ToolboxAlias") for tool in tools: print tool print arcpy.Usage(tool) Sometimes (and it is not known why) the workbench tools are listed in the ???print tool??? and print arcpy.Usage(tool) enumeration, but almost all cases, they are not listed at all, only other model tools in the toolbox. When FME workbenches are not listed, the workbenches cannot be executed as they cannot be found. There seems to be no discernable pattern when FME workbenches cannot be found using arcpy (in most cases), or can be found (rarely). Closing and reopening the toolbox, ArcCatalog or even the Windows login account on the computer where this is run from makes no difference. Note that in all cases, in arcpy, I am checking out the date interoperability license extension and include a message that I have successfully obtained the license extension. This is the code : try: if arcpy.CheckExtension("DataInteroperability") == "Available": arcpy.CheckOutExtension("DataInteroperability") print "Checked out \"DataInteroperability\" Extension" else: raise LicenseError except LicenseError: print "Data Interoperability license is unavailable" except: print arcpy.GetMessages(2) Hence not having a license extension is not the cause of not finding the workbench aliases. It must be something else. Would someone be able to help? Thanks very much. Hugo
... View more
09-19-2011
11:02 PM
|
0
|
0
|
796
|
POST
|
I have a problem with accessing Data Interoperability (FME) workbenches version 10.0 from python (arcpy) using ArcGIS Desktop 10, service pack 1. The purpose is to run several FME translators as a batch script without having to open ArcCatalog, the toolbox, and in the toolbox, the Data Interoperability workbenches themselves. This is so the process of importing (and translating) data can be automated. The way that this works (from the documentation) is that you import the ArcGIS toolbox in your arcpy environment and then run the workbenches in the toolbox. For example I have a toolbox named "SDE Loads.tbx" which contains several FME workbenches. To import in arcpy I do the following: arcpy.ImportToolbox("D:/FME/SDE Loads.tbx") A toolbox has a name alias (right click on toolbox, -> properties with the name to be found in the �??Name�?� properties box). Each FME workbench in the toolbox also has an alias (right click on FME workbench, -> properties with the name to be found in the �??Name�?� properties box). The way that python then is suposed to call the FME workbench (to execute the FME translation) is with the following format: FMEworkbenchAlias_ToolboxAlias(input parameters) However this rarely works as most times, the workbench aliases in the toolbox cannot be found. However note that if other objects in the toolbox are created, such as models, they can always be found. This proves that both the toolbox as well as tools in the toolbox can be found, with the exception of FME workbenches. Note that the way I check whether models, scripts or FME workbenches can be found in the toolbox is with the following code: tools = arcpy.ListTools("*_ToolboxAlias") for tool in tools: print tool print arcpy.Usage(tool) Sometimes (and it is not known why) the workbench tools are listed in the �??print tool�?� and print arcpy.Usage(tool) enumeration, but in most cases, they are not listed at all, only other model tools in the toolbox. When FME workbenches are not listed, the workbenches cannot be executed as they cannot be found. There seems to be no discernable pattern in when FME workbenches cannot be found using arcpy (in most cases), or can be found (sometimes). Closing and reopening the toolbox, ArcCatalog or even the Windows login account on the computer where this is run from makes no difference. Note that in all cases, in arcpy, I am checking out the date interoperability license extension and include a message that I have successfully obtained the license extension. This is the code : try: if arcpy.CheckExtension("DataInteroperability") == "Available": arcpy.CheckOutExtension("DataInteroperability") print "Checked out \"DataInteroperability\" Extension" else: raise LicenseError except LicenseError: print "Data Interoperability license is unavailable" except: print arcpy.GetMessages(2) Hence not having a license extension is not the cause of not finding the workbench aliases. It must be something else. Would someone be able to help? Thanks very much. Hugo
... View more
09-18-2011
06:31 PM
|
0
|
2
|
2859
|
Title | Kudos | Posted |
---|---|---|
1 | 04-07-2017 12:13 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|