1

I have a raster file in numpy array of size 4x9000x10000. The raster file has 4 bands - Red, Green, Blue, NIR and 6 different crop types.

I want to create small arrays of size, say 4x100x100 such that all pixels in the small array belong to the same crop type.

I tried to select a random point from the big array and read 100 pixels around the random point, but it doesnt guarantee that all pixels are going to be of same crop type.

Can you please help me how to do the split

  • 1
    See gis.stackexchange.com/questions/260304/… – BERA Apr 26 '18 at 7:25
  • Do you want to cut just the pixels within the polygons perhaps for some statistical analysis? So the spatial location of the pixels does not matter any more? – user30184 Apr 26 '18 at 9:03
  • Use rasterstats. It will return an array for each feature in your shapefile. – Jon Apr 26 '18 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.