I wish to create a polygon that looks like this (it's a tree and a root scan): enter image description here I have a file containing positions where readings have been taken, and I have the centre point and the projection. So, for example, reading 1 is 35cm north of the centre, reading R2 is 135cm north of the centre.

This point has a centre Latitude: 57.802384, Longitude: 12.03286745 in EPSG:4326

How do I add this increase to e.g. the latitude? I'm using Python GDAL, I'm sure there'a a function I can use.

The code I've tried is:

nodeX = float(latitude) + (float(data[1])/100) + ((float(data[6])/100) / 2) + (float(data[7]) / 100)

but the result is way too big an increase.

  • 1
    Of course it doesn't scale right -- You"re adding centimeters to degrees.
    – Vince
    May 28 '17 at 14:13

Found this post: algorithm-for-offsetting-a-latitude-longitude-by-some-amount-of-meters, and reworked my example, which now reads like this:

# factor = 111,111 meters (+ 00 to get centimetres)
factor = 11111100
ring = ogr.Geometry(ogr.wkbLinearRing)
# Loop through data
  offsetX = float(data[1]) / factor
  offsetY = float(data[2]) / factor
  nodeX = float(latitude) + offsetY
  nodeY = float(longitude) + offsetX
  ring.AddPoint(nodeY, nodeX)

# Create polygon
poly = ogr.Geometry(ogr.wkbPolygon)
writeShapefile( poly )

Result looks ok, bit of fine tuning of the points needed perhapsenter image description here

  • 1
    As this is quite high scale data I highly recommend that you project your coordinates into a local UTM projection first. Then you can work with centimeters or millimeters without problems. Your linked question was about "within 10 meters". The 111,111 is meant for that. It will NOT lead to reasonable results for your level of accuracy. May 28 '17 at 18:26
  • Thanks @bugmenot123 - am I right in thinking SWEREF 99 TM might be the one for me here in Sweden?
    – minisaurus
    May 30 '17 at 14:11
  • Or maybe SWEREF 99 12 00 is better for large scale?
    – minisaurus
    May 30 '17 at 14:34
  • 1
    Sounds good if my German reading of Swedish is correct on sv.wikipedia.org/wiki/SWEREF_99#Nationellt_koordinatsystem :) May 31 '17 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.