DynaSlum/satsense

Use satsense for Sentinel 2 tif

prakharcode opened this issue · 3 comments

As a user,
I want to run satsense over a few sentinel-2 tiles, and osm shapefile as my ground label
because I want to do landcover classification.

@bouweandela any idea?

I read the code and tried to implement it for TCI tile sentinel2, it gives an error to register the itype using register method. Can you help me with that?

Hi @prakharcode,

I have used satsense to extract features from a sentinel2 image, so this should in principle be possible. Sentinel2 has the same band structure as quickbird so if you specify that when loading the image it should work.

Something like this should work:

import matplotlib.pyplot as plt

from satsense import Image
from satsense.generators import FullGenerator
from satsense.features import NirNDVI
from satsense import extract_features

# URI to the image
imagefile = 'path/to/your/sentinel2_image.tif'

# Loading the file
image = Image(imagefile, 'quickbird')
image.precompute_normalization()

# Define the step from one window to the next
step_size = [10, 10]
# Define one or more window sizes 
windows=[(10, 10)]

# Define the features to calculate
features = [
  NirNDVI(windows)
]
generator = FullGenerator(image, step_size)

# Extract the features (using 1 cpu)
# extract_features is a generator, therefore use the next() function
feature_vector = next(extract_features(features, generator, n_jobs=1))

plt.imshow(feature_vector.vector[:, :, 0, 0])

@prakharcode Have you been able to resolve your issue? If so I can close this issue.