Skip to content

Add finding_grazing_allotment notebook#428

Closed
priyankatuteja wants to merge 0 commit into
Esri:masterfrom
priyankatuteja:master
Closed

Add finding_grazing_allotment notebook#428
priyankatuteja wants to merge 0 commit into
Esri:masterfrom
priyankatuteja:master

Conversation

@priyankatuteja
Copy link
Copy Markdown
Collaborator

@AtmaMani AtmaMani requested a review from jyaistMap May 31, 2019 05:16
@AtmaMani
Copy link
Copy Markdown
Contributor

@jyaistMap could you do the first round of reviews for this notebook?

@AtmaMani AtmaMani self-requested a review May 31, 2019 05:17
Copy link
Copy Markdown
Collaborator

@jyaistMap jyaistMap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 datetime to import datetime as dt and change the cells that call datetime accordingly: The datetime module and the datetime class behave strangely. When I import the datetime class and try str(datetime.now().microsecond), I receive:
---------------------------------------------------------------------------
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 = True parameter 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_widgets to see the initial hydro_units, grazing_allotments, and streams layers before the overlay analysis
    • Add a map widget that zooms in on grazing_allotments and hydro_units before 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]
  • In Mapping and exploring basin overlay results

    • Labeling the basin_overlay_df.groupby('BASIN_NAME').size() as the variable df is confusing because the function returns a Series object
    • 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() uses allot_name for the col parameter. I think it should be BASIN_NAME
    • The overlay_layers output is a hosted feature layer that carries over numerous original geometry values from the analysis layer: Shape__Area, Shape__Length, Shape_Leng, and corresponding ..._1 and a PERIMETER attribute 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)
  • 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_units to 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_NAME column 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))
  • In Mapping and exploring stream overlay results

    • Unless the attributes from the grazing_allotments overlay layer are needed in the output stream_overlay item, I suggest removing them after creating stream_overlay_df. I think the FID_GRAZING_ALLOTMETS_GRAZING_A, FID_GRAZING_ALLOTMETS_STREAMS, OBJECTID, Shape__Area, Shape_Length, Shape__Length_1, objectid_1, and shape_Leng fields are unnecessary to subsequent analyses, cause confusion when looking at the dataframe and generally interfere with following the flow of the analysis
    • st_df is technically a Series object, assigning it a variable name with df in the name is confusing
    • Change neighboring to contiguous in 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 map4 would make more sense to say Map of streams overlaid by grazing allotments. I'd also add the grazing_allotments layer to the map for context.
  • 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_layer for a specific stream: to stay consistent with the language of the tool
    • I suggest adding the grazing_allotments to map5 for context

@AtmaMani
Copy link
Copy Markdown
Contributor

@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:

  • Change title to "Monitoring hydrologic water quality in pasturelands through spatial overlay analysis"
  • The bottom two images in the "workflow" diagram need to be swapped. Right now, it shows when you overlay hydro units with grazing allotments you get streams, which is misleading.
  • In "Mapping and exploring" - - I like the df.nlarges() method. It is a useful example. But you need to explain what it does before or after using it. As @jyaistMap points out, calling size() on the basin overlay DF is misleading, as you are counting the number of fragments, not the aerial size of the basins.
  • Similar issue when overlaying streams in - stream_overlay_df.groupby('allot_name').size().nlargest(10)
  • The sentence "The map shows in which allotment each stream segment falls." (right before conclusion ) is misleading as you are plotting just 1 stream and needs to be rewritten
  • Conclusion: Change "Biologists can now identify several hydrologic basins that seem to have chronic..." to "Biologists can now identify which hydrologic basin and stream(s) intersect with which grazing allotments in an effort to identify sources of chronic water quality issues...."

Copy link
Copy Markdown
Contributor

@AtmaMani AtmaMani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@priyankatuteja please update the sample with the requested changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants