spaceie08 / GEE_Classification_Regression_Mini_Project_3

The repository contains the two notebooks for the mini project III for the course of Big Geo data processing.
0 stars 0 forks source link

Peer Review - Classification GEE #2

Open arthurwilly opened 1 day ago

arthurwilly commented 1 day ago
  1. I can't run the code from the section "Combining Separate Landcover Classes....." until the end of the notebook. So I could not review it until the end.
  2. I don't understand the code for computing the median. Why don't you use "image.median().clip(region)" to reduce the image number into median?
spaceie08 commented 23 hours ago

Thank you for pointing that out! Here’s my response:

  1. I understand that you couldn’t run the code from the "Combining Separate Landcover Classes…" section onward. This happened because I generated the samples using map.user_rois, which I noted in the notebook. For each class, I used the geemap Map feature to draw regions on the map and then exported them as a FeatureCollection using map.user_rois.

    For more details on this process, please refer to the cell titled "Combining Separate Landcover Classes into a Single Feature Collection." Additionally, I saved the sample collections to a GeoJSON file so that others can re-run the classification easily. Here’s the relevant code:

    import geopandas as gpd
    
    output_path = "landcover_data.geojson"
    landcover_gdf.to_file(output_path, driver="GeoJSON")
    print(f"GeoJSON file saved as {output_path}")
    
    # Optionally, load the GeoJSON file back into a GeoDataFrame for verification
    landcover_fc = gpd.read_file(output_path)
    
    # Display the first few rows to verify the data
    landcover_fc.head()

    I’ll also add this GeoJSON file to the repository, so the code should now be runnable from this section onward. Please let me know if you have any further questions or if there’s anything else I can clarify!

  2. Yes, I actually did compute the median in exactly that way. Here’s the code I used to reduce the image collection to its median and clip it to the region:

image = imageCollection.median()
image_roi = image.clip(boundingBox)

By using imageCollection.median(), I’m reducing the entire collection to a single median image, then clipping it to the specified region (boundingBox). Let me know if this clarifies things, or if you’d like any further details on this step!