using Pkg;
Pkg.add(url = "https://github.com/JuliaPlanet/NighttimeLights.jl")
using NighttimeLights
load_img("/work/mumbai_ntl/img/april2012.tif")
load_datacube("/work/mumbai_ntl/datacube/mumbai_radiance.jld")
#make_datacube("/work/mumbai_ntl/datacube/")
top_left = Coordinate(37.5, 67.91666)
bottom_right = Coordinate(4.166, 97.5)
height = 8000
width = 7100
my_coordinate_system = CoordinateSystem(top_left, bottom_right, height, width)
# If latitude = 19.6, what row is it?
lat_to_row(my_coordinate_system, 19.6)
# If longitude = 73.33, what column is it?
long_to_column(my_coordinate_system, 73.33)
# From (lat,long) to (row,col)
coordinate_to_image(my_coordinate_system, Coordinate(19.6, 73.33))
# If row = 100, what latitude is it?
row_to_lat(my_coordinate_system, 100)
# If column = 100, what longitude is it?
column_to_long(my_coordinate_system, 100)
# From (row,col) to (lat,long)
image_to_coordinate(my_coordinate_system, [100, 100])
image = rand(0:10.0, 10, 10)
threshold = 0.3
noise_threshold = function(x, threshold)
if x < threshold
return 0
else
return 1
end
end
mask_mask = noise_threshold.(image, threshold)
sum(mask_mask)
mask = rand(0:1,8000,7100)
mask_area(my_coordinate_system, mask)
rand_image = rand(10, 10)
rand_mask = rand(0:1, 10, 10)
aggregate(rand_image, rand_mask)
sum(rand_image .* rand_mask)
rand_datacube = rand(10, 10, 10)
rand_mask = rand(0:1, 10, 10)
aggregate_timeseries(rand_datacube, rand_mask)
mumbai_districts = load_shapefile("/work/mumbai_map/mumbai_districts.shp")
district1 = mumbai_districts[1,:] # Select the first district
district1_mask = polygon_mask(my_coordinate_system, district1)
radiance = rand(1:10.0, 10, 10)
cloud = rand(0:5, 10, 10)
mark_nan(radiance, cloud)
radiance = rand(1:10.0, 10, 10, 10)
cloud = rand(0:5, 10, 10, 10)
mark_nan(radiance, cloud)
x = rand(1:10.0, 10)
x[5] = NaN
x
linear_interpolation(x)
radiance_datacube = rand(1:1000.0, 10, 10, 15)
clouds_datacube = rand(1:1000, 10, 10, 15)
PatnaikSTT2021(radiance_datacube, clouds_datacube)
NighttimeLights.load_example
cleaned_datacube = conventional_cleaning(radiance_datacube, clouds_datacube)
cleaned_datacube = PatnaikSTT2021(radiance_datacube, clouds_datacube)
#MUMBAI_COORDINATE_SYSTEM = CoordinateSystem(Coordinate(19.49907,72.721252), Coordinate(18.849475, 73.074187), 156, 85)
load_example()
NighttimeLights.radiance_datacube
radiance_datacube
mumbai_map = load_shapefile("/work/mumbai_map/mumbai_districts.shp")
mumbai_district_ntl = aggregate_dataframe(MUMBAI_COORDINATE_SYSTEM, NighttimeLights.radiance_datacube, mumbai_map, "DISTRICT")
mumbai_district_ntl_per_area = aggregate_per_area_dataframe(MUMBAI_COORDINATE_SYSTEM, NighttimeLights.radiance_datacube, mumbai_map, "DISTRICT")