furqaankhan commented on code in PR #1011:
URL: https://github.com/apache/sedona/pull/1011#discussion_r1319283735
##########
common/src/main/java/org/apache/sedona/common/raster/RasterConstructors.java:
##########
@@ -45,6 +55,94 @@ public static GridCoverage2D fromGeoTiff(byte[] bytes)
throws IOException {
return geoTiffReader.read(null);
}
+ /**
+ * Returns a raster that is converted from the geometry provided.
+ * @param geom The geometry to convert
+ * @param raster The reference raster
+ * @param pixelType The data type of pixel/cell of resultant raster
+ * @param value The value of the pixel of the resultant raster
+ * @param noDataValue The noDataValue of the resultant raster
+ *
+ * @return Rasterized Geometry
+ * @throws FactoryException
+ */
+ public static GridCoverage2D asRaster(Geometry geom, GridCoverage2D
raster, String pixelType, double value, Double noDataValue) throws
FactoryException {
+
+ DefaultFeatureCollection featureCollection =
getFeatureCollection(geom, raster.getCoordinateReferenceSystem());
+
+
+ double[] metadata = RasterAccessors.metadata(raster);
+ // The current implementation doesn't support rasters with properties
below
+ // It is not a problem as most rasters don't have these properties
+ // ScaleX < 0
+ if (metadata[4] < 0) {
+ throw new IllegalArgumentException(String.format("ScaleX %f of the
raster is negative, it should be positive", metadata[4]));
+ }
+ // ScaleY > 0
+ if (metadata[5] > 0) {
Review Comment:
If the ScaleX < 0 and ScaleY > 0 then we would have to flip the raster. To
keep the function simple, we decided to not do it for now. I consulted Kristin
on this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]