More

Setting parameters in ArcGIS desktop script

Setting parameters in ArcGIS desktop script


How would I create the parameterspixel_typeandnumber_of bands(as found in MosaicToNewRaster) as user inputs at the start of my own script?

ERROR 000714: Error in script BatchMosaic. Error in executing: cmd.exe /C C:ErosionScriptsBATCHM~1.PY "C:finalprojectMosaic" "C:finalprojectMosiac_out" "mosaicme" "32_BIT_SIGNED" "1" Failed to execute (BatchMosaic).

import arcpy, os, sys #User parameters. in_workspace = sys.argv[1] out_workspace = sys.argv[2] output_name = sys.argv[3] def getParameterInfo(self): param4 = arcpy.Parameter( pixel_type="Input value") param4.filter.type = "ValueList" param4.filter.list = [""] def getParameterInfo(self): param5 = arcpy.Parameter( number_of_bands="Input value") param5.filter.type = "ValueList" param5.filter.list = [] #Attempts to mosaic all raster files in root and sub directories. rasters = [] for dirpath, dirnames, filenames in arcpy.da.Walk(in_workspace, topdown = True, datatype="RasterDataset", type = "TIF"): for filename in filenames: rasters.append(os.path.join(dirpath, filename)) #Pixel Type and Number of Bands must be manualy inserted to script. arcpy.MosaicToNewRaster_management(';'.join(rasters), out_workspace, output_name, pixel_type = "32_BIT_UNSIGNED", number_of_bands = 1)


Your code is quite nice, thanks for the arcpy.da.walk example, there is a bit of confusion about feeding a tool the correct values and sys.argv, arcpy.GetParameter and arcpy.GetParameterAsText… I always use sys.argv, mostly because it's less typing, it also takes the confusion out of supplying the correct type to the tool.

import os, sys, arcpy BaseFolder = sys.argv[1] OutFolder = sys.argv[2] OutName = sys.argv[3] SpatRel = sys.argv[4] PixelType = sys.argv[5] NumBands = sys.argv[6] rasters = [] for dirpath, dirnames, filenames in arcpy.da.Walk(BaseFolder , topdown = True, datatype="RasterDataset", type = "TIF"): # thanks for that, I used to use os.walk() but this is much handier for filename in filenames: rasters.append(os.path.join(dirpath, filename)) arcpy.MosaicToNewRaster_management(';'.join(rasters),OutFolder,OutName,SpatRel,PixelType,number_of_bands = NumBands) # note, skipping cell size

This is your script with a few brief modifications. Note that I've skipped the CellSize parameter on the tool by using the parameter by namenumber_of_bands = NumBands, this can be done for any optional parameter.

To add this to a toolbox you need to specify one script parameter persys.argv[](or GetParameterAsText):

The data type in the second column has nothing to do with what is passed to the tool, it is only used by the tool to help you find the correct items… for example if you specify 'feature class' the tool will only let you browse for a feature class, but the script is not passed a feature class - it is passed a string with the path to the feature class.

If you want to control the pixel types to a list of values you do that in the tool dialog:

And this cuts down the options you are given to pick from… which is also handy on a monday morning - when you're struggling to remember was that Int32, Int_32, 32bit or 32_bit_int?? by giving only a few options (all valid) there's no chance of giving the wrong value to the tool… be sensible though, most rasters are 8 bit unsigned, 32 bit float or some integer value. If you don't deal with 1 bit images or 64 bit Int for example then don't put it in the list!


Territory Solution layer to setup parameters

Territory Level to modify

Measure type for building territory shape

  • STRAIGHT_LINE_DISTANCE — straight line distance will be used for calculate Maximum Distance, Minimum Distance and Minimum Distance Between Territory Centers
  • DRIVE_DISTANCE — results of ArcGIS Network Analyst extension solver with Distance Units will be used for calculate distances
  • DRIVE_TIME — results of ArcGIS Network Analyst extension solver with Time Units will be used for calculate distances

This parameter can adjust preference between fine shape of territories and resulted balance of variables. Low value means good balance but worse shape, high value means good shape but worse balance.

This option overrides previously set balancing and minimum attribute capacity constraints to ensure a more ideal territory shape. Territories can only acquire features that are closest to their territory center, instead of centers of surrounding territories. This essentially puts less emphasis on statistical inputs and applies a heavier weight to maintaining a territory boundary.

  • USE_ONLY_CLOSEST_FEATURES — only closest features will be used for growing territories
  • USE_ALL_FEATURES — all surround features will be used for growing territories

Location of non-fixed (created not from seed points) centers can be defined by this parameter. Territory center’s location will be automatically changed on every territory shape change, but always inside of territory shape.

  • GEOMETRIC_CENTER — territory center will place into geometric center of territory (center of territory’s bound box)
  • MEAN_CENTER — territory center will be placed into territory’s mean center by spatial locations with or without specified summary attribute
  • DENSITY_CENTER — territory center will be placed into territory’s density center by spatial locations with or without specified summary attribute
  • FARTHEST_POINT_FROM_ALL_BOUNDARIES — territory center will be located within a territory farthest from all its territory boundaries

Territories can be calculated using the geographic


Coordinate transformation in arcpy

As part of a script I need to convert coordinates from one SRS to another. This is the code I have so far, but I am missing the bit in the middle. I have done some extensive googling but I was not able to find a solution so I would appreciate some assistance.

It will first create a Feature named 'base' with input SRS and then creates your output feature with output SRS.

You can set the environment to save the output in a specific location.

It will first create a Feature named 'base' with input SRS and then creates your output feature with output SRS.

You can set the environment to save the output in a specific location.

additionally you can cross check by :

Jai, thank you very much this is exactly what I wanted!

Edit: Is it possible to do this without saving to a file? I will be doing this on thousands of coordinates so this is undesirable as it will place increased load on the disk, and slow down the process.

by curtvprice

Is it possible to do this without saving to a file?

Yes, you can use the arcpy shape method .projectAs() . This can be tricky but should work great!

Projects a geometry and optionally applies a geotransformation.

To project, the geometry needs to have a spatial reference, and not have an UnknownCoordinateSystem . The new spatial reference system passed to the method defines the output coordinate system. If either spatial reference is unknown the coordinates will not be changed. The Z- and measure values are not changed by the ProjectAs method.


Procedure

To batch export attachments from a feature class in ArcGIS Pro, create a script tool from a Python script that enables exporting attachments in batches from a feature class. Run the script tool by providing the parameters required.

  1. Copy and paste the following script into a Notepad, and save it as ExportAttachments.py.
  1. In ArcGIS Pro, right-click a toolbox in the Catalog pane, and click New > Script

  1. On the script tool property page, set the properties of the script tool as follows:
    1. In the General section, type the Name and Label for the script tool. For example, type ExportAttachments as the Name, and Export Attachments as the Label. The label displays the name of the script tool, as shown in the Geoprocessing pane.
    2. Click the Browse icon next to the Script File field, and navigate to the location of the script file saved in Step 1. Select the script and click OK.
    3. Check the Store tool with relative path check box.

    1. In the Parameters section, type Attachments Table in the first row of the Label column, and set the Data Type as Table. This is the first parameter of the script tool and it defines the table containing the attachments to export.
    2. In the second row, add a second parameter with the Label name as Output Location, and set the Data Type as Folder. This parameter defines the folder to locate the exported attachments.

    1. Double-click to open the created script tool. Set the parameters of the tool as follows to export the attachments in a batch.
      1. In the tool dialog box, browse for the attachments table containing the attachments to export in the Attachments Table parameter.
      2. In the Output Location parameter, select a folder to save the exported attachments, and click OK.
      3. Click Run.

      The attachments are successfully exported in a batch, and located in the folder defined in the Output Location parameter.

      Create a server certificate

      To be able to create an HTTPS connection between ArcGIS Web Adaptor and your server, the web server requires a server certificate. A certificate is a digital file that contains information about the identity of the web server. It also contains the encryption technique to use when establishing a secure channel between the web server and ArcGIS Server. A certificate must be created by the owner of the website and digitally signed. There are three types of certificates, CA-signed, domain, and self-signed, which are explained below.

      CA-signed certificates

      Certificate authority (CA) signed certificates should be used for production systems, particularly if your deployment of ArcGIS Server is going to be accessed from users outside your organization. For example, if your server is not behind your firewall and accessible over the Internet, using a CA-signed certificate assures clients from outside your organization that the identity of the website has been verified.

      In addition to being signed by the owner of the website, a certificate may be signed by an independent CA. A CA is usually a trusted third party that can attest to the authenticity of a website. If a website is trustworthy, the CA adds its own digital signature to that website's self-signed certificate. This assures web clients that the website's identity has been verified.

      When using a certificate issued by a well-known CA, secure communication between the server and the web client occurs automatically with no special action required by the user. There is no unexpected behavior or warning message displayed in the web browser, since the website has been verified by the CA.

      Domain certificates

      If your server is located behind your firewall and using a CA-signed certificate is not possible, using a domain certificate is an acceptable solution. A domain certificate is an internal certificate signed by your organization's certificate authority. Using a domain certificate helps you reduce the cost of issuing certificates and eases certificate deployment, since certificates can be generated quickly within your organization for trusted internal use.

      Users within your domain will not experience any of the unexpected behavior or warning messages normally associated with a self-signed certificate, since the website has been verified by the domain certificate. However, domain certificates are not validated by an external CA, which means users visiting your site from outside your domain will not be able verify that your certificate really represents the party it claims to represent. External users will see browser warnings about the site being untrusted which may lead them to think that they are actually communicating with a malicious party and be turned away from your site.

      Create a domain certificate and enable HTTPS

      Successful completion of the ArcGIS Enterprise configuration wizard requires HTTPS to be enabled in IIS on the machine where the base deployment is installed.

      If HTTPS is not enabled, the configuration wizard will not complete and report the following error message:

      The Web Adaptor URL https://mymachine.mydomain.com/server cannot be reached. Please check that HTTPS has been enabled for your web server. For instructions on enabling HTTPS, navigate to the Help Topic: Introducing ArcGIS Enterprise > ArcGIS Enterprise Builder > Plan a base deployment.

      In most cases, your IT administrator will give you certificates and bind them to HTTPS port 443.

      In 2017, Chrome began only trusting certificates with a Subject Alternative Name (SAN) parameter, which cannot be configured when creating a certificate in the IIS Manager application.

      If you are using IIS and need to create a domain certificate, see Create a domain certificate, which provides a script to run on your machine that will create the appropriate certificate and bind it to HTTPS port 443.

      Self-signed certificates

      A certificate signed only by the owner of the website is called a self-signed certificate. Self-signed certificates are commonly used on websites that are only available to users on the organization's internal (LAN) network. If you communicate with a website outside your own network that uses a self-signed certificate, you have no way to verify that the site issuing the certificate really represents the party it claims to represent. You could actually be communicating with a malicious party, putting your information at risk.

      If you use a self-signed certificate, expect to see web browser and ArcGIS Desktop warnings about the site being untrusted. When a web browser encounters a self-signed certificate, it will typically display a warning and ask you to confirm that you want to proceed to the site. Many browsers display warning icons or a red color in the address bar as long as you are using the self-signed certificate.

      Create a self-signed certificate in IIS

      In IIS Manager, do the following to create a self-signed certificate:

      1. In the Connections pane, select your server in the tree view and double-click Server Certificates .

      The final step is for you to bind the self-signed certificate to HTTPS port 443. See Binding the certificate to the website below for instructions.


      Setting parameters in ArcGIS desktop script - Geographic Information Systems

      The Mosaic Dataset Configuration Script (MDCS) is a Python script that reads parameters stored in an xml file in order to create, configure, and populate a mosaic dataset.

      If you want to try out MDCS, review the documentation included in the repo for instructions, and download the suggested sample data from ArcGIS Online.

      This repo also contains MDTools, a command line tool that simplifies some common management tasks when working with rasters in a mosaic dataset.

      • Automate the creation of multiple mosaic datasets
      • Configure multiple mosaic datasets using XML files
      • Built-in verbose reporting and logging system
      • Command line usage via batch files
      • Compatible with ArcMap 10.1+ and ArcGIS Pro 1.0+ (MDTools requires ArcMap 10.6.1+ or ArcGIS Pro 2.2+)
      • Use MDTools to do the following:
        • Embed raster proxies in a mosaic dataset
        • Perform search and replace for embedded raster proxy strings
        • Export file locations to a text file for rasters in a mosaic dataset in a given area of interest (AOI) and with a specific cell size
        1. Download the ZIP file (called mdcs-py-master.zip)
        2. Create a folder called Image_Mgmt_Workflows in the root of your C: drive
        3. Unzip the contents of the MDCS ZIP file into the Image_Mgmt_Workflows folder

        To get started with MDTools:

        1. Navigate to C:/Image_Mgmt_Workflows/mdcs-py/MDTools_Setup.zip
        2. Unzip the contents, then double-click MDTools_Setup.exe to install the tools.
        3. Refer to the MDTools documentation to get started.
        • Dowload sample data for use with MDCS.
        • See the Managing Elevation workflow scripts on ArcGIS Online for an example application of MDCS.

        Find a bug or want to request a new feature? Please let us know by submitting an issue.

        Anyone and everyone is welcome to contribute.

        Licensed under the Apache License, Version 2.0 (the "License") you may not use this file except in compliance with the License. You may obtain a copy of the License at

        Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

        A copy of the license is available in the repository's license.txt file.


        Syntax

        The input datasets containing the data to be appended to the target dataset. Input datasets can be point, line, or polygon feature classes, tables, rasters, annotation feature classes, or dimensions feature classes. Each input dataset must match the data type of the target dataset.

        The existing dataset where the input datasets' data will be appended.

        Specifies whether the schema (field definitions) of the input datasets must match the schema of the target dataset for data to be appended.

        • TEST —Input dataset schema (field definitions) must match the schema of the target dataset. An error will be returned if the schemas do not match.
        • NO_TEST —Input dataset schema (field definitions) do not have to match the schema of the target dataset. Any fields from the input datasets that do not match the fields of the target dataset will not be mapped to the target dataset unless the mapping is explicitly set in the Field Map parameter.

        Controls how the attribute fields from the input datasets are transferred or mapped to the target dataset. This parameter can only be used if the schema_type parameter is NO_TEST .

        Because the input datasets' data is appended to an existing target dataset that has a predefined schema (field names and types), fields cannot be added or removed from the target dataset. You can set merge rules for each output field.

        • First—Use the input fields' first value.
        • Last—Use the input fields' last value.
        • Join—Concatenate (join) the input fields' values.
        • Sum—Calculate the total of the input fields' values.
        • Mean—Calculate the mean (average) of the input fields' values.
        • Median—Calculate the median (middle) of the input fields' values.
        • Mode—Use the value with the highest frequency.
        • Min—Use the minimum value of all input fields' values.
        • Max—Use the maximum value of all input fields' values.
        • Standard deviation—Use the standard deviation classification method on all input fields' values.
        • Count—Find the number of records included in the calculation.

        You can use the ArcPy FieldMappings class to define this parameter.

        The subtype description to assign to all new data that is appended to the target dataset.

        Derived Output

        The updated target dataset.


        Unattended uninstallation and installation

        When you install Survey123 Connect or the Survey123 field app on Windows , macOS , or Ubuntu , you're also provided with script files to help perform future unattended uninstallations or installations.

        To prepare for these actions, follow these steps after first installing the app, using Survey123 Connect as an example:

        1. Browse to the location where the app was installed, which, by default on Windows , is C:Users<username>ApplicationsArcGISArcGISSurvey123Connect .
        2. Copy the following files to another location on your computer, for example folder called, InstallScripts :
          • silent-install-controller.qs
          • silent-uninstall-controller.qs
          • silent-uninstall-install-ArcGISSurvey123Connect
        3. When the time comes to install a new version of Survey123 Connect , copy the app installation file to InstallScripts , and rename the file to a name that will remain constant, for example, Survey123ConnectInstallFile.exe .

        Once this location has been established, the .qs and script files don't change. To perform unattended installations and uninstallations, only the installation files will need to change.

        If you have multiple apps that are based on AppStudio on your computer, you only need one copy of silent-install-controller.qs and silent-uninstall-controller.qs . Copy only the different silent-uninstall-install-appName script files to InstallScripts alongside the .qs files.

        By default, the unattended installation and uninstallation will be performed in the background, with no user interface to show progress. To display a user interface for these unattended installations and uninstallations, add the command line parameter showui=true when running the script files.

        If your scripts are from a version earlier than Survey123 3.10, update your scripts to the latest version to ensure that hiding the interface is the default behavior.

        Uninstall only

        To uninstall the app using these scripts, browse to InstallScripts in a command window and enter the following command:

        The period at the end is important, as it indicates that nothing will be installed.

        Uninstall and install, or install only

        To install the app, browse to the folder in a command window and enter this command:

        The same command uninstalls all existing versions of the app before installing the new version, allowing you to upgrade the app with one command.


        Mdhntd

        How many photos should I take If I'm given a phone to take a picture?

        Multithreading program stuck in optimized mode but runs normally in -O0

        What is it called when at university there are two subjects being held at the same time?

        How Would Civilisations on Different Planes of a Cube Planet Interact?

        Tourist / simple city maps to print

        Are independent variables necessarily "independent" and how does this relate to what's being predicted?

        Is there a name for this phenomenon?

        Why is Ian Blackford allowed to speak in the Commons while having crossed the line?

        Authentication versus Authorisation

        Ethan Finds the Maximum Element

        Opposite of Coupon Collector / Birthday Problems?

        How can I manage my team to maintain a reasonable productivity when my employer doesn't treat employees well?

        How do I convert the number of seconds passed since 1 January 2001 00:00 to human readable date in bash?

        Practically, how does an 'observer' collapse a wave function?

        What are those two silvery objects resting on Ben Kenobi's table when R2-D2 plays Princess Leia's message?

        Will the price change on Airbnb if I provide my ID later?

        "When you Frankenstein a team together. " - Is "Frankenstein" a new verb?

        What is the four-dimensional equivalent of pi?

        Is there more concise way to say "tomorrow morning" than "mañana por la mañana"?

        Can an MP who didn't vote for the 2nd reading of a bill propose amendments to it?

        Using Enable Attachments tool in ArcGIS Desktop

        Exporting features with attachments for use outside ArcGIS?How to enable adding both feature classes / tables and layers from TOC to a script tool parameter input?Adding photos as attachments to geotagged photo points in ArcMap?Setting domains for feature class using ArcGIS OnlineArcGIS ArcPy update attachments table rowsCannot display attachments in ArcGIS ProAdding attachments to feature with ArcPy

        I am working through the tutorial for ArcGIS Collector - Step 8, which says : To allow users to take pictures in the field and attach them to their assessment reports, enable attachments on the feature class you just created. To do so, right-click the feature class in the Catalog window, select Manage, and click Create Attachments.

        This is supposed to be available under the Data Management Tools - but all I see is a Photo tool, which does not appear to work the same way.

        Step 1 - need to "Enable Attachments" - but can't find the right tool
        Step 2 - right click feature class in catalog window.

        Other users posted that you cannot add attachments to geodatabases with Desktop version, then why is this an instruction under this tutorial, which is for Desktop version?

        I am using ArcGIS Desktop 10.2.1.

        Can you edit your Question to include the license level of ArcGIS for Desktop that you are using, please? You need Standard or Advanced in order to be able to enable attachments.

        I am working through the tutorial for ArcGIS Collector - Step 8, which says : To allow users to take pictures in the field and attach them to their assessment reports, enable attachments on the feature class you just created. To do so, right-click the feature class in the Catalog window, select Manage, and click Create Attachments.

        This is supposed to be available under the Data Management Tools - but all I see is a Photo tool, which does not appear to work the same way.

        Step 1 - need to "Enable Attachments" - but can't find the right tool
        Step 2 - right click feature class in catalog window.

        Other users posted that you cannot add attachments to geodatabases with Desktop version, then why is this an instruction under this tutorial, which is for Desktop version?

        I am using ArcGIS Desktop 10.2.1.

        Can you edit your Question to include the license level of ArcGIS for Desktop that you are using, please? You need Standard or Advanced in order to be able to enable attachments.

        I am working through the tutorial for ArcGIS Collector - Step 8, which says : To allow users to take pictures in the field and attach them to their assessment reports, enable attachments on the feature class you just created. To do so, right-click the feature class in the Catalog window, select Manage, and click Create Attachments.

        This is supposed to be available under the Data Management Tools - but all I see is a Photo tool, which does not appear to work the same way.

        Step 1 - need to "Enable Attachments" - but can't find the right tool
        Step 2 - right click feature class in catalog window.

        Other users posted that you cannot add attachments to geodatabases with Desktop version, then why is this an instruction under this tutorial, which is for Desktop version?

        I am using ArcGIS Desktop 10.2.1.

        I am working through the tutorial for ArcGIS Collector - Step 8, which says : To allow users to take pictures in the field and attach them to their assessment reports, enable attachments on the feature class you just created. To do so, right-click the feature class in the Catalog window, select Manage, and click Create Attachments.

        This is supposed to be available under the Data Management Tools - but all I see is a Photo tool, which does not appear to work the same way.

        Step 1 - need to "Enable Attachments" - but can't find the right tool
        Step 2 - right click feature class in catalog window.

        Other users posted that you cannot add attachments to geodatabases with Desktop version, then why is this an instruction under this tutorial, which is for Desktop version?

        I am using ArcGIS Desktop 10.2.1.

        Can you edit your Question to include the license level of ArcGIS for Desktop that you are using, please? You need Standard or Advanced in order to be able to enable attachments.

        Can you edit your Question to include the license level of ArcGIS for Desktop that you are using, please? You need Standard or Advanced in order to be able to enable attachments.

        Can you edit your Question to include the license level of ArcGIS for Desktop that you are using, please? You need Standard or Advanced in order to be able to enable attachments.

        Can you edit your Question to include the license level of ArcGIS for Desktop that you are using, please? You need Standard or Advanced in order to be able to enable attachments.


        Using environment settings in Python

        Each tool has a set of parameters it uses to execute an operation. Some of these parameters are common among all tools, such as a tolerance or output location. These parameters may obtain their default values from a geoprocessing environment that all tools utilize during their operation. When a tool is executed, the current environment settings can also be used as global input parameter values. Settings such as an area of interest, the spatial reference of the output dataset, and the cell size of a new raster dataset can all be specified with geoprocessing environments.

        A script can be executed in several different ways. It can be run as a script tool in an ArcGIS application, such as ArcMap. It can also be run from another script or by itself from a Python window . When a script is run inside a tool from an ArcGIS application or from another geoprocessing script, the environment settings used by the calling application or script are passed to it. These settings become the default settings used by the tool's script when it is executed. The called script may alter the settings passed to it, but those changes are only used within that script or by any other tool it may call. Changes are not passed back to the calling script or application. The environment model can best be described as cascading, where values flow down to any process that uses the geoprocessing environment.


        Watch the video: Week 10: 2 Introduction to ArcGIS Script Tools