Created
April 9, 2014 19:52
-
-
Save ejc123/10307890 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val valid = geotrellis.data.geojson.GeoJsonReader.parse(geoJson).get.filter(node => node.geom.isValid && node.geom.getGeometryType == "Polygon").map { | |
g => (Polygon(g.geom,0), g.geom.getCentroid.getCoordinate) | |
} | |
val results = months.flatMap { | |
month => { | |
val raster = RasterSource(store, s"${month}${year}NDVI_TOA_UTM14") | |
val mask = RasterSource(store, s"${month}${year}ACCA_State_UTM14") | |
val masked = raster.localMask(mask, 1, NODATA).cached | |
val sources = valid.map { | |
case (poly, coord) => | |
masked.zonalMean(poly).map { | |
result => if (isNoData(result)) (coord, month, "") | |
else | |
(coord, month, math.round(result).toString) | |
} | |
} | |
val ds = DataSource.fromSources(sources) | |
ds.run match { | |
case Complete (result,_) => result | |
} | |
} | |
} |
lossyrob
commented
Apr 9, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment