0

I am attempting to create a custom ArcGIS Pro Python Toolbox tool and some of the geoprocessing tools I use run slowly or not at all if the input DEM or environment is not projected first. I would like to make the tool have the option of selecting the projection with the built in tools like in the Project Raster tool where you have the option to select the coordinate system, but I cannot figure out how to call that.

Select coordinate System button circled in red

The current work around I have discovered is creating a .prj file of the coordinate system you wish to project into and using that file as a parameter to feed into your script like so.

        projection = arcpy.Parameter(
        displayName="Projection for DEM",
        name="projection",
        datatype="DEPrjFile",
        parameterType="Required",
        direction="Input")

Then using arcpy.management.ProjectRaster() to project using the .prj file.

I believe there must be a better way to access the built in Coordinate systems.

2
  • 1
    Are you trying to create your tool in a standard (*.tbx) or Python (*.pyt) toolbox?
    – PolyGeo
    Nov 16 at 22:29
  • 1
    @PolyGeo *.pyt toolbox
    – ffirgd
    Nov 16 at 22:37
2

See Defining parameter data types in a Python toolbox.

I would use either GPCoordinateSystem or GPSpatialReference.

class Tool(object):

    def getParameterInfo(self):
        """Define parameter definitions"""
        param0 = arcpy.Parameter(
            displayName="GPCoordinateSystem",
            name="GPCoordinateSystem",
            datatype="GPCoordinateSystem",
            parameterType="Required",
            direction="Input")

        param1 = arcpy.Parameter(
            displayName="GPSpatialReference",
            name="GPSpatialReference",
            datatype="GPSpatialReference",
            parameterType="Required",
            direction="Input")

        return [param0, param1]

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.