harsha2010 / magellan

Geo Spatial Data Analytics on Spark
Apache License 2.0
534 stars 149 forks source link

variable x in class Point cannot be accessed in Magellan.Point #104

Open nyitzkj1992 opened 7 years ago

nyitzkj1992 commented 7 years ago

Hi Ram,

This is Jay. Finally I solved the previous issue by adding Magellan. before Point or Polygon.

However, I ran into a new issue. That I want to follow the sample project.

I use magellan:1.0.4-s_2.11 and that project example used magellan:1.0.3-s_2.10.

I tried to run: val transformer: Point => Point = (point: Point) => { val from = new NAD83(Map("zone" -> 403)).from() val p = point.transform(from) Point(3.28084 p.x, 3.28084 p.y) }

And get the error variable x in class Point cannot be accessed in Magellan.Point

Attached is the screenshot.

Thank you

Jay capture

harsha2010 commented 7 years ago

@nyitzkj1992 can you try p.getX instead of p.x and similarly p.getY instead of p.y? I have removed public access to the fields to make it easier to change the data layout of the Point , Polygon etc for optimization purposes

nyitzkj1992 commented 7 years ago

Thank you Ram.

The definition works, but it looks like it does not complete a right transformer. The numbers are not right obviously. capture

You can see the screenshot.

nyitzkj1992 commented 7 years ago

O... does this transform only applies for California data? I do not know which state does my dataset belong to

harsha2010 commented 7 years ago

what are you trying to transform? are you trying the uber example in Magellan or something else? can you attach the entire code?

harsha2010 commented 7 years ago

yeah, the value "403" is for california.. You'll have to use a value appropriate to your state

On Thu, Mar 9, 2017 at 10:51 PM, nyitzkj1992 notifications@github.com wrote:

O... does this transform only applies for California data? I do not know which state does my dataset belong to

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/harsha2010/magellan/issues/104#issuecomment-285494881, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQmVLKiKWQ38FUIz0gqRImD52tYGgzJks5rkHRPgaJpZM4MYl0G .

-- Ram Sriharsha Product Manager, Apache Spark PPMC Member and Committer, Apache Spark Databricks San Francisco, CA Ph: 408-510-8635 email: harsha@apache.org

[image: https://www.linkedin.com/in/harsha340] https://www.linkedin.com/in/harsha340 https://twitter.com/halfabrane https://github.com/harsha2010/

nyitzkj1992 commented 7 years ago

Hi Ram, Below is my code. I use the USA country map downloaded from ArcGis because my dataset is a countrywide data.

val df = sqlContext.read.format("magellan").load("pathUSA").select($"polygon", $"metadata".getItem("STATE_ABBR")).withColumnRenamed("metadata[STATE_ABBR]", "State")

case class Record(ID: String, timestp: String, point: magellan.Point)

val twinecsv = sc.cassandraTable("twinedata","twine_all").limit(40000).map {row => val ID = row.getString("mobileadid") val timestp = row.getString("timestp") val point = Point(row.getDouble("latitude"),row.getDouble("longitude")) Record(ID, timestp, point)}.toDF()

val transformer: Point => Point = (point: Point) => { val from = new NAD83(Map("zone" -> 403)).from() val p = point.transform(from) Point(3.28084 p.getX, 3.28084 p.getY) }

val twinecsvTransformed = twinecsv. withColumn("nad83", $"point".transform(transformer)).cache()

df.join(twinecsvTransformed).where($"nad83" intersects $"polygon"). select($"ID", $"timestp", $"State", $"polygon").show(5)