<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Creating and Using Panel Data Using ArcGIS Defined Location Cubes
Step1:  Example
Step2:  Open Panel Cube From NetCDF File for Analysis
Step3:  Number of Locations and Time Periods
Step4:  List Variables
Step5:  View Mann-Kendall Trend Results in PANDAS Data Frame
Step6:  Get 3D Analysis Variable
Step7:  Use PySAL to Analyze LISA Markov Transitions
Step8:  View Transistion Probabilities
<ASSISTANT_TASK:>
Python Code:
import os as OS
import arcpy as ARCPY
import SSDataObject as SSDO
import SSPanelObject as SSPO
import SSPanel as PANEL
ARCPY.overwriteOutput = True
Explanation: Creating and Using Panel Data Using ArcGIS Defined Location Cubes
End of explanation
inputFC = r'../data/CA_Counties_Panel.shp'
outputCube = r'../data/CA_Panel.nc'
fullFC = OS.path.abspath(inputFC)
outputCube = OS.path.abspath(outputCube)
fullPath, fcName = OS.path.split(fullFC)
ssdo = SSDO.SSDataObject(inputFC)
uniqueIDField = "MYID"
timeField = "YEAR"
analysisField = "PCR"
panelObj = SSPO.SSPanelObject(inputFC)
requireGeometry = panelObj.ssdo.shapeType.upper() == "POLYGON"
panelObj.obtainData(uniqueIDField, "YEAR", "1 Years", fields = [analysisField],
                    requireGeometry = requireGeometry)
panelCube = PANEL.SSPanel(outputCube, panelObj = panelObj)
varName = panelCube.fieldNames[0]
panelCube.mannKendall(varName)
panelCube.close()
Explanation: Example: Per Capita Incomes Relative to National Average in California (1969 - 2010)
Create Defined Locations Cube from Repeating Shapes Feature Class
Run Mann-Kendall Trend Statistic
Save to NetCDF File
End of explanation
panel = PANEL.SSPanel(outputCube)
Explanation: Open Panel Cube From NetCDF File for Analysis
End of explanation
print("# locations = {0}, # time periods = {1}".format(panel.numLocations, panel.numTime))
Explanation: Number of Locations and Time Periods
End of explanation
print(panel.obtainVariableList())
Explanation: List Variables
End of explanation
import pandas as PANDAS
locations = panel.locationLabel[0]
z = panel.obtainValues('PCR_TREND_ZSCORE')
pv = panel.obtainValues('PCR_TREND_PVALUE')
d = {'PCR_TREND_ZSCORE':z, 'PCR_TREND_PVALUE':pv}
df = PANDAS.DataFrame(d, index = locations)
print(df.head())
Explanation: View Mann-Kendall Trend Results in PANDAS Data Frame
End of explanation
data = panel.obtainValues(analysisField)
print(data.shape)
Explanation: Get 3D Analysis Variable
End of explanation
import pysal as PYSAL
w = PYSAL.open(r"../data/queen.gal").read()
lm = PYSAL.LISA_Markov(data.T, w)
print(lm.classes)
Explanation: Use PySAL to Analyze LISA Markov Transitions
End of explanation
print(lm.p)
panel.close()
Explanation: View Transistion Probabilities
End of explanation
<END_TASK>