2

I load a set of point from a CSV file to a RDD:

case class yieldrow(Elevation:Double,DryYield:Double)

val points :RDD[PointFeature[yieldrow]] = lines.map { line =>
  val fields = line.split(",")
  val point = Point(fields(1).toDouble,fields(0).toDouble)
  Feature(point, yieldrow(fields(4).toDouble,fields(20)))
}

Then get:

points: org.apache.spark.rdd.RDD[geotrellis.vector.PointFeature[yieldrow]] 

Now need to reproject from EPSG:4326 to EPSG:3270

So I create the CRS from and to:

val crsFrom : geotrellis.proj4.CRS =  geotrellis.proj4.CRS.fromName("EPSG:4326")
val crsTo : geotrellis.proj4.CRS =  geotrellis.proj4.CRS.fromEpsgCode(32720)

But I can not create the transform and also i don not know:

Hot to apply a transform to a single point:

val pt = Point( -64.9772376007928, -33.6408083223936)

How to use the mapGeom method of Feature to make a CRS transformation ?

points.map(_.mapGeom(?????))
points.map(feature => feature.mapGeom(????))

How to use ReprojectPointFeature(pointfeature) ?

The documentation not have basic code samples.

Any help will be appreciate

user2232395
  • 461
  • 5
  • 15

1 Answers1

1

I'll start from the last question:

Indeed to perform a reproject on a PointFeature you can use ReprojectPointFeature implict case class. To use it just be sure that you have import geotrellis.vector._ in reproject function call scope.

import geotrellis.vector._
points.map(_.reproject(crsFrom, crsTo))

The same import works for a Point too:

import geotrellis.vector._
pt.reproject(crsFrom, crsTo)
points.map(_.mapGeom(_.reproject(crsFrom, crsTo)))
DaunnC
  • 1,301
  • 15
  • 30
  • 1
    Thanks, I read the API and the Geometry don not have the reproject method: http://geotrellis.github.io/scaladocs/latest/#geotrellis.vector.Geometry But there is a Implicits in geotrellis.vector.reproject.Implicits http://geotrellis.github.io/scaladocs/latest/#geotrellis.vector.reproject.Implicits$ReprojectGeometry So now understand that it work using the implicits way. – user2232395 Nov 13 '17 at 11:57
  • trying ftRdd.map(_.mapGeom(_.reproject(crsFrom, crsTo))), give me org.apache.spark.SparkException: Task not serializable: Task not serializable – user2232395 Nov 13 '17 at 22:53