Hello,
I'm attempting to add a layer to a map in Jupyter Notebook but am receiving the error:
UnboundLocalError<SPAN class="punctuation token">:</SPAN> local variable <SPAN class="string token">'fc_layer_definition'</SPAN> referenced before assignment
My code is as follows:
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> <SPAN class="operator token">*</SPAN>
<SPAN class="keyword token">import</SPAN> pandas <SPAN class="keyword token">as</SPAN> pd
gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
df <SPAN class="operator token">=</SPAN> pd<SPAN class="punctuation token">.</SPAN>read_csv<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'file.csv'</SPAN><SPAN class="punctuation token">)</SPAN>
df_layer <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>import_data<SPAN class="punctuation token">(</SPAN>df<SPAN class="punctuation token">)</SPAN>
m <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>map<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
m<SPAN class="punctuation token">.</SPAN>add_layer<SPAN class="punctuation token">(</SPAN>df_layer<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
My dataframe is as follows:
ID ID2 NAME CODE2 LONGITUDE_MEASURE LATITUDE_MEASURE
| 2 | 2100519 | xyz | 2100519-001 | -122.960000 | 38.250000 |
|---|
| 3 | 2100519 | xyz | 2100519-002 | -122.950000 | 38.250000 |
|---|
| 4 | 2100519 | xyz | 2100519-004 | -122.957714 | 38.257917 |
|---|
I do not understand what variable is being referenced before the assignment. Thank you