Final Project from my GIS 280 - Geospatial Programming and Web Services class.
# Class: Gis 280
# Script Name: wesleyFinalProject.py
# Purpose: To convert csv to data points on a map, then export a map series
# Author: Wesley Chou
# Date: 11/24/2020
# Python Version: 3.6
# files needed :
# la county base map (credits to Professor Roberts of RHC and Claremont Colleges)
# trader joe's locations csv file (converted from data above)
import arcpy
arcpy.env.workspace = "true"
arcpy.env.overwriteOutput = True
# setting up parameters to be passed in from ArcGIS user input
workspace = arcpy.GetParameterAsText(0)
inputFile = arcpy.GetParameterAsText(1)
outputFC = arcpy.GetParameterAsText(2)
outputPDF = arcpy.GetParameterAsText(3)
aprx = arcpy.mp.ArcGISProject("current")
maps = aprx.listMaps("Map")[0]
maps.addDataFromPath(inputFile)
# variables for x and y data points (found in csv file)
x = "Longitude"
y = "Latitude"
try:
# tool execution part one
arcpy.management.XYTableToPoint(inputFile, outputFC, x, y)
# creates a new feature layer from the inputFile and it's x,y data and into outputFC
# -----------------------------------------------------------------
# tool execution part two
maps.addDataFromPath(outputFC) # needed to update map series base
# without updating, the map series output defaults to setup layout (no points, just map)
p = arcpy.mp.ArcGISProject("current")
l = p.listLayouts()[0]
if not l.mapSeries is None:
ms = l.mapSeries
if ms.enabled:
ms.exportToPDF(outputPDF)
# creates map series PDF (multiple pages of pre-formatted layout)
except Exception as e:
print("Error: " + e.args[0])
# resouces used : https://pro.arcgis.com/en/pro-app/tool-reference/data-management/xy-table-to-point.htm
# https://pro.arcgis.com/en/pro-app/arcpy/mapping/mapseries-class.htm