NighttimeLights.load_shapefileMethod

Polygon boundaries are usually stored in a format called shapefile. For example, the shapefile of the world will consist of country names and each country will have coordinates of the boundaries.

load_shapefile("assets/mumbai_map/mumbai_districts.shp")
source
|   |       geometry      |     DISTRICT    |    ST_NM    | ST_CEN_CD | DT_CEN_CD | censuscode |
|:-:|:-------------------:|:---------------:|:-----------:|:---------:|:---------:|:----------:|
| 1 | Polygon(78 Points)  | Mumbai          | Maharashtra | 27        | 23        | 519        |
| 2 | Polygon(139 Points) | Mumbai Suburban | Maharashtra | 27        | 22        | 518        |

Each row of a shapefile dataframe contains a polygon and other information about it.

NighttimeLights.polygon_maskMethod

The polygon of a shapefile row can be make into a mask. This means all the points inside the polygon will be marked as 1, while the points outside will be marked as 0.

mumbai_districts = load_shapefile("assets/mumbai_map/mumbai_districts.shp")
district1 = mumbai_dists[1,:] # Select the first district
district1_mask = polygon_mask(my_coordinate_system, district1)
source

Once a mask is obtained from a polygon, the mask can be used as just as any other mask.