Created
March 7, 2020 17:18
-
-
Save lakshmanok/26c7276fdaab495ec55b8c71739125d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_geo(LATRES, LONRES, ORIGIN_LAT, ORIGIN_LON, rowno, startcol, endcol): | |
# represent each rectangle by a polygon of its corners | |
top = ORIGIN_LAT - rowno * LATRES | |
bot = ORIGIN_LAT - (rowno+1) * LATRES | |
left = ORIGIN_LON + startcol * LONRES | |
right = ORIGIN_LON + endcol * LONRES | |
poly = json.dumps({ | |
'type': 'Polygon', | |
'coordinates': [ | |
[ # polygon 1 | |
[left, top], # topleft | |
[left, bot], # botleft | |
[right, bot], # botright | |
[right, top], # topright | |
[left, top] # same as first point | |
] | |
] | |
}) | |
center = 'POINT({:2f} {:2f})'.format( (left+right)/2, (top+bot)/2 ) | |
return poly, center, endcol | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment