using Pkg;
Pkg.add(url = "https://github.com/JuliaPlanet/NighttimeLights.jl")
Cloning git-repo `https://github.com/JuliaPlanet/NighttimeLights.jl`
Updating git-repo `https://github.com/JuliaPlanet/NighttimeLights.jl`
Updating registry at `~/.julia/registries/General`
Resolving package versions...
Installed MKL_jll ───────────────────── v2021.1.1+2
Installed FFTW_jll ──────────────────── v3.3.9+8
Installed ZygoteRules ───────────────── v0.2.2
Installed DiffRules ─────────────────── v1.5.0
Installed Crayons ───────────────────── v4.0.4
Installed InitialValues ─────────────── v0.3.0
Installed DBFTables ─────────────────── v1.0.0
Installed DensityRatioEstimation ────── v0.4.3
Installed GLM ───────────────────────── v1.4.2
Installed CompositionsBase ──────────── v0.1.1
Installed RecursiveArrayTools ───────── v2.11.4
Installed FiniteDiff ────────────────── v2.8.1
Installed libgeotiff_jll ────────────── v1.6.0+1
Installed JpegTurbo_jll ─────────────── v2.1.0+0
Installed BangBang ──────────────────── v0.3.33
Installed CommonSolve ───────────────── v0.2.0
Installed Baselet ───────────────────── v0.1.1
Installed LogExpFunctions ───────────── v0.3.0
Installed IteratorInterfaceExtensions ─ v1.0.0
Installed Transducers ───────────────── v0.4.68
Installed StatsModels ───────────────── v0.6.21
Installed HypothesisTests ───────────── v0.10.6
Installed CEnum ─────────────────────── v0.4.1
Installed ArgCheck ──────────────────── v2.1.0
Installed StatisticalTraits ─────────── v3.0.0
Installed PROJ_jll ──────────────────── v700.202.100+0
Installed GeoArrays ─────────────────── v0.6.0
Installed SQLite_jll ────────────────── v3.37.0+0
Installed Roots ─────────────────────── v1.3.13
Installed Indexing ──────────────────── v1.1.1
Installed SentinelArrays ────────────── v1.3.10
Installed StatsFuns ─────────────────── v0.9.9
Installed Tables ────────────────────── v1.6.1
Installed CircularArrays ────────────── v1.3.0
Installed ProgressMeter ─────────────── v1.7.1
Installed ArchGDAL ──────────────────── v0.7.4
Installed DataValueInterfaces ───────── v1.0.0
Installed CSV ───────────────────────── v0.8.5
Installed QuadGK ────────────────────── v2.4.2
Installed SplitApplyCombine ─────────── v1.2.0
Installed MicroCollections ──────────── v0.1.1
Installed Rmath ─────────────────────── v0.7.0
Installed PooledArrays ──────────────── v1.4.0
Installed AverageShiftedHistograms ──── v0.8.7
Installed SmoothingSplines ──────────── v0.3.1
Installed GeoStatsBase ──────────────── v0.21.8
Installed PositiveFactorizations ────── v0.2.4
Installed DefineSingletons ──────────── v0.1.1
Installed UnicodePlots ──────────────── v2.5.1
Installed LittleCMS_jll ─────────────── v2.12.0+0
Installed Distributions ─────────────── v0.24.18
Installed FillArrays ────────────────── v0.11.9
Installed CubicSplines ──────────────── v0.2.0
Installed TableTraits ───────────────── v1.0.1
Installed Rmath_jll ─────────────────── v0.3.0+0
Installed GDAL ──────────────────────── v1.2.6
Installed Dictionaries ──────────────── v0.3.16
Installed JLD ───────────────────────── v0.12.3
Installed TableOperations ───────────── v1.2.0
Installed GEOS_jll ──────────────────── v3.9.0+0
Installed ForwardDiff ───────────────── v0.10.24
Installed ScientificTypesBase ───────── v3.0.0
Installed Libtiff_jll ───────────────── v4.3.0+0
Installed SplittablesBase ───────────── v0.1.14
Installed GeoInterface ──────────────── v0.5.6
Installed ScientificTypes ───────────── v1.1.2
Installed ReferenceFrameRotations ───── v1.0.1
Installed LearnBase ─────────────────── v0.4.1
Installed IrrationalConstants ───────── v0.1.1
Installed DataFrames ────────────────── v1.1.1
Installed PDMats ────────────────────── v0.11.5
Installed RecipesBase ───────────────── v1.2.1
Installed ConstructionBase ──────────── v1.3.0
Installed WeakRefStrings ────────────── v1.1.0
Installed Expat_jll ─────────────────── v2.2.10+0
Installed NLSolversBase ─────────────── v7.8.2
Installed NearestNeighbors ──────────── v0.4.9
Installed Optim ─────────────────────── v1.6.0
Installed Combinatorics ─────────────── v1.0.2
Installed CategoricalArrays ─────────── v0.10.2
Installed Meshes ────────────────────── v0.16.13
Installed ShiftedArrays ─────────────── v1.0.0
Installed Formatting ────────────────── v0.4.2
Installed InvertedIndices ───────────── v1.1.0
Installed GDAL_jll ──────────────────── v300.202.100+0
Installed Preferences ───────────────── v1.2.3
Installed LineSearches ──────────────── v7.1.1
Installed TypedTables ───────────────── v1.4.0
Installed CommonSubexpressions ──────── v0.3.0
Installed GeoFormatTypes ────────────── v0.3.0
Installed DiffResults ───────────────── v1.0.3
Installed MLJModelInterface ─────────── v1.3.4
Installed LossFunctions ─────────────── v0.7.2
Installed DiskArrays ────────────────── v0.2.13
Installed OpenJpeg_jll ──────────────── v2.4.0+0
Installed Shapefile ─────────────────── v0.7.3
Installed Setfield ──────────────────── v0.8.1
Installed DocStringExtensions ───────── v0.8.6
Installed libpng_jll ────────────────── v1.6.38+0
Installed PrettyTables ──────────────── v1.3.1
Updating `~/.julia/environments/v1.6/Project.toml`
[4d912a30] + NighttimeLights v0.3.1 `https://github.com/JuliaPlanet/NighttimeLights.jl#main`
Updating `~/.julia/environments/v1.6/Manifest.toml`
[c9ce4bd3] + ArchGDAL v0.7.4
[dce04be8] + ArgCheck v2.1.0
[77b51b56] + AverageShiftedHistograms v0.8.7
[198e06fe] + BangBang v0.3.33
[9718e550] + Baselet v0.1.1
[fa961155] + CEnum v0.4.1
[336ed68f] + CSV v0.8.5
[324d7699] + CategoricalArrays v0.10.2
[7a955b69] + CircularArrays v1.3.0
[861a8166] + Combinatorics v1.0.2
[38540f10] + CommonSolve v0.2.0
[bbf7d656] + CommonSubexpressions v0.3.0
[a33af91c] + CompositionsBase v0.1.1
[187b0558] + ConstructionBase v1.3.0
[a8cc5b0e] + Crayons v4.0.4
[9c784101] + CubicSplines v0.2.0
[75c7ada1] + DBFTables v1.0.0
[a93c6f00] + DataFrames v1.1.1
[e2d170a0] + DataValueInterfaces v1.0.0
[244e2a9f] + DefineSingletons v0.1.1
[ab46fb84] + DensityRatioEstimation v0.4.3
[85a47980] + Dictionaries v0.3.16
[163ba53b] + DiffResults v1.0.3
[b552c78f] + DiffRules v1.5.0
[3c3547ce] + DiskArrays v0.2.13
[31c24e10] + Distributions v0.24.18
[ffbed154] + DocStringExtensions v0.8.6
[1a297f60] + FillArrays v0.11.9
[6a86dc24] + FiniteDiff v2.8.1
[59287772] + Formatting v0.4.2
[f6369f11] + ForwardDiff v0.10.24
[add2ef01] + GDAL v1.2.6
[38e38edf] + GLM v1.4.2
[2fb1d81b] + GeoArrays v0.6.0
[68eda718] + GeoFormatTypes v0.3.0
[cf35fbd7] + GeoInterface v0.5.6
[323cb8eb] + GeoStatsBase v0.21.8
[09f84164] + HypothesisTests v0.10.6
[313cdc1a] + Indexing v1.1.1
[22cec73e] + InitialValues v0.3.0
[41ab1584] + InvertedIndices v1.1.0
[92d709cd] + IrrationalConstants v0.1.1
[82899510] + IteratorInterfaceExtensions v1.0.0
[4138dd39] + JLD v0.12.3
[7f8f8fb0] + LearnBase v0.4.1
[d3d80556] + LineSearches v7.1.1
[2ab3a3ac] + LogExpFunctions v0.3.0
[30fc2ffe] + LossFunctions v0.7.2
[e80e1ace] + MLJModelInterface v1.3.4
[eacbb407] + Meshes v0.16.13
[128add7d] + MicroCollections v0.1.1
[d41bc354] + NLSolversBase v7.8.2
[b8a86587] + NearestNeighbors v0.4.9
[4d912a30] + NighttimeLights v0.3.1 `https://github.com/JuliaPlanet/NighttimeLights.jl#main`
[429524aa] + Optim v1.6.0
[90014a1f] + PDMats v0.11.5
[2dfb63ee] + PooledArrays v1.4.0
[85a6dd25] + PositiveFactorizations v0.2.4
[21216c6a] + Preferences v1.2.3
[08abe8d2] + PrettyTables v1.3.1
[92933f4c] + ProgressMeter v1.7.1
[1fd47b50] + QuadGK v2.4.2
[3cdcf5f2] + RecipesBase v1.2.1
[731186ca] + RecursiveArrayTools v2.11.4
[74f56ac7] + ReferenceFrameRotations v1.0.1
[79098fc4] + Rmath v0.7.0
[f2b01f46] + Roots v1.3.13
[321657f4] + ScientificTypes v1.1.2
[30f210dd] + ScientificTypesBase v3.0.0
[91c51154] + SentinelArrays v1.3.10
[efcf1570] + Setfield v0.8.1
[8e980c4a] + Shapefile v0.7.3
[1277b4bf] + ShiftedArrays v1.0.0
[102930c3] + SmoothingSplines v0.3.1
[03a91e81] + SplitApplyCombine v1.2.0
[171d559e] + SplittablesBase v0.1.14
[64bff920] + StatisticalTraits v3.0.0
[4c63d2b9] + StatsFuns v0.9.9
[3eaba693] + StatsModels v0.6.21
[ab02a1b2] + TableOperations v1.2.0
[3783bdb8] + TableTraits v1.0.1
[bd369af6] + Tables v1.6.1
[28d57a85] + Transducers v0.4.68
[9d95f2ec] + TypedTables v1.4.0
[b8865327] + UnicodePlots v2.5.1
[ea10d353] + WeakRefStrings v1.1.0
[700de1a5] + ZygoteRules v0.2.2
[2e619515] + Expat_jll v2.2.10+0
[f5851436] ↑ FFTW_jll v3.3.9+7 ⇒ v3.3.9+8
[a7073274] + GDAL_jll v300.202.100+0
[d604d12d] + GEOS_jll v3.9.0+0
[aacddb02] + JpegTurbo_jll v2.1.0+0
[89763e89] + Libtiff_jll v4.3.0+0
[d3a379c0] + LittleCMS_jll v2.12.0+0
[856f044c] ↑ MKL_jll v2021.1.1+1 ⇒ v2021.1.1+2
[643b3616] + OpenJpeg_jll v2.4.0+0
[58948b4f] + PROJ_jll v700.202.100+0
[f50d1b31] + Rmath_jll v0.3.0+0
[76ed43ae] + SQLite_jll v3.37.0+0
[06c338fa] + libgeotiff_jll v1.6.0+1
[b53b4c65] + libpng_jll v1.6.38+0
[9fa8497b] + Future
[4607b0f0] + SuiteSparse
Precompiling project...
✓ PositiveFactorizations
✓ ArgCheck
✓ CubicSplines
✓ IteratorInterfaceExtensions
✓ InvertedIndices
✓ IrrationalConstants
✓ CompositionsBase
✓ ScientificTypesBase
✓ FillArrays
✓ Preferences
✓ InitialValues
✓ CommonSubexpressions
✓ LearnBase
✓ GeoFormatTypes
✓ Baselet
✓ ShiftedArrays
✓ ProgressMeter
✓ CommonSolve
✓ DocStringExtensions
✓ Crayons
✓ Rmath_jll
✓ PooledArrays
✓ DiskArrays
✓ DataValueInterfaces
✓ Combinatorics
✓ ConstructionBase
✓ Formatting
✓ Indexing
✓ CEnum
✓ SQLite_jll
✓ SentinelArrays
✓ DefineSingletons
✓ ZygoteRules
✓ ScientificTypes
✓ Expat_jll
✓ FFTW_jll
✓ PDMats
✓ JpegTurbo_jll
✓ RecipesBase
✓ DiffResults
✓ CategoricalArrays
✓ GEOS_jll
✓ libpng_jll
✓ CircularArrays
✓ MKL_jll
✓ WeakRefStrings
✓ SmoothingSplines
✓ QuadGK
✓ NearestNeighbors
✓ TableTraits
✓ FiniteDiff
✓ StatisticalTraits
✓ LogExpFunctions
✓ DensityRatioEstimation
✓ Rmath
✓ JLD
✓ ReferenceFrameRotations
✓ Setfield
✓ UnicodePlots
✓ Dictionaries
✓ GeoInterface
✓ Libtiff_jll
✓ MLJModelInterface
✓ LossFunctions
✓ Tables
✓ DiffRules
✓ StatsFuns
✓ SplittablesBase
✓ AverageShiftedHistograms
✓ SplitApplyCombine
✓ RecursiveArrayTools
✓ Roots
✓ PROJ_jll
✓ LittleCMS_jll
✓ TableOperations
✓ DBFTables
✓ BangBang
✓ FFTW
✓ Meshes
✓ PrettyTables
✓ CSV
✓ TypedTables
✓ StatsModels
✓ libgeotiff_jll
✓ ForwardDiff
✓ OpenJpeg_jll
✓ FFTViews
✓ MicroCollections
✓ Distributions
✓ Shapefile
✓ GDAL_jll
✓ NLSolversBase
✓ Transducers
✓ HypothesisTests
✓ GLM
✓ GDAL
✓ LineSearches
✓ Optim
✓ ArchGDAL
✓ ImageFiltering
✓ GeoStatsBase
✓ ImageQualityIndexes
✓ GeoArrays
✓ Images
✓ DataFrames
✓ NighttimeLights
106 dependencies successfully precompiled in 288 seconds (86 already precompiled)
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)
Progress: 100%|█████████████████████████████████████████| Time: 0:00:11
Progress: 100%|█████████████████████████████████████████| Time: 0:00:02
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()
Loading sample data
Follow the tutorial on:
https://juliaplanet.github.io/NighttimeLights.jl/tutorial.html
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")