Hello! I'm wrapping up my coordenates converter but when I go and run it in ArcGis Pro it got the error down below. I've checked PATH (both) and checked the intalation of the app itself. If you know how to fix it please don't hesitate to reply!
Thanks in advance.
PD: I'll also post the code
import arcpy
arcpy.env.workspace = r"C:\Users\Usuario\Desktop\DocsUSACH\SIG_TAREA1"
print('Welcome to the coordinates converter, where you can convert to and from UTM-Geographics, all within the WGS84 Datum and between the 18S-19S UTM zone')
# Toma de Datos
formato = input('Please choose the input coords to convert, either being (G)eographic or (U)TM, please remember the geographic coords HAS to be in the WGS84 Datum: ')
formato = formato.lower()
if formato == 'g':
print('Please remember that if you input the coordinates in degrees it may not be as precise as the asked format')
# RECOLECCION DE DATOS
long_input = input('Enter the longitude in a numeric format (not in degrees) and with dot (.) not comma (,): ')
lat_input = input('Enter the latitude in a numeric format (not in degrees) and with dot (.) not comma (,): ')
long_input = long_input.replace(',', '.').replace('°', '')
lat_input = lat_input.replace(',', '.').replace('°', '')
try: # BLOQUE TRY PARA PROBLEMAS DE FORMATO POR USUARIO
long = float(long_input)
lat = float(lat_input)
# Crear punto y geometría en ArcGIS con coordenadas Geográficas
punto_entrante = arcpy.Point(long, lat)
geometria_entrante = arcpy.PointGeometry(punto_entrante, arcpy.SpatialReference(4326)) # 4326 es el código para WGS84
# Convertir coordenadas geográficas a UTM
huso = int((long + 180) / 6) + 1
if huso == 18:
punto = arcpy.Point(long, lat)
hemisferio = 'S'
utm_sr = arcpy.SpatialReference(32718) # CODIGO SRID PARA HUSO 18
point_geometry = arcpy.PointGeometry(punto, utm_sr)
elif huso == 19:
punto = arcpy.Point(long, lat)
hemisferio = 'S'
utm_sr = arcpy.SpatialReference(32719) # CODIGO SRID PARA HUSO 19
point_geometry = arcpy.PointGeometry(punto, utm_sr)
else:
print('Invalid coordinates, please try again with coords within the 18S and 19S.')
exit()
utm_sistref = arcpy.SpatialReference(32611) # Código para UTM
geometria_salida = geometria_entrante.projectAs(utm_sistref)
if geometria_salida is not None:
este_utm = geometria_salida.firstPoint.X
norte_utm = geometria_salida.firstPoint.Y
# Mostrar las coordenadas UTM
print('UTM East', este_utm)
print('UTM North', norte_utm)
print('Zone', str(huso) + 'S')
else:
print('Failed to project coordinates to UTM. Please check the input coordinates.')
except ValueError:
print('Invalid input. Please enter numeric coordinates')
# Inicio Segunda opción
elif formato == 'u':
print('Please remember that if you input the coordinates in degrees it may not be as precise as the asked format')
# Recolección de Datos
utm_y_input = input('Enter the northing of the coordinate in a numeric format, no degrees: ')
utm_x_input = input('Enter the easting of the coordinate in a numeric format, no degrees: ')
utm_zone = int(input('Enter the UTM zone corresponding to the coordinates, only between (18)S or (19)S: '))
utm_y_input = utm_y_input.replace(',', '.').replace('°', '')
utm_x_input = utm_x_input.replace(',', '.').replace('°', '')
try:
utm_y = float(utm_y_input)
utm_x = float(utm_x_input)
# Determinación código de transformación
utm_codigo = int(32600 + utm_zone)
# Crear objeto Point usando UTM y su código correspondiente
utm_point = arcpy.Point(utm_x, utm_y, None, None, None, utm_codigo)
# Definir sistema de referencia (Spatial Reference) para WGS85 y realizar conversión
sr_wgs84 = arcpy.SpatialReference(4326)
geografic_point = utm_point.projectAs(sr_wgs84)
geo_x = geografic_point.X
geo_y = geografic_point.Y
# Devolver resultados
print('Your new coordinates in the WGS84 Datum are:', 'X=', geo_x, 'Y=', geo_y)
except ValueError:
print('Invalid input. Please enter numeric coordinates.')
else:
print('Invalid input format. Please choose (G)eographic or (U)TM: ')