Arcpy GIS Pro 2.7 Metadata access issue

165
1
Jump to solution
05-21-2021 07:07 AM
MatthewCarver
New Contributor

Hello,

I'm attempting to transition an ArcMap python toolbox for use with ArcGIS Pro (version 2.7). I can get the toolbox to work, but only if I already have a shapefile prepared to load. I'd like to be able to create a new polygon within Pro and pass that to the toolbox. Based on some previous searches, the Draw capability and subsequent save as a shapefile isn't yet available for Pro. However, I can create a Layer File which has the geometry saved within, but am unable to access via the arcpy API. I've attempted to get this info via the Layerfile metadata which has properties of xmin and ymin (or max) as seen here (https://pro.arcgis.com/en/pro-app/2.7/arcpy/metadata/metadata-class.htm), but I get the error "'Metadata' object has no attribute 'xmax'". The code is below. Any thoughts on how to make this implementation work or another way to get lat/lon coordinates of the geometry in a layerfile?

import arcpy

layerfile = arcpy.mp.LayerFile(C:\Location\of\layerfile)

meta = layerfile.metadata

xmin  = meta.xmin #issue here

 

Thanks,

Matt

0 Kudos
1 Solution

Accepted Solutions
MatthewCarver
New Contributor

The issue arose because I originally was unable to create a feature class. However, after following the directions here (https://pro.arcgis.com/en/pro-app/2.7/get-started/create-points-on-a-map.htm) I was able to create a polygon to be read into my toolbox.

View solution in original post

0 Kudos
1 Reply
MatthewCarver
New Contributor

The issue arose because I originally was unable to create a feature class. However, after following the directions here (https://pro.arcgis.com/en/pro-app/2.7/get-started/create-points-on-a-map.htm) I was able to create a polygon to be read into my toolbox.

View solution in original post

0 Kudos