1

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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Nov 16, 2021 at 22:18
2
  • 1
    Are you trying to create your tool in a standard (*.tbx) or Python (*.pyt) toolbox? Commented Nov 16, 2021 at 22:29
  • 1
    @PolyGeo *.pyt toolbox Commented Nov 16, 2021 at 22:37

1 Answer 1

3

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

answered Nov 17, 2021 at 1:34

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.