Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 6 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ orbs:
executors:
default:
docker:
- image: docker.pkg.github.com/locationtech/rasterframes/miniconda-gdal:latest
auth:
username: $GITHUB_USERNAME
password: $GITHUB_PASSWORD
resource_class: medium
- image: s22s/miniconda-gdal:latest
working_directory: ~/repo
environment:
SBT_VERSION: 1.3.8
Expand Down Expand Up @@ -152,7 +148,6 @@ jobs:

docs:
executor: sbt/default
resource_class: large
steps:
- checkout
- sbt/setup
Expand All @@ -172,7 +167,6 @@ jobs:

it:
executor: sbt/default
resource_class: large
steps:
- checkout
- sbt/setup
Expand All @@ -190,7 +184,6 @@ jobs:

it-no-gdal:
executor: sbt/default
resource_class: large
steps:
- checkout
- sbt/setup
Expand All @@ -215,11 +208,9 @@ workflows:
version: 2
all:
jobs:
- test:
context: rasterframes
- test

- it:
context: rasterframes
requires:
- test
filters:
Expand All @@ -229,7 +220,6 @@ workflows:
- /it\/.*/

- it-no-gdal:
context: rasterframes
requires:
- test
filters:
Expand All @@ -239,7 +229,6 @@ workflows:
- /it\/.*/

- docs:
context: rasterframes
filters:
branches:
only:
Expand All @@ -256,11 +245,7 @@ workflows:
only:
- develop
jobs:
- test:
context: rasterframes
- it:
context: rasterframes
- it-no-gdal:
context: rasterframes
- docs:
context: rasterframes
- test
- it
- it-no-gdal
- docs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ class RasterSourceSpec extends TestEnvironment with TestData {
gdal.bandCount should be (3)
}

it("should support nested vsi file paths") {
val path = URI.create("gdal://vsihdfs/hdfs://dp-01.tap-psnc.net:9000/user/dpuser/images/landsat/LC081900242018092001T1-SC20200409091832/LC08_L1TP_190024_20180920_20180928_01_T1_sr_band1.tif")
assert(RFRasterSource(path).isInstanceOf[GDALRasterSource])
}

it("should interpret no scheme as file://") {
val localSrc = geotiffDir.resolve("LC08_B7_Memphis_COG.tiff").toString
val schemelessUri = new URI(localSrc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ package object geotiff {
tag[GeoTiffRasterFrameWriterTag][DataFrameWriter[T]](
writer.format(GeoTiffDataSource.SHORT_NAME)
)

}
implicit class GeoTiffFormatHasOptions[T](val writer: GeoTiffRasterFrameWriter[T]) {
def withDimensions(cols: Int, rows: Int): GeoTiffRasterFrameWriter[T] =
tag[GeoTiffRasterFrameWriterTag][DataFrameWriter[T]](
writer
Expand Down
59 changes: 59 additions & 0 deletions datasource/src/test/scala/examples/ExplodeWithLocation.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* This software is licensed under the Apache 2 license, quoted below.
*
* Copyright 2020 Astraea, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* SPDX-License-Identifier: Apache-2.0
*
*/

package examples

import geotrellis.raster._
import geotrellis.vector.Extent
import org.apache.spark.sql._
import org.apache.spark.sql.functions._
import org.locationtech.rasterframes._
import org.locationtech.rasterframes.datasource.raster._
import org.locationtech.rasterframes.encoders.CatalystSerializer._

object ExplodeWithLocation extends App {

implicit val spark = SparkSession.builder()
.master("local[*]").appName("RasterFrames")
.withKryoSerialization.getOrCreate().withRasterFrames
spark.sparkContext.setLogLevel("ERROR")

import spark.implicits._

val example = "https://raw.githubusercontent.com/locationtech/rasterframes/develop/core/src/test/resources/LC08_B7_Memphis_COG.tiff"
val rf = spark.read.raster.from(example).withTileDimensions(16, 16).load()

val grid2map = udf((encExtent: Row, encDims: Row, colIdx: Int, rowIdx: Int) => {
val extent = encExtent.to[Extent]
val dims = encDims.to[Dimensions[Int]]
GridExtent(extent, dims.cols, dims.rows).gridToMap(colIdx, rowIdx)
})

val exploded = rf
.withColumn("dims", rf_dimensions($"proj_raster"))
.withColumn("extent", rf_extent($"proj_raster"))
.select(rf_explode_tiles($"proj_raster"), $"dims", $"extent")
.select(grid2map($"extent", $"dims", $"column_index", $"row_index") as "location", $"proj_raster" as "value")

exploded.show(false)

spark.stop()
}
58 changes: 58 additions & 0 deletions datasource/src/test/scala/examples/ValueAtPoint.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* This software is licensed under the Apache 2 license, quoted below.
*
* Copyright 2020 Astraea, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* [http://www.apache.org/licenses/LICENSE-2.0]
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* SPDX-License-Identifier: Apache-2.0
*
*/

package examples

import org.apache.spark.sql._
import org.apache.spark.sql.functions._
import org.locationtech.rasterframes._
import org.locationtech.rasterframes.datasource.raster._
import org.locationtech.rasterframes.encoders.CatalystSerializer._
import geotrellis.raster._
import geotrellis.vector.Extent
import org.locationtech.jts.geom.Point

object ValueAtPoint extends App {

implicit val spark = SparkSession.builder()
.master("local[*]").appName("RasterFrames")
.withKryoSerialization.getOrCreate().withRasterFrames
spark.sparkContext.setLogLevel("ERROR")

import spark.implicits._

val example = "https://raw.githubusercontent.com/locationtech/rasterframes/develop/core/src/test/resources/LC08_B7_Memphis_COG.tiff"
val rf = spark.read.raster.from(example).withTileDimensions(16, 16).load()
val point = st_makePoint(766770.000, 3883995.000)

val rf_value_at_point = udf((extentEnc: Row, tile: Tile, point: Point) => {
val extent = extentEnc.to[Extent]
Raster(tile, extent).getDoubleValueAtPoint(point)
})

rf.where(st_intersects(rf_geometry($"proj_raster"), point))
.select(rf_value_at_point(rf_extent($"proj_raster"), rf_tile($"proj_raster"), point) as "value")
.show(false)

//rf.show()

spark.stop()
}