Skip to content

Commit 66161ee

Browse files
authored
Add longitude and latitude to conical converter (DhanushNehru#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
1 parent 0073d35 commit 66161ee

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from pyproj import Proj
2+
from shapely.geometry import Point
3+
from shapely.geometry.polygon import Polygon
4+
5+
# Definition of lambert conical projection.
6+
lambert = {'proj': 'lcc', # Lambert Conformal Conic 2SP (epsg:9802)
7+
'ellps': 'GRS80', #'epsg:7019', #'epsg:9802', # 'epsg:6651',
8+
'lon_0': -102.00000000,
9+
'lat_0': 12.00000000, # 12° 00’ 0.0’’ N
10+
'lat_1': 17.50000000, # 17° 30’ 0.00’’ N
11+
'lat_2': 29.50000000, # 29° 30’ 0.00’’ N
12+
'x_0': 2500000,
13+
'y_0': 0}
14+
15+
prj = Proj(lambert)
16+
17+
# Coordinates for the city of Monterrey, Nuevo León, México
18+
19+
city = {'c_name': 'Monterrey', 'lon': -100.316116, 'lat': 25.686613}
20+
21+
x, y = prj(city['lon'], city['lat'])
22+
23+
print(' X Y')
24+
print(city['c_name'], ': lon:', city['lon'], ' , lat:', city['lat'])
25+
print('Lambert function:', x, ',', y)
26+
print(' Should return: 2668223.843 , 1516271.922')
27+
28+
# Should return:
29+
30+
"""
31+
X Y
32+
Monterrey : lon: -100.316116 , lat: 25.686613
33+
Lambert function: 2668223.842598227 , 1516271.9216458194
34+
Should return: 2668223.843 , 1516271.922
35+
"""

Diff for: Longitude Latitude conical converter/readme.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Longitude and Latitude to Conical Converter
2+
3+
This script converts longitude and latitude to [Lambert conformal conic projection](https://en.wikipedia.org/wiki/Lambert_conformal_conic_projection).
4+
The example used is for Mexico, under International Terrestrial Reference Frame 2008, which uses Lambert Conformal Conic projection 2SP (epsg:9802).
5+
6+
This script is useful to combine census and geographic data, with traditional Longitude and Latitude from the more international frame of reference.
7+
8+
For more reference, see [National Geography institute explanatory PDF](https://www.inegi.org.mx/contenidos/temas/MapaDigital/Doc/asignar_sistema_coordenadas.pdf)
9+
and [Pyproj, Lambert projections](https://proj.org/operations/projections/lcc.html).
10+
11+
## Prerequisites
12+
- Python 3.x installed on your machine.
13+
14+
## Dependencies
15+
The script requires the following Python libraries:
16+
`pyproj`
17+
`shapely`
18+
19+
You can install the required library using pip:
20+
`pip install pyproj`
21+
`pip install shapely`

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ More information on contributing and the general code of conduct for discussion
8888
| Keylogger | [Keylogger](https://github.com/DhanushNehru/Python-Scripts/tree/master/Keylogger) | Keylogger that can track your keystrokes, clipboard text, take screenshots at regular intervals, and records audio. |
8989
| Keyword - Retweeting | [Keyword - Retweeting](https://github.com/DhanushNehru/Python-Scripts/tree/master/Keyword%20Retweet%20Twitter%20Bot) | Find the latest tweets containing given keywords and then retweet them. |
9090
| LinkedIn Bot | [LinkedIn Bot](https://github.com/DhanushNehru/Python-Scripts/tree/master/LinkedIn%20Bot) | Automates the process of searching for public profiles on LinkedIn and exporting the data to an Excel sheet. |
91+
| Longitude & Latitude to conical coverter | [Longitude Latitude conical converter](master/Longitude%20Latitude%20conical%20converter) | Converts Longitude and Latitude to Lambert conformal conic projection. |
9192
| Mail Sender | [Mail Sender](https://github.com/DhanushNehru/Python-Scripts/tree/master/Mail%20Sender) | Sends an email. |
9293
| Merge Two Images | [Merge Two Images](https://github.com/DhanushNehru/Python-Scripts/tree/master/Merge%20Two%20Images) | Merges two images horizontally or vertically. |
9394
| Mouse mover | [Mouse mover](https://github.com/DhanushNehru/Python-Scripts/tree/master/Mouse%20Mover) | Moves your mouse every 15 seconds. |

0 commit comments

Comments
 (0)