This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gis = GIS() | |
# Landsat data - https://www.arcgis.com/home/item.html?id=d9b466d6a9e647ce8d1dd5fe12eb434b | |
landsat_data = gis.content.get("d9b466d6a9e647ce8d1dd5fe12eb434b") # id from the URL | |
landsat_data.layers # [<ImageryLayer url:"https://landsat2.arcgis.com/arcgis/rest/services/Landsat/MS/ImageServer">] | |
landsat_data.type # 'Image Service' | |
HTML(landsat_data.description) # prints the description of the landsat data | |
# printing all the properties available on the landsat imagery layer - a total of 55 properties will be printed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
llayer = landsat_data.layers[0] | |
for rasterFunction in llayer.properties['rasterFunctionInfos']: | |
print(f"{rasterFunction.get('name')}") | |
# Agriculture with DRA | |
# Bathymetric with DRA | |
# Color Infrared with DRA | |
# Natural Color with DRA | |
# Short-wave Infrared with DRA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
llayer_colorized = apply(llayer, "NDVI Colorized") # applying NDVI Colorized on the imagery | |
delhi_clipped = clip(llayer_colorized, delhi_geom) | |
map = gis.map() | |
map.add_layer(delhi_clipped) | |
map.export_to_html(f'xsd.html') | |
delhi_image = llayer.filter_by("OBJECTID=2752790") # 2017-10-15 - imagery of single day selected over delhi region | |
delhi_image_colorized = apply(delhi_image, "NDVI Colorized") | |
delhi_clipped = clip(delhi_image_colorized, delhi_geom) | |
map = gis.map() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gis = GIS("gis developer profile details") | |
boundaries = gis.content.get("3013e4533dc64a848159cafe7bc2de84") | |
state_boundaries = boundaries.layers[1] | |
state_boundaries.query().sdf # prints the dataframe | |
# OBJECTID ID NAME AREA TOTPOP_CY ISO_CODE ISO_SUB ISO2_CC ISO3_CC Shape__Area Shape__Length SHAPE | |
# 0 1 01 Jammu & Kashmir 106337.915332 14150564 INJK JK IN IND 10.355640 24.807143 {"rings": [[[76.553503226, 35.927019016], [76.... | |
# 1 2 02 Himachal Pradesh 55388.071495 7675650 INHP HP IN IND 5.282314 15.582886 {"rings": [[[76.8309960000001, 33.250837], [76... | |
# 2 3 03 Punjab 50563.578593 31014086 INPB PB IN IND 4.767880 16.249509 {"rings": [[[75.838508, 32.504755], [75.846393... | |
# 3 4 04 Chandigarh 114.429678 1182432 INCH CH IN IND 0.010776 0.583075 {"rings": [[[76.7713440000001, 30.795139000000... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
delhi_ndviraw = apply(delhi_image,"NDVI Raw") | |
delhi_clip = clip(delhi_ndviraw, delhi_geom) | |
# 0.4-0.5 is mapped to 1, and 0.5-1 is mapped to 2 | |
delhi_clip_remapped = remap(delhi_clip, | |
input_ranges=[0.4, 0.5, 0.5, 1], | |
output_values=[1, 2]) | |
# 1 is mapped to (124, 252, 0), and 2 is mapped to (0, 102, 0) | |
delhi_clip_colormapped = colormap(delhi_clip_remapped,colormap=[[1, 124, 252, 0], [2, 0, 102, 0]], astype='u8') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# apply(llayer, 'NDVI Raw') | |
apply(llayer, 'NDVI Colorized') | |
apply(llayer, 'Agriculture with DRA') | |
# apply(llayer, 'Color Infrared with DRA') | |
apply(llayer, 'Normalized Difference Moisture Index Colorized') | |
apply(llayer, 'Natural Color with DRA') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
selected = llayer.filter_by(where="(CloudCover <= 0.05)", | |
time=[datetime(2015, 1, 1),datetime(2017, 12, 31)], | |
geometry=arcgis.geometry.filters.intersects(area['extent'])) | |
df = selected.query(out_fields="AcquisitionDate, GroupName, CloudCover, DayOfYear", | |
order_by_fields="AcquisitionDate").sdf | |
df['AcquisitionDate'] = pd.to_datetime(df['AcquisitionDate'], unit='ms') | |
df | |
# prints a dataframe consisting of the fields selected, ordered by Acquisition Date | |
delhi_image = llayer.filter_by("OBJECTID=2752790") # Extracting the imagery on 2017-10-15 - a date randomly selected from above dataframe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import geojson | |
x = geojson.Polygon(coordinates=geometry[0]['coordinates']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final_products = self.api.query(footprint, | |
date=(products_df_sorted['beginposition'][0].date()-datetime.timedelta(days=4),products_df_sorted['beginposition'][0].date()+datetime.timedelta(days=5)), | |
area_relation='Intersects', | |
platformname='Sentinel-2') | |
final_products_ids_list = list(final_products) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sentinelsat.sentinel import SentinelAPI, read_geojson, geojson_to_wkt | |
# geojson_file consists of the manual coordinates around the district Birbhum, not the original coordinates, | |
# as with the original coordinates the query becomes huge, and the API throws error. Then it filters the imageries, | |
# around this location in geojson between the 6months from Jan to June 2020 and gives all images which falls within this range. | |
api = SentinelAPI('user', 'password') | |
footprint = geojson_to_wkt(read_geojson(geojson_file)) | |
products = self.api.query(footprint, | |
date=(date(2020,1,1), date(2020,6,30)), | |
area_relation='Intersects', |