Aggregate 30m pixel binary on average to 1km

60 views
Skip to first unread message

Carlos Leandro Cordeiro

unread,
Mar 7, 2018, 9:22:44 AM3/7/18
to RSGISLib Support
Hi everyone, I have a question. I have a raster of 30 m with 1 and 0 and need to aggregate the pixels to 1 km using the averages of these pixel of 30 m. I'm trying to use the script below, 

#!/usr/bin/env python
# Import RSGISLib modules
import rsgislib
from rsgislib import imageutils
# Set up list of images to stack
inRefImg = 'exemplo_albers2_IBGE_WGS84_Brasil.tif'
# Set names for image bands
inProcessImg = 'equals2.tif'
# Set output image
outImg = 'equals2-averaged_30m.tif'
# Stack band
rsgislib.imageutils.resampleImage2Match(inRefImg, inProcessImg, outImg, 'KEA', 'average', datatype=None, noDataVal=None, multicore=False)

but it returns me this error. 

  File "media_reamost.py", line 12
SyntaxError: Non-ASCII character '\xc2' in file media_reamost.py on line 12, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

I've tried it in many ways, but it always returns some error. Can anybody help me?

thanks

Thiago Sanna Freire Silva

unread,
Mar 16, 2018, 7:28:24 AM3/16/18
to RSGISLib Support
The problem seems to be with the text encoding of the script file, there is some weird character on line 12 that is not being recognized.  I just copied your text and saved as a UTF-8 file on my PC (attached), see if it fixes it.
media_reamost.py

Carlos Leandro Cordeiro

unread,
Mar 19, 2018, 9:23:18 AM3/19/18
to RSGISLib Support
Thanks Thiago. abcs
Reply all
Reply to author
Forward
0 new messages