Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mosaic using "count()" method #24

Closed
7yl4r opened this issue Nov 26, 2019 · 4 comments
Closed

mosaic using "count()" method #24

7yl4r opened this issue Nov 26, 2019 · 4 comments

Comments

@7yl4r
Copy link
Member

7yl4r commented Nov 26, 2019

mosaic of the count of images covering this area

does gdal have a count method?

@7yl4r
Copy link
Member Author

7yl4r commented Nov 26, 2019

does gdal have a count method?

No. We would need to use gdal_calc.
Seems like a "gdal fn reduce" implmentation is needed for both this & #17

@7yl4r 7yl4r self-assigned this Nov 26, 2019
@7yl4r
Copy link
Member Author

7yl4r commented Nov 26, 2019

A reduce implementation for count would look something like:

reduce( lambda a,b: b+int(a > 0), list_of_images)

for #17 it might be like:

reduce( max, list_of_images)

@7yl4r
Copy link
Member Author

7yl4r commented Dec 2, 2019

Done using vrt methods described on #17

  <VRTRasterBand dataType="Byte" band="1" subClass="VRTDerivedRasterBand">
    <PixelFunctionType>count</PixelFunctionType>
    <PixelFunctionLanguage>Python</PixelFunctionLanguage>
    <PixelFunctionCode><![CDATA[
import numpy as np
def count(in_ar, out_ar, xoff, yoff, xsize, ysize, raster_xsize,
                   raster_ysize, buf_radius, gt, **kwargs):
    np.clip(np.count_nonzero(in_ar, axis = 0),0,15, out = out_ar)
]]>
    </PixelFunctionCode>

edit: changed clip 255 to 15

@7yl4r 7yl4r closed this as completed Dec 3, 2019
@7yl4r
Copy link
Member Author

7yl4r commented Dec 9, 2019

Tested w/ clip 255 on my pc:

[tylar@tylar-pc circe_output]$ time gdaladdo -ro swtx_2019-12-05_coverage.vrt 10
0...10...20...30...40...50...60...70...80...90...100 - done.

real	226m20.006s
user	203m30.257s
sys	21m17.668s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant