How to use the sentinelsat.sentinel.read_geojson function in sentinelsat

To help you get started, we’ve selected a few sentinelsat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github clcr / pyeo / pyeo / apps / sentinel_1 / sen1get.py View on Github external
geom = feat.GetGeometryRef()
print('Geometry of feature 1:', geom)

###############################################
# convert the shapefile to geojson
###############################################
gjfile = shapefile.split(".")[0]+".geojson"
com = "ogr2ogr -f GeoJSON -t_srs crs:84 " + gjfile + " " + shapefile
flag = os.system(com)
if flag == 0:
    print('Shapefile converted to Geojson format: ' + gjfile)
else:
    print('Error converting shaoefile to Geojson')

# convert the geojson to wkt for the API search
footprint = geojson_to_wkt(read_geojson(gjfile))

# old code to open a geojson file directly
# with open(geojsonfile) as f:
#     polydata = gj.load(f)

###############################################
# search the ESA Sentinel data hub
###############################################

# set query parameters
query_kwargs = {
        'area': footprint,
        'platformname': 'Sentinel-1',
        'producttype': 'GRD',
#        orbitdirection='ASCENDING'),
        'date': (datefrom, dateto),
github sentinelsat / sentinelsat / sentinelsat / scripts / cli.py View on Github external
search_kwargs["instrumentshortname"] = instrument

    if producttype:
        search_kwargs["producttype"] = producttype

    if cloud:
        if sentinel not in ["2", "3"]:
            logger.error("Cloud cover is only supported for Sentinel 2 and 3.")
            exit(1)
        search_kwargs["cloudcoverpercentage"] = (0, cloud)

    if query is not None:
        search_kwargs.update((x.split("=") for x in query))

    if geometry is not None:
        search_kwargs["area"] = geojson_to_wkt(read_geojson(geometry))

    if uuid is not None:
        uuid_list = [x.strip() for x in uuid]
        products = {}
        for productid in uuid_list:
            try:
                products[productid] = api.get_product_odata(productid)
            except SentinelAPIError as e:
                if "Invalid key" in e.msg:
                    logger.error("No product with ID '%s' exists on server", productid)
                    exit(1)
                else:
                    raise
    elif name is not None:
        search_kwargs["identifier"] = name[0] if len(name) == 1 else "(" + " OR ".join(name) + ")"
        products = api.query(order_by=order_by, limit=limit, **search_kwargs)
github clcr / pyeo / pyeo / sen2get.py View on Github external
geom = feat.GetGeometryRef()
print('Geometry of feature 1:', geom)

###############################################
# convert the shapefile to geojson
###############################################
gjfile = shapefile.split(".")[0]+".geojson"
com = "ogr2ogr -f GeoJSON -t_srs crs:84 " + gjfile + " " + shapefile
flag = os.system(com)
if flag == 0:
    print('Shapefile converted to Geojson format: ' + gjfile)
else:
    print('Error converting shaoefile to Geojson')

# convert the geojson to wkt for the API search
footprint = geojson_to_wkt(read_geojson(gjfile))

# old code to open a geojson file directly
# with open(geojsonfile) as f:
#     polydata = gj.load(f)

###############################################
# search the ESA Sentinel data hub
###############################################

# set query parameters
query_kwargs = {
        'area': footprint,
        'platformname': 'Sentinel-2',
        'producttype': 'S2MSI1C',
#        orbitdirection='ASCENDING'),
        'date': (datefrom, dateto),
github geosolutions-it / evo-odas / airflow / plugins / dhus_plugin.py View on Github external
log.info('Start Date: %s', self.startdate)
        log.info('End Date: %s', self.enddate)
        log.info('Filter Max: %s', self.filter_max)
        log.info('Order By: %s', self.order_by)        
        log.info('GeoJSON: %s', self.geojson_bbox)
        log.info('Keywords: %s', self.keywords)

        log.info('Now is: {}'.format( datetime.now() ))
        log.info('6 hours ago was: {}'.format( datetime.now() - timedelta(hours=6)) )

        print("Execute DHUS Search.. ")

        # search products 
        api = SentinelAPI(self.dhus_user, self.dhus_pass, self.dhus_url)
        try:
            footprint = geojson_to_wkt(read_geojson(self.geojson_bbox))
        except:
            log.error('Cannot open GeoJSON file: {}'.format(self.geojson_bbox))
            return False

        products = api.query(
            area=footprint,
            date=(self.startdate, self.enddate),
            order_by=self.order_by,
            limit=self.filter_max,
            **self.keywords
        )

        log.info("Retrieving {} products:".format(len(products)))
        products_summary="\n"
        for key, product in products.items():
            products_summary+='ID: {}, {}\n'.format(key,product['summary'])
github clcr / pyeo / pyeo / Sen2Search.py View on Github external
Parameters
    ----------
    geojson_path
    cloud
    start_date
    end_date
    conf

    Returns
    -------
    A dicitonary of products

    """
    api = SentinelAPI(conf["sen2"]["user"], conf["sen2"]["pass"], 'https://scihub.copernicus.eu/dhus')
    footprint = geojson_to_wkt(read_geojson(geojson_path))
    products = api.query(footprint,
                        platformname = 'Sentinel-2',
                        cloudcoverpercentage = (0, cloud),
                        date = (start_date, end_date))
    return products