Giter Club home page Giter Club logo

Comments (4)

dbuscombe-usgs avatar dbuscombe-usgs commented on June 3, 2024 1

the above suggestion would be the following straightforward mod to check_images_available_selected_ROI

def check_images_available_selected_ROI(selected_ROI:dict)->list:
    list_of_inputs=[]; 
    if selected_ROI["features"] != []:
        for counter, ROI in enumerate(selected_ROI["features"]):
            coastSatBBOX=ROI["geometry"]["coordinates"]
            polygon=coastSatBBOX
            # it's recommended to convert the polygon to the smallest rectangle (sides parallel to coordinate axes)       
            polygon = SDS_tools.smallest_rectangle(polygon)
            # date range
            dates = ['2018-12-01', '2019-01-01']
            # satellite missions
            sat_list = ['S2','L7','L8']
            # name of the site
            sitename = 'ID'+str(counter)
            # directory where the data will be stored
            filepath = os.path.join(os.getcwd(), 'data')
            # put all the inputs into a dictionnary
            inputs = {'polygon': polygon, 'dates': dates, 'sat_list': sat_list, 'sitename': sitename, 'filepath':filepath}
            # before downloading the images, check how many images are available for your inputs
            SDS_download.check_images_available(inputs)
            list_of_inputs.append(inputs)
    return list_of_inputs

Images are downloaded into folders named ID0, ID1, etc. Good enough, I think

from coastseg.

dbuscombe-usgs avatar dbuscombe-usgs commented on June 3, 2024 1

This is good, but might I suggest the same datestring for all IDs in the same session? That may be easier to deal with for the end user. i.e.

def check_images_available_selected_ROI(selected_ROI:dict)->list:
    list_of_inputs=[]; 
    if selected_ROI["features"] != []:
        date_str=generate_datestring()
        for counter, ROI in enumerate(selected_ROI["features"]):
            coastSatBBOX=ROI["geometry"]["coordinates"]
            polygon=coastSatBBOX
            # it's recommended to convert the polygon to the smallest rectangle (sides parallel to coordinate axes)       
            polygon = SDS_tools.smallest_rectangle(polygon)
            # date range
            dates = ['2018-12-01', '2019-01-01']
            # satellite missions
            sat_list = ['S2','L7','L8']
            # name of the site
            sitename = 'ID'+str(counter)+date_str
            # directory where the data will be stored
            filepath = os.path.join(os.getcwd(), 'data')
            # put all the inputs into a dictionnary
            inputs = {'polygon': polygon, 'dates': dates, 'sat_list': sat_list, 'sitename': sitename, 'filepath':filepath}
            # before downloading the images, check how many images are available for your inputs
            SDS_download.check_images_available(inputs)
            list_of_inputs.append(inputs)
    return list_of_inputs

from coastseg.

2320sharon avatar 2320sharon commented on June 3, 2024

However, I get a "denied request" error

I did a little digging the reason why you get this error is because we don't have a google maps API key. I don't think we need one for this project, so your second solution is definitely the way to go.

To make sure the data doesn't get overwritten when the user runs the program again I plan on adding a date time string to the sitename. This will also allow the user to check when they downloaded data last.

from coastseg.

2320sharon avatar 2320sharon commented on June 3, 2024

check_images_available_selected_ROI()

Here is the working code that creates a unique sitename for each ROI:

def check_images_available_selected_ROI(selected_ROI:dict)->list:
    list_of_inputs=[]; 
    if selected_ROI["features"] != []:
        for counter, ROI in enumerate(selected_ROI["features"]):
            coastSatBBOX=ROI["geometry"]["coordinates"]
            polygon=coastSatBBOX
            # it's recommended to convert the polygon to the smallest rectangle (sides parallel to coordinate axes)       
            polygon = SDS_tools.smallest_rectangle(polygon)
            # date range
            dates = ['2018-12-01', '2019-01-01']
            # satellite missions
            sat_list = ['S2','L7','L8']
            # name of the site
            date_str=generate_datestring()
            sitename = 'ID'+str(counter)+date_str
            # directory where the data will be stored
            filepath = os.path.join(os.getcwd(), 'data')
            # put all the inputs into a dictionnary
            inputs = {'polygon': polygon, 'dates': dates, 'sat_list': sat_list, 'sitename': sitename, 'filepath':filepath}
            # before downloading the images, check how many images are available for your inputs
            SDS_download.check_images_available(inputs)
            list_of_inputs.append(inputs)
    return list_of_inputs

generate_datestring()

-This function returns a string containing the current date, hour and minute (24 hr style)

from datetime import datetime
def generate_datestring():
    date=datetime.now()
    print(date)
    return date.strftime('%Y-%m-%d %H_hr_%M_min')

Resulting Folder Names

  1. ID02022-01-31 13_hr_19_min
  2. ID12022-01-31 13_hr_19_min

from coastseg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.