ankitkariryaa / An-unexpectedly-large-count-of-trees-in-the-western-Sahara-and-Sahel

This repository contains the code for the paper "An unexpectedly large count of trees in the western Sahara and Sahel".
MIT License
85 stars 32 forks source link

Install_Config_preprocessing_setup #27

Open nicholasmetherall opened 2 years ago

nicholasmetherall commented 2 years ago

Thanks for putting together this github repository.

I am following all of the steps but when I try to setup the config files I am having some issues.

I have tried to setup my config as follows but am having some issues with the path names.

  1. Should I use a semi colon to prevent the paths running into the next line?
Config1
  1. Do I need to do all the config pre processing before installing or after installing?
  2. When installing using the install / requirements docs, I tend to get the issue with the kernel needing to be restarted. Is there something I am missing in the installation of all the dependencies?
install1
AlanMorningLight commented 2 years ago

Can you share the corresponding paper? Thanks.

ndmetherall commented 1 year ago

Thank you @AlanMorningLight. The academic paper for the steps I am seeking to replicate is based on this one: https://www.nature.com/articles/s41586-020-2824-5

ndmetherall commented 1 year ago

Hello all. I have tried to rerun this code in pycharm using some advice from the authors. Thank you for all the support with this.

import os desktop = os.path.join(os.path.join(os.environ[r'USERPROFILE']), 'Desktop')

Configuration of the parameters for the 1-Preprocessing.ipynb notebook

class Configuration: ''' Configuration for the first notebook. Copy the configTemplate folder and define the paths to input and output data. Variables such as raw_ndvi_image_prefix may also need to be corrected if you are use a different source. ''' def init(self):

For reading the training areas and polygons

    self.training_base_dir = r'C:\Users\Nicholas Metherall\Desktop\ML_Brandt\Github\ankitkariryaa-An-unexpectedly-large-count-of-trees-in-the-western-Sahara-and-Sahel-eeeb76f\SampleAnnotations'
    self.training_area_fn = r'C:\Users\Nicholas Metherall\Desktop\ML_Brandt\Github\ankitkariryaa-An-unexpectedly-large-count-of-trees-in-the-western-Sahara-and-Sahel-eeeb76f\SampleAnnotations\training_areas_example.shp'
    self.training_polygon_fn = r'C:\Users\Nicholas Metherall\Desktop\ML_Brandt\Github\ankitkariryaa-An-unexpectedly-large-count-of-trees-in-the-western-Sahara-and-Sahel-eeeb76f\SampleAnnotations\training_polygons_example.shp'

    # For reading the VHR images
    self.bands = [0]
    self.raw_image_base_dir = r'C:\Users\Nicholas Metherall\Desktop\ML_Brandt\Github\ankitkariryaa-An-unexpectedly-large-count-of-trees-in-the-western-Sahara-and-Sahel-eeeb76f\SampleAnnotations\Satellite_image'
    self.raw_image_file_type = '.tif'
    self.raw_ndvi_image_prefix = 'ndvi'
    self.raw_pan_image_prefix = 'pan'

    # For writing the extracted images and their corresponding annotations and boundary file
    self.path_to_write = r'C:\Users\Nicholas Metherall\Desktop\ML_Brandt\Github\ankitkariryaa-An-unexpectedly-large-count-of-trees-in-the-western-Sahara-and-Sahel-eeeb76f\Output'
    self.show_boundaries_during_processing = False
    self.extracted_file_type = '.png'
    self.extracted_ndvi_filename = 'ndvi'
    self.extracted_pan_filename = 'pan'
    self.extracted_annotation_filename = 'annotation'
    self.extracted_boundary_filename = 'boundary'

    # Path to write should be a valid directory
    assert os.path.exists(self.path_to_write)

    if not len(os.listdir(self.path_to_write)) == 0:
        print('Warning: path_to_write is not empty! The old files in the directory may not be overwritten!!')

I have managed to stop getting any syntax errors but there is not yet any output in the output folder and I am not sure of how to check whether this first preprocessing step is complete and the next step to follow.