Geographic Information Systems Asked by salRad on August 29, 2020
I used the following code from this github repo I know it take a point coodinates and return area of 10 sequare Km around it by transforming Km to degree, but I need to make this area to 5 sequare Km for example. how can I achieve that? The only number I found is (3.75) but I’m not sure what it represents and how to change it to get the area I need.
I know this might sound obvious for some, but I have zero background in GIS and GEO data and I played around with the code but the results I had didn’t make any sense at least for me.
import math
# Distances are measured in kilometers.
# Longitudes and latitudes are measured in degrees.
# Earth is assumed to be perfectly spherical.
earth_radius = 6271.0
degrees_to_radians = math.pi/180.0
radians_to_degrees = 180.0/math.pi
def change_in_latitude(kms):
"Given a distance north, return the change in latitude."
return (kms/earth_radius)*radians_to_degrees
def change_in_longitude(latitude, kms):
"Given a latitude and a distance west, return the change in longitude."
# Find the radius of a circle around the earth at given latitude.
r = earth_radius*math.cos(latitude*degrees_to_radians)
return (kms/r)*radians_to_degrees
def ten_km_square(latitude, longitude):
slat, nlat = latitude+change_in_latitude(-3.75), latitude+change_in_latitude(3.75)
wlon = longitude+change_in_longitude(latitude,-3.75)
elon = longitude+change_in_longitude(latitude, 3.75)
return(nlat, wlon, slat, elon)
def main(lon, lat):
'''First argument degrees longitude (E is positive, W negative)
of the landslide location,
second argument latitude (N positive, S negative),
in decimal format(not minutes etc.)'''
nlat, wlon, slat, elon = ten_km_square(lat,lon)
#print("(NLat:{:.4f},WLon:{:.4f}),(SLat:{:.4f},ELon:{:.4f});".format(nlat, wlon, slat, elon))
print("var region = '[[{:.4f},{:.4f}], [{:.4f},{:.4f}], [{:.4f},{:.4f}], [{:.4f},{:.4f}]]';".format(wlon,nlat,elon,nlat,wlon,slat,elon,slat))
print("var rectangle = [{:.4f},{:.4f},{:.4f},{:.4f}];".format(wlon,slat,elon,nlat))
#change these to longitude, latitude
main(18.07769,44.14354)
Using the code you provided, to get a ~5km² square area you would need a value of 1.118 km instead of 3.75 km
sqrt(5) ~= 2.236 (side of square) / 2 = 1.118 km
Correct answer by Louis Cottereau on August 29, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP