Add finding_grazing_allotment notebook#428
Conversation
|
@jyaistMap could you do the first round of reviews for this notebook? |
jyaistMap
left a comment
There was a problem hiding this comment.
Hi @priyankatuteja
This is a good notebook sample. overlay_layers is difficult to write about because of the terminology. I made some suggestions, but will leave it up to you and @AtmaMani as to whether any of them improve upon what you've done!
- In section Necessary Imports
- Change
from datetime import datetimetoimport datetime as dtand change the cells that call datetime accordingly: Thedatetimemodule and thedatetimeclass behave strangely. When I import thedatetimeclass and trystr(datetime.now().microsecond), I receive:
- Change
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-11-438ff5d9724d> in <module>()
1 basin_overlay = overlay_layers(grazing_allotments,
2 hydro_units,
----> 3 output_name="OverlayAllotmentWithBasin" + str(datetime.now().microsecond)
4 )
AttributeError: module 'datetime' has no attribute 'now'-
In section Assigning basin information to allotments
- Remove the sentence about the
outside_org = Trueparameter in the Get data for analysis section. Seems unnecessary and out of place since it's not used in the code cell. - Change It combines two layers to create a layer containing new features where input features overlap to something like It combines two layers, an analysis layer and an overlay layer, into a new layer, creating new features and combining attributes from the two layers according to the overlay method selected.
- To better visualize and comprehend the analysis results, it might help to add some
map_widgetsto see the initialhydro_units,grazing_allotments, andstreamslayers before the overlay analysis - Add a map widget that zooms in on
grazing_allotmentsandhydro_unitsbefore the overlay:
m = gis.map("Oregon") m m.add_layer(grazing_allotments) m.add_layer(hydro_units) m.zoom = 11 m.center = [42.18, -119.13]
Then after the analysis, create a new map with the same code to show how new features were created:
m2 = gis.map("Oregon") m2 m2.add_layer(basin_overlay.layers[0]) m2.zoom = 11 m2.center = [42.18, -119.13]
- Remove the sentence about the
-
In Mapping and exploring basin overlay results
- Labeling the
basin_overlay_df.groupby('BASIN_NAME').size()as the variabledfis confusing because the function returns aSeriesobject - Change phrasing in We see that Powder basin is the largest basin, followed by Burnt. to be more explicit. We see that Powder Basin intersected the largest number of grazing allotments, followed by Burnt and Lower John Day basins.
- The descriptive text of the first map widget states Grazing allotments are color coded by the basin they are in, but then the
plot()usesallot_namefor thecolparameter. I think it should beBASIN_NAME - The
overlay_layersoutput is a hosted feature layer that carries over numerous original geometry values from the analysis layer:Shape__Area,Shape__Length,Shape_Leng, and corresponding..._1and aPERIMETERattribute for values from the overlay layer. It makes the resulting dataframe cluttered, confusing and difficult to interpret. Perhaps removing attributes that pertain to the original geometry of the analysis and overlay layers makes a more readable dataframe:basin_overlay_df.drop(labels=["Shape__Area", "Shape__Area_1", "Shape_Leng_1", "Shape__Length_1", "Shape__Length", "shape_Leng", "PERIMETER"], axis=1)
- Labeling the
-
In the Display grazing allotments within a particular basin section
- Might help when drawing the allotments in a basin to add the basin itself to the map widget before plotting the dataframe:
map2.add_layer(hydro_units.query(where="BASIN_NAME = ' MIDDLE FORK JOHN DAY'") john_day_df.spatial.plot(map_widget=map2)
-
In Display a particular grazing allotment to see which basins it is in
- Rename to Display a particular grazing allotment to see which basins intersect it
- When I plot the dataframe I receive a warning
C:\Program Files\ArcGIS\Pro\bin\Python\envs\most-recent-api\lib\site- packages\arcgis\features\geo\_accessor.py:2276: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: http://pandas.pydata.org/pandas- docs/stable/indexing.html#indexing-view-versus-copy self._data['OBJECTID'] = list(range(1, self._data.shape[0] + 1))
- I think it would help to plot the
hydro_unitsto illustrate the results better:allot_04003_basins = hydro_units.query(where="BASIN_NAME in (' MIDDLE FORK JOHN DAY', ' NORTH FORK JOHN DAY')") map3.draw(allot_04003_basins)
- I think it would help to plot the allotments with a unique value renderer on the
BASIN_NAMEcolumn to illustrate the splitting of the original allotment at basin boundaries:
allot_df.spatial.plot(map_widget=map3, renderer_type='u', col='BASIN_NAME')
- I receive the same warning as above when plotting the spatially enabled dataframe
- Centering the map display and zooming in might help to illustrate the features as well:
map.zoom = 9 map.center = [44.85, -119.42]
-
In Assigning allotment information to streams
- The phrasing of the first sentence is ...this time overlaying grazing allotments with streams..., but the code block has streams as the analysis layer and grazing allotments as the overlay layer, which to me would be better expressed as ...this time overlaying streams with grazing allotments...:
stream_overlay = overlay_layers(streams, grazing_allotments, output_name="StreamOverlay" + str(datetime.now().microsecond))
- The phrasing of the first sentence is ...this time overlaying grazing allotments with streams..., but the code block has streams as the analysis layer and grazing allotments as the overlay layer, which to me would be better expressed as ...this time overlaying streams with grazing allotments...:
-
In Mapping and exploring stream overlay results
- Unless the attributes from the
grazing_allotmentsoverlay layer are needed in the outputstream_overlayitem, I suggest removing them after creatingstream_overlay_df. I think theFID_GRAZING_ALLOTMETS_GRAZING_A,FID_GRAZING_ALLOTMETS_STREAMS,OBJECTID,Shape__Area,Shape_Length,Shape__Length_1,objectid_1, andshape_Lengfields are unnecessary to subsequent analyses, cause confusion when looking at the dataframe and generally interfere with following the flow of the analysis st_dfis technically aSeriesobject, assigning it a variable name withdfin the name is confusing- Change
neighboringtocontiguousin the John Day River is the third longest free-flowing river... sentence - the meaning of neighboring in this sentence is vague - Change 'THREE FINGERS' grazing allotment passes through a lot of streams. to _ Thirty-six (36) stream segments from 17 different streams pass through the 'THREE FINGERS' grazing allotment._
- The caption for
map4would make more sense to say Map of streams overlaid by grazing allotments. I'd also add thegrazing_allotmentslayer to the map for context.
- Unless the attributes from the
-
In Display particular stream to find out allotments that pass through it,
- Rename to Display a stream and grazing allotments it intersects to stay consistent with the language of the tool
- Change intro sentence to We will filter the
analysis_layerfor a specific stream: to stay consistent with the language of the tool - I suggest adding the
grazing_allotmentstomap5for context
|
@priyankatuteja could you please resolve @jyaistMap's suggestions and do the following as well? I agree with all the points @jyaistMap makes, I came across them when I reviewed the article. suggested changes:
|
AtmaMani
left a comment
There was a problem hiding this comment.
@priyankatuteja please update the sample with the requested changes
This sample is based on a case study at http://desktop.arcgis.com/en/analytics/case-studies/which-watersheds-are-grazing-allotments-in.htm