Created
September 19, 2018 18:29
-
-
Save Saigesp/506055bc97406c3be8150a7e65aa3675 to your computer and use it in GitHub Desktop.
Convert between projections epsg:25830 and epsg:4326 used in INE (Instituto Nacional de Estadística, Spain)
This file contains hidden or 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
# returns latlng | |
def get_maxmin_latlon_region(region): | |
lon_max = -180 | |
lon_min = 180 | |
lat_max = -90 | |
lat_min = 90 | |
if region['type'] == 'Polygon': | |
for polygon in region['coordinates']: | |
for point in polygon: | |
point = translate_projections(point) | |
if point[0] > lon_max: lon_max = point[0] | |
if point[0] < lon_min: lon_min = point[0] | |
if point[1] > lat_max: lat_max = point[1] | |
if point[1] < lat_min: lat_min = point[1] | |
return [lat_max,lon_max,lat_min,lon_min] | |
# returns latlng | |
def translate_projections(point): | |
inProj = Proj(init='epsg:25830') | |
outProj = Proj(init='epsg:4326') | |
x2,y2 = transform(inProj,outProj,point[0],point[1]) | |
return [y2,x2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Buenas @Saigesp,
no debería estar aquí la función "transform", a la que le envías inProj, outProj, point[0] y point[1], para que el código estuviera completo y fuera funcional?