Filtering Sentinel 1 Image Collection to my area of interest produced no feature (or image) in google-earth-engine - filtering

My objective it to load and filter 2015 to 2016 sentinel images for my project area (AOI); The code produced image collection without image. Can you help me
The following is the code originally from https://krstn.eu/analyze-Sentinel-1-time-series-in-Google-Earth-Engine it does not work for my project area. It results in o elements in the image collection
Load the Sentinel-1 ImageCollection.
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD');
Filter VH, IW
var vh = sentinel1
// Filter to get images with VV and VH dual polarization.
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
// Filter to get images collected in interferometric wide swath mode.
.filter(ee.Filter.eq('instrumentMode', 'IW'))
// reduce to VH polarization
.select('VH')
// filter 10m resolution
.filter(ee.Filter.eq('resolution_meters', 10));
// Filter to orbitdirection Descending
var vhDescending = vh.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING'));
// Filter time 2015
var vhDesc2015 = vhDescending.filterDate(ee.Date('2015-01-01'), ee.Date('2015-12-31'));
Filter to MKD AOI
var AOI = ee.Geometry.Polygon(
[[[40.5548410121811,6.969011579129182],
[39.0332345668686,7.241560288027144],
[37.5226144496811,7.050793118016936],
[37.9675607387436,6.521691240305265],
[39.6539621059311,6.390691419627786],
[40.5548410121811,6.969011579129182]]]);
var s1_mkd = vhDesc2015.filterBounds(AOI);
print(s1_mkd,'s1_mkd');
The following is the output of the print
ImageCollection COPERNICUS/S1_GRD (0 elements)
type: ImageCollection
id: COPERNICUS/S1_GRD
version: 1533921047325895
bands: []
features: []
properties: Object (15 properties)

There are simply no images matching your criteria. For some parts of the world, Sentinel-1 imagery weren't acquired at full operational capacity until mid-late 2016. Change your date range in filterDate() to include more recent imagery (e.g., all of 2017 or 2018) and you will start seeing something closer to the Sentinel-1 12-day revisit.

Related

how to download precipitation data for latitude-longitude coordinates from NOAA in R

I'm trying to download precipitation data for a list of latitude-longitude coordinates in R. I've came across this question which gets me most of the way there, but over half of the weather stations don't have precipitation data. I've pasted code below up to this point.
I'm now trying to figure out how to only get data from the closest station with precipitation data, or run a second function on the sites with missing data to get data from the second closest station. However, I haven't been able to figure out how to do this. Any suggestions or resources that might help?
`
library(rnoaa)
# load station data - takes some minutes
station_data <- ghcnd_stations() %>% filter(element == "PRCP")
# add id column for each location (necessary for next function)
sites_df$id <- 1:nrow(sites_df)
# retrieve all stations in radius (e.g. 20km) using lapply
stations <- lapply(1:nrow(sites_df),
function(i) meteo_nearby_stations(sites_df[i,],lat_colname = 'Lattitude',lon_colname = 'Longitude',radius = 20,station_data = station_data)[[1]])
# pull data for nearest stations - x$id[1] selects ID of closest station
stations_data <- lapply(stations,function(x) meteo_pull_monitors(x$id[1], date_min = "2022-05-01", date_max = "2022-05-31", var = c("prcp")))
stations_data`
# poor attempt its making me include- trying to rerun subset for second closest station. I know this isn't working but don't know how to get lapply to run for a subset of a list, or understand exactly how the function is running to code it another way
for (i in c(1,2,3,7,9,10,11,14,16,17,19,20)){
stations_data[[i]] <- lapply(stations,function(x) meteo_pull_monitors(x$id[2], date_min = "2022-05-01", date_max = "2022-05-31", var = c("prcp")))
}

How can I merge two Mbtiles?

I have created 2 Mbtiles via QGIS: 1) one Mbtile is from zoom 0 until 10 & is a map of the whole world, 2) and another one from zoom 0 until 17 & is a detailed map of one country.
I would like to merge the two Mbtiles, and have the Mbtile of the detailed country overlapping the Mbtile of whole world. Also the merged result to be from zoom 0 til 17 (the whole world would disappear at zoom 10, but the country will remain until zoom 17).
What program/method should I use? Is it possible to merge them via QGIS?
I use Python to merge MBTiles files. Be sure to update the matadata table noting the min max zoom. They are just sqlite databases with a unique extension.
This example does not include data validation. I did not test this example -- as it is stripped down from where I batch process output from QGIS.
It is less problematic to use an IDE other than QGIS's python interface. Does not require anything specific to QGIS or PyQGIS.
import sqlite3 as sqlite
def processOneSource(srcDB, dstDB):
# create_index_sql = "CREATE UNIQUE INDEX tile_index on tiles (zoom_level, tile_column, tile_row);"
# dstDB.connection.execute(create_index_sql)
# the index forces an error if there is already a tile for the same zxy
sqlite_insert_blob_query = """ INSERT INTO tiles (zoom_level, tile_column, tile_row, tile_data) VALUES (?, ?, ?, ?)"""
tiles = srcDB.connection.execute('select zoom_level, tile_column, tile_row, tile_data from tiles;')
for t in tiles:
z = t[0]
x = t[1]
y = t[2]
data = t[3]
# example of how you might include exclude tiles
if not (z == 12 or z == 13 or z == 14 or z == 15 or z == 16):
continue
print(str((t[0], t[1], t[2])))
data_tuple = (t[0], t[1], t[2], t[3])
try:
dstDB.connection.execute(sqlite_insert_blob_query, data_tuple)
except Exception as e:
print(e)
dstDB.commit()
if __name__ == '__main__':
srcDB = sqlite.connect("path_to_yourfilename")
dstDB = sqlite.connect("path_to_yourfilename")
processOneSource(srcDB, dstDB)
You can use tile-join, it has a bunch of flags so you can customize the output.

Counting cloudless days using Google Earth Enigne - Sentinel-5p

I perform some analysis on Sentinel-5P data using Google Earth Engine. I would like to know how many cludless days are during month for each pixel. I am using the code below and it works. The problem is that Sentinel-5P images are captured several times a day so my result is number of cloudless images instead of cloudless days.
//Poland's border
var polska = ee.FeatureCollection('users/patrykgrzybowski1991/POL_adm1');
//upload collection
var collection_january_19 = ee.ImageCollection('COPERNICUS/S5P/NRTI/L3_NO2')//('COPERNICUS/S5P/NRTI/L3_NO2')
//filters
.filterBounds(ee.FeatureCollection('users/patrykgrzybowski1991/POL_adm0'))
.filterDate('2019-01-01', '2019-02-01')
.map(function(img){return ee.Image(img.select('tropospheric_NO2_column_number_density')).updateMask(img.select('cloud_fraction').lt(0.4))})
//cludless images - count
var count_january_19 = collection_january_19.count();
Number of cloudless days is slightly ill-defined when there are multiple images, but if you mean "none of the images on a day had clouds in them", then you probably need to composite the images by day before counting:
var start = ee.Date('2019-01-01')
var daysAsList = ee.List.sequence(0, 31).map(function(n) {
n = ee.Number(n)
var begin = start.advance(n, 'day')
var end = begin.advance(1, 'day')
return collection_january_19.filterDate(begin, end).mosaic()
})
var days = ee.ImageCollection.fromImages(daysAsList).count()

Customized Android GraphView x-axis date labels not displaying as per setNumHorizontalValues()

I attempt to show a tersely formatted date/time on the x-axis in a graphview chart. As per the API Code examples, I set HumanRounding to false when using using a date formatter on that axis. I'm also setting the NumHorizontalLabels to 3 in order to display reasonably OK in both orientations.
This results in e.g. the following, where the date labels show as a black shape, and the LineChart background is different. I'm speculating that the black shape is the result of all my date data points overwriting each other:
With HumanRounding set to true (commented out), I get labels showing, but instead of the expected 3 evenly distributed labels, they are unpredictably spread out and/or not equal to 3, sometimes the labels over-write each other, sometimes they are bunched on the left...
The number of date data-points on the x-axis can vary depending on how much history the user has selected. Note that this can vary from 60 to thousands of minutes.
Here's the code that receives data and charts it. Note that the unixdate retrieved from wxList elements has already been converted to a Java date (by multiplying by 1000) by the time they get used here (the time portion of the x-axis are in fact correct when they do show up in a reasonably distributed manner):
protected void onPostExecute(List<WxData> wxList) {
// We will display MM/dd HH:mm on the x-axes on all graphs...
SimpleDateFormat shortDateTime = new SimpleDateFormat("MM/dd HH:mm");
shortDateTime.setTimeZone(TimeZone.getTimeZone("America/Toronto"));
DateAsXAxisLabelFormatter xAxisFormat = new DateAsXAxisLabelFormatter(parentContext, shortDateTime);
if (wxList == null || wxList.isEmpty()) {
makeText(parentContext,
"Could not retrieve data from server",
Toast.LENGTH_LONG).show();
} else {
// Temperature Celcius
GraphView tempGraph = findViewById(R.id.temp_graph);
tempGraph.removeAllSeries();
tempGraph.setTitle(parentContext.getString(R.string.temp_graph_label));
DataPoint[] tempCArray = new DataPoint[wxList.size()];
for (int i = 0; i < wxList.size(); i++) {
tempCArray[i] = new DataPoint(wxList.get(i).getUnixtime(), wxList.get(i).getTempC().doubleValue());
}
LineGraphSeries<DataPoint> tempCSeries = new LineGraphSeries<>(tempCArray);
tempGraph.addSeries(tempCSeries);
tempGraph.getGridLabelRenderer().invalidate(false, false);
tempGraph.getGridLabelRenderer().setLabelFormatter(xAxisFormat);
tempGraph.getGridLabelRenderer().setNumHorizontalLabels(3);
tempGraph.getViewport().setMinX(wxList.get(0).getUnixtime());
tempGraph.getViewport().setMaxX(wxList.get(wxList.size() - 1).getUnixtime());
tempGraph.getViewport().setXAxisBoundsManual(true);
// Code below seems buggy - with humanRounding, X-axis turns black
// tempGraph.getGridLabelRenderer().setHumanRounding(false);
...
I have tried many variations,but I cannot get the graph to consistently display 3 datetimes evenly spread out, for both orientations, for varyings sample sizes. Any help is appreciated.

Select Night Lights in Google Earth Engine by year

I am able to select an image by year from the OLS dataset with the code examples from the web:
// Load a Japan boundary from a Fusion Table.
var japan = ee.FeatureCollection('ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw')
.filter(ee.Filter.eq('Country', 'Japan'));
// Load a 2012 nightlights image, clipped to the Japan border.
var nl2012 = ee.Image('NOAA/DMSP-OLS/NIGHTTIME_LIGHTS/F182009')
.select('stable_lights')
.clipToCollection(japan);
However, when I try to use the ImageCollection I am unable to select by date like with other datasets (such as Landsat):
var collection = ee.ImageCollection('LANDSAT/LE07/C01/T1')
.filterDate('2000-01-01', '2001-01-01');
I would like to be able to apply the same filters on the OLS dataset:
var ols = ee.ImageCollection("NOAA/DMSP-OLS/CALIBRATED_LIGHTS_V4")
.filterDate('2000-01-01', '2001-01-01')
.select('stable_lights')
.clipToCollection(japan);
You're just using the wrong ImageCollection ID.
If you use NOAA/DMSP-OLS/NIGHTTIME_LIGHTS, the filter work:
var ols = ee.ImageCollection("NOAA/DMSP-OLS/NIGHTTIME_LIGHTS")
.filterDate('2000-01-01', '2001-01-01')
.select('stable_lights')
print(ols)
// ImageCollection NOAA/DMSP-OLS/NIGHTTIME_LIGHTS (2 elements)
// type: ImageCollection
// id: NOAA/DMSP-OLS/NIGHTTIME_LIGHTS
// version: 1509484869949711
// bands: []
// features: List (2 elements)
// properties: Object (17 properties)