Select to view content in your preferred language

Fire Analysis

827
4
12-08-2020 01:00 AM
KrishV
by
Frequent Contributor

Hi Everyone,

 

I'm trying to use California wildfires 2017 - Thomas Fire analysis Sample provided in ArcGIS Python API Samples.

 

I have used sentinel imagery to do the same analysis but I always end up getting black imagery (All 0s). Can you please suggest where I'm doing wrong?

 

 

import arcgis
from arcgis import *
from arcgis.mapping import MapImageLayer

gis = GIS(profile="krishna_dev") 

#Sentinel2 
sentinel_item = gis.content.search('title:Sentinel2', 'Imagery Layer', outside_org=True)[0]
sentinel = sentinel_item.layers[0]
sentinel_item

aoi = {'spatialReference': {'latestWkid': 3857, 'wkid': 102100}, 'type': 'extent', 
       'xmax': 9028482.969, 'xmin': 8908018.212, 'ymax': 2478700.211, 'ymin': 2248166.133}

arcgis.env.analysis_extent = {'xmax': 9028482.969, 'xmin': 8908018.212, 'ymax': 2478700.211, 'ymin': 2248166.133,
                              "spatialReference":{"wkid":102100,"latestWkid":3857}}
sentinel.extent = aoi

import pandas as pd
from datetime import datetime


selected = sentinel.filter_by(where="(Category = 1)",
                             time=[datetime(2020, 4, 3), datetime(2020, 4, 15)],
geometry=arcgis.geometry.filters.intersects(aoi))

df = selected.query(out_fields="acquisitiondate, name, cloudcover", 
                    order_by_fields="acquisitiondate").sdf
df['acquisitiondate'] = pd.to_datetime(df['acquisitiondate'], unit='ms')
df.tail()

prefire = sentinel.filter_by('OBJECTID in ( 10127407, 10187367)') # 2020-04-03
prefire = prefire.blend()

midfire = sentinel.filter_by('OBJECTID in (10304749, 10304746)') # 2020-04-13 
midfire = midfire.blend()

from arcgis.raster.functions import *

extracted_band = extract_band(midfire, [13,12,4])
extracted_band_prefire = extract_band(prefire, [13,12,4])

nbr_prefire  = band_arithmetic(prefire, "(b9 - b13) / (b9 + b13) + 2000")
nbr_postfire = band_arithmetic(midfire, "(b9 - b13) / (b9 + b13) + 2000")

nbr_diff = nbr_prefire - nbr_postfir

nbr_diff

burnt_areas = colormap(remap(nbr_diff,
                             input_ranges=[0.1,  0.27,  # low severity 
                                           0.27, 0.44,  # medium severity
                                           0.44, 0.66,  # moderate severity
                                           0.66, 1.00], # high severity burn
                             output_values=[1, 2, 3, 4],                    
                             no_data_ranges=[-1, 0.1], astype='u8'), 
                             colormap=[[4, 0xFF, 0xC3, 0], [3, 0xFA, 0x8E, 0], [2, 0xF2, 0x55, 0], [1, 0xE6, 0,    0]])

burnt_areas

 

 

Thanks,

Krish

0 Kudos
4 Replies
DanPatterson
MVP Esteemed Contributor

You would be better served if you posted your code...

Code formatting ... the Community Version - GeoNet, The Esri Community


... sort of retired...
0 Kudos
KrishV
by
Frequent Contributor

Hi @DanPatterson ,

I attached the entire notebook in the zip file.

 

Thanks,

Krish

 

0 Kudos
DanPatterson
MVP Esteemed Contributor

So you want people to run the notebook rather than examine the code?


... sort of retired...
0 Kudos
KrishV
by
Frequent Contributor

Hi @DanPatterson ,

Updated the post with code!

 

Thanks,

Krish

0 Kudos