Question : How to draw land using its 4 points GPS coordinates?

Dear all,
I have a problem and i hope you can help me. I want to know how to draw a land using its 4 points GPS coordinates.
I have the coordinates of the border points of the land and i imported the location which includes it on Sketchup, but i cant find a way to draw my exact land borders using the GPS coordinates?

  1. Open Window → Ruby Console
  2. Replace the decimal coordinates in this snippet (in latitude, longitude order):
coordinates = [
  [-105.270556, 40.015],
  [-105.270120, 40.015],
  [-105.270120, 40.016],
  [-105.270556, 40.016]
]
model = Sketchup.active_model
model.active_entities.add_face(coordinates.map{ |c| model.latlong_to_point(c) })
  1. Paste and enter
2 Likes

worked well !!! many thanks

Hi @Aerilius, I was trying to find a method to do exactly what you shared in this post and tried your snipet.

It was the best method yet, but my results are not right.

The thing is that I was able to convert GPS coordinates from DMS to DD and the data is right, but then when I use your code, the points are off.

I wonder if it has to do with my units settings. I’m using metric and your code might be for imperial?

I would really thank you if you could help me. Thanks in advance,

João

try, converting :

model.active_entities.add_face(coordinates.map{ |c|
 model.latlong_to_point(c.map(&:to_inch)) })

john

In SketchUp we don’t design code for verious units. There is only one type of units that are internally used (and these are non-standard inch instead of SI units, but that’s another topic). We only need to convert user input, or convert internal units for user display.

The code snippet takes geocoordinates in decimal degrees (these are neither metric nor empirial) and converts them to SketchUp’s internal units. Then it tells SketchUp to draw a face from given coordinates in internal units. This seems consistent.

  • Are you sure that you provide the longitude first, then the latitude (the method name is misleading)?

  • What I could imagine is that the geocoordinates are in a different projection than the one that SketchUp uses. I didn’t figure out which projection SketchUp uses.

    If you have the geocoordinates in UTM format, you can also use these:

    #                       zone_number, zone_letter, x, y
    lon_lat = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749).to_latlong.to_a.reverse
    model.latlong_to_point(lon_lat)