-
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add longitude and latitude to conical converter (#329)
* Create lonlat_converter_lambert.py * Create readme.md * Rename Longitude Latitude conical converter/Python/lonlat_converter_lambert.py to Longitude Latitude conical converter/lonlat_converter_lambert.py * Rename Longitude Latitude conical converter/Python/readme.md to Longitude Latitude conical converter/readme.md * Update README.md
- Loading branch information
1 parent
0073d35
commit 66161ee
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
Longitude Latitude conical converter/lonlat_converter_lambert.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from pyproj import Proj | ||
from shapely.geometry import Point | ||
from shapely.geometry.polygon import Polygon | ||
|
||
# Definition of lambert conical projection. | ||
lambert = {'proj': 'lcc', # Lambert Conformal Conic 2SP (epsg:9802) | ||
'ellps': 'GRS80', #'epsg:7019', #'epsg:9802', # 'epsg:6651', | ||
'lon_0': -102.00000000, | ||
'lat_0': 12.00000000, # 12° 00’ 0.0’’ N | ||
'lat_1': 17.50000000, # 17° 30’ 0.00’’ N | ||
'lat_2': 29.50000000, # 29° 30’ 0.00’’ N | ||
'x_0': 2500000, | ||
'y_0': 0} | ||
|
||
prj = Proj(lambert) | ||
|
||
# Coordinates for the city of Monterrey, Nuevo León, México | ||
|
||
city = {'c_name': 'Monterrey', 'lon': -100.316116, 'lat': 25.686613} | ||
|
||
x, y = prj(city['lon'], city['lat']) | ||
|
||
print(' X Y') | ||
print(city['c_name'], ': lon:', city['lon'], ' , lat:', city['lat']) | ||
print('Lambert function:', x, ',', y) | ||
print(' Should return: 2668223.843 , 1516271.922') | ||
|
||
# Should return: | ||
|
||
""" | ||
X Y | ||
Monterrey : lon: -100.316116 , lat: 25.686613 | ||
Lambert function: 2668223.842598227 , 1516271.9216458194 | ||
Should return: 2668223.843 , 1516271.922 | ||
""" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## Longitude and Latitude to Conical Converter | ||
|
||
This script converts longitude and latitude to [Lambert conformal conic projection](https://en.wikipedia.org/wiki/Lambert_conformal_conic_projection). | ||
The example used is for Mexico, under International Terrestrial Reference Frame 2008, which uses Lambert Conformal Conic projection 2SP (epsg:9802). | ||
|
||
This script is useful to combine census and geographic data, with traditional Longitude and Latitude from the more international frame of reference. | ||
|
||
For more reference, see [National Geography institute explanatory PDF](https://www.inegi.org.mx/contenidos/temas/MapaDigital/Doc/asignar_sistema_coordenadas.pdf) | ||
and [Pyproj, Lambert projections](https://proj.org/operations/projections/lcc.html). | ||
|
||
## Prerequisites | ||
- Python 3.x installed on your machine. | ||
|
||
## Dependencies | ||
The script requires the following Python libraries: | ||
`pyproj` | ||
`shapely` | ||
|
||
You can install the required library using pip: | ||
`pip install pyproj` | ||
`pip install shapely` |
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