GeoTrellis is a geographic data processing engine for high performance applications.
Exception in thread "main" java.lang.StackOverflowError
at org.locationtech.jts.geom.CoordinateArrays.dimension(CoordinateArrays.java:44)
at org.locationtech.jts.geom.impl.CoordinateArraySequence.<init>(CoordinateArraySequence.java:65)
at org.locationtech.jts.geom.impl.CoordinateArraySequenceFactory.create(CoordinateArraySequenceFactory.java:55)
at org.locationtech.jts.geom.GeometryFactory.createPoint(GeometryFactory.java:267)
at geotrellis.vector.Point$.apply(Point.scala:25)
at geotrellis.vector.reproject.Reproject$.refine$1(Reproject.scala:87)
at geotrellis.vector.reproject.Reproject$.refine$1(Reproject.scala:97)
at geotrellis.vector.reproject.Reproject$.refine$1(Reproject.scala:97)
at geotrellis.vector.reproject.Reproject$.refine$1(Reproject.scala:97)
at geotrellis.vector.reproject.Reproject$.refine$1(Reproject.scala:97)
at geotrellis.vector.reproject.Reproject$.refine$1(Reproject.scala:97)
at geotrellis.vector.reproject.Reproject$.refine$1(Reproject.scala:97)
at geotrellis.vector.reproject.Reproject$.refine$1(Reproject.scala:97)
at geotrellis.vector.reproject.Reproject$.refine$1(Reproject.scala:97)
# Continued...
def assimilate(path: String, catalog: String)(implicit sc: SparkContext): Unit = {
val scheme = ZoomedLayoutScheme(LatLng, tileSize = 256)
val (zoom, rdd) = netcdfToRDD(path, scheme)
val reprojected = rdd.reproject(WebMercator, scheme, Bilinear)
val attributeStore = new FileAttributeStore(catalog)
val writer = new FileLayerWriter(attributeStore, catalog)
writer.write(LayerId("precipitation", zoom), rdd, ZCurveKeyIndexMethod.byHour())
}
@pomadchin here are the shapePolygon and the tileExtent that is inside the polygon
metricLayerRdd.filter( rddKeyVal => {
val key = rddKeyVal._1
val tileExtentPolygon = key.extent(params.metadata.layout)
val contained = shapePolygon.contains(tileExtentPolygon)
if(tileExtentPolygon.contains(pnt.jtsGeom)) {
println(tileExtentPolygon.toGeoJson())
println(shapePolygon.toGeoJson())
println(contained)
System.exit(1)
}
contained
})
output
{"type":"Polygon","coordinates":[[[301599.466697037,4932229.096487437],[301599.466697037,4932230.096487457],[301600.46669720486,4932230.096487457],[301600.46669720486,4932229.096487437],[301599.466697037,4932229.096487437]]]}
{"type":"MultiPolygon","coordinates":[[[[301570.4514820544,4932330.550698328],[301608.4739502942,4932329.050574216],[301615.7797098104,4932283.3908159025],[301567.98736547644,4932285.527373691],[301570.4514820544,4932330.550698328]],[[301568.33936377685,4932265.41646293],[301616.3991255134,4932264.116287277],[301607.37711448024,4932221.9959483575],[301576.71921868704,4932223.2709015105],[301568.33936377685,4932265.41646293]]]]}
false
shapePolygon
?
geotrellis.spark.TileLayerRDD[geotrellis.layer.SpatialKey]
as a single tif file
[error] No implicit view available from geotrellis.layer.SpatialKey => geotrellis.spark.tiling.TilerKeyMethods[geotrellis.layer.SpatialKey,geotrellis.layer.SpatialKey].
[error] rdd.collectMetadata[SpatialKey](layoutScheme)
[error]
val (_: Int, metadata: TileLayerMetadata[SpatialKey]) =
rdd.collectMetadata[SpatialKey](layoutScheme)
rdd.collectMetadata
geotrellis.spark.TileLayerRDD[geotrellis.layer.SpatialKey]
rdd.metadata
rdd.stitch
and that is it
val rdd: TileLayerRDD[SpatialKey] = ???
val raster: Raster[Tile] = rdd.stitch
GeoTiff(raster, rdd.metadata.crs).write(“path/to/output.tiff”)
polygonType match {
case "Polygon" =>
val polygon = jsonString.parseGeoJson[Polygon]
val reprojectedPolygon = polygon.reproject(CRS.fromEpsgCode(polygonEpsg), CRS.fromEpsgCode(epsgCode))
MultiPolygon(Array(reprojectedPolygon))
case "MultiPolygon" =>
val multiPolygon = jsonString.parseGeoJson[MultiPolygon]
multiPolygon.reproject(CRS.fromEpsgCode(polygonEpsg), CRS.fromEpsgCode(epsgCode))
}