Select to view content in your preferred language

AGOL Notebook Script Tool Parameter Help

144
0
2 weeks ago
JaredPilbeam2
MVP Alum

No info on script tool parameters to be found here: https://doc.arcgis.com/en/arcgis-online/get-started/get-started-with-notebooks.htm

Generally speaking, how does a parameter work? Is it like a Pro script tool parameter? How do I fill it out? For example, for Pro you just put arcpy.GetParameterAsText(0) in place of the variable in the script. And then based on the 0 index you fill out the parameters for the tool. 

I have a short script I'd like to make into a tool to ultimately be used in ExB. It geocodes a CSV file. There should only be two variables concerning the user: the CSV in file and the CSV out file. Once you fill out the Add parameter pane and enter something in the Default value (?) box you can save. It then gives you the option to insert the variable. Not sure where to insert it? 

JaredPilbeam2_0-1776884251990.png

''' 
csv file > df > gdf > shp
'''

import pandas as pd
import geopandas as gpd

# read csv file
f = r'C:\pathto\infile.csv'
file = pd.read_csv(f)

# convert to dataframe
df = pd.DataFrame(file)

# geocode
gdf = gpd.tools.geocode(df['ADDRESS'])

# extract lat long from geometry and put into dataframe
df['latitude'],df['longitude'],df['geometry'] = gdf.geometry.y, gdf.geometry.x, gdf.geometry

# generate GeometryArray of shapely Point geometries from x, y(, z) coordinates.
gdf = gpd.GeoDataFrame(df, geometry=gpd.points_from_xy(df.longitude, df.latitude), crs="EPSG:4326") #crs is optional

# write to shapefile
gdf.to_csv(r'C:\pathto\outfile.csv')

JaredPilbeam2_1-1776884329317.png

 

 

 

0 Kudos
0 Replies