Skip to content

[fsm-scala] Hadoop filesystem error #13

@KipCrossing

Description

@KipCrossing

When trying to run the processors, I get:

[error] (run-main-0) java.lang.IllegalArgumentException: Expected authority at index 7: hdfs://
[error] java.lang.IllegalArgumentException: Expected authority at index 7: hdfs://
[error] 	at java.net.URI.create(URI.java:852)
[error] 	at org.apache.hadoop.fs.FileSystem.getDefaultUri(FileSystem.java:236)
[error] 	at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:227)
[error] 	at org.fsm.hfs.HFSUtils$.fileSystem(HFSUtils.scala:67)
[error] 	at org.fsm.hfs.HFSUtils$.exisits(HFSUtils.scala:93)
[error] 	at org.fsm.mapreduce.GridDataFolder.<init>(GridDataset.scala:41)
[error] 	at org.fsm.Paddock.folder$lzycompute(Paddock.scala:19)
[error] 	at org.fsm.Paddock.folder(Paddock.scala:19)
[error] 	at org.fsm.Paddock.getAllDataAsRDD(Paddock.scala:23)
[error] 	at org.fsm.processors.CLHCProcessor.$anonfun$build$11(CLHCProcessor.scala:40)
[error] 	at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:237)
[error] 	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
[error] 	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
[error] 	at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:39)
[error] 	at scala.collection.TraversableLike.map(TraversableLike.scala:237)
[error] 	at scala.collection.TraversableLike.map$(TraversableLike.scala:230)
[error] 	at scala.collection.AbstractTraversable.map(Traversable.scala:108)
[error] 	at org.fsm.processors.CLHCProcessor.build(CLHCProcessor.scala:38)
[error] 	at RunProgram$.main(RunProgram.scala:57)
[error] 	at RunProgram.main(RunProgram.scala)
[error] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] 	at java.lang.reflect.Method.invoke(Method.java:498)

My script:

import java.io.File
import java.net.URL

import geotrellis.vector.Polygon
import org.fsm.processors.{CLHCProcessor, LHCConfig, SampleAlignProcessor}
import org.fsm.{DataFormat, GridDataFile, NDVIFile, Paddock, PointDataset}
import org.geotools.geojson.feature.FeatureJSON
import org.locationtech.jts.geom.GeometryFactory
import org.opengis.feature.simple.SimpleFeature
import play.api.libs.json.Json

object RunProgram{
  def main(args: Array[String]): Unit = {
    println("It is running")
    val nirInput = new File(s"/home/kipling/Documents/fsm_sample_data/nir.tif").toURI().toURL()
    val nirData = GridDataFile(uid="nir", metricType="Average NDVI", file=nirInput, fileType=DataFormat.Tiff)


    val redInput = new File(s"/home/kipling/Documents/fsm_sample_data/red.tif").toURI().toURL()
    val redData = GridDataFile(uid="red", metricType="Average NDVI", file=redInput, fileType=DataFormat.Tiff)


    val elevationInput = new File(s"/home/kipling/Documents/fsm_sample_data/dem.tif").toURI().toURL()
    val elevationFile = GridDataFile(uid="dem_123", metricType="Elevation", file=elevationInput, fileType=DataFormat.Tiff)


    val ndviFile = NDVIFile(id="ndvi", red=redData, nir=nirData)


    val paddockJson = new FeatureJSON().readFeatureCollection(new File(s"/home/kipling/Documents/fsm_sample_data/paddocks.json").toURI().toURL().openStream())
    val samplePoints = Json.parse(new File(s"/home/kipling/Documents/fsm_sample_data/samples.json").toURI().toURL().openStream()).as[List[PointDataset]]

    val geomFactory = new GeometryFactory()

    val paddocks = paddockJson.toArray().flatMap{
      case sf:SimpleFeature if sf.getDefaultGeometry.isInstanceOf[Polygon] =>
        val bounds = sf.getDefaultGeometry.asInstanceOf[Polygon]
        println(bounds)
        val samplesInside = samplePoints.filter(s => bounds.contains(geomFactory.createPoint(s.location)))
        println(samplesInside)
        Some(
          Paddock(
            ndviFiles = List(ndviFile),
            otherGridFiles = List(elevationFile),
            bounds = bounds,
            soilPointDataArray = samplesInside,
            id = sf.getID
          )
        )
      case _ =>
        None
    }
    println(paddocks);
    println(paddocks.length);

    val lhcConfig = Option(LHCConfig(samples=4, metrics=Seq("Average NDVI", "Elevation"), perPaddock = false))
    val lhcRes = new CLHCProcessor().build(paddocks, lhcConfig)
    print(lhcRes)

  }

}

And intelliJ configs:

intelliJ_run_settings

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions