Converting large data with lat and long into X and Y?Off by about 85 meters when converting NAD27 UTM to WGS84 lat/lonConvert some UTM coordinates to Lat LongConvert shapefile to LonLat (R)Splitting and converting a large tif files into multiple .hgt filesConverting SHP UTM to decimal lat/long
What explains the Genie's fate?
Friend is very nitpicky about side comments I don't intend to be taken too seriously
The pirate treasure of Leatherback Atoll
Is there a way to deal with desistance in a off-chain game?
What exactly is Apple Cider
Write a Schrödinger's sentence
Python implementation of atoi
How do you say "to hell with everything" in French?
Galilean transformation vs simple translation
What precisely does the commonly reported network hash rate refer to?
Quick Shikaku Puzzle: Stars and Stripes
How does a changeling's Divergent Persona affect bard spells cast using musical instruments?
How would two worlds first establish an exchange rate between their currencies
Why can't some airports handle heavy aircraft while others do it easily (same runway length)?
Is future tense in English really a myth?
Is there any control character or hack to prevent simple command line tools from showing subsequent data?
What happens when a file that is 100% paged in to the page cache gets modified by another process
Is there a "right" way to interpret a novel, if not, how do we make sure our novel is interpreted correctly?
What is this sticking out of my wall?
Problem with listing a directory to grep
Why did Tony's Arc Reactor do this?
The Green Glass Door, Revisited
Does the word voltage exist in academic engineering?
I multiply the source, you (probably) multiply the output!
Converting large data with lat and long into X and Y?
Off by about 85 meters when converting NAD27 UTM to WGS84 lat/lonConvert some UTM coordinates to Lat LongConvert shapefile to LonLat (R)Splitting and converting a large tif files into multiple .hgt filesConverting SHP UTM to decimal lat/long
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have 9888562 records in dataframe and I would like to convert my lat, long to UTM x,y. according to my code, I have used pyproj package but because my data are too much it takes a long time and finally, it doesn't work.
I wonder whether you know another way or package that I can use for my data?
def rule(row):
p = Proj(proj='utm',zone=10,ellps='WGS84', preserve_units=False)
x,y = p(row["LON"], row["LAT"])
return pd.Series("X": x , "Y": y)
My_data = My_data.merge(My_data.apply(rule, axis=1), left_index= True, right_index= True)
python convert latitude-longitude utm pyproj
New contributor
user149052 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I have 9888562 records in dataframe and I would like to convert my lat, long to UTM x,y. according to my code, I have used pyproj package but because my data are too much it takes a long time and finally, it doesn't work.
I wonder whether you know another way or package that I can use for my data?
def rule(row):
p = Proj(proj='utm',zone=10,ellps='WGS84', preserve_units=False)
x,y = p(row["LON"], row["LAT"])
return pd.Series("X": x , "Y": y)
My_data = My_data.merge(My_data.apply(rule, axis=1), left_index= True, right_index= True)
python convert latitude-longitude utm pyproj
New contributor
user149052 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
what do you mean it doesn't work? can you give a pair of input points and output returned?
– Ian Turton♦
4 hours ago
Yes. I have tried my code for several rows and it works but when I try my code for large data(9888562 rows) it takes along time. I waited for 8 hours but it was running and I interrupted it.
– user149052
4 hours ago
add a comment |
I have 9888562 records in dataframe and I would like to convert my lat, long to UTM x,y. according to my code, I have used pyproj package but because my data are too much it takes a long time and finally, it doesn't work.
I wonder whether you know another way or package that I can use for my data?
def rule(row):
p = Proj(proj='utm',zone=10,ellps='WGS84', preserve_units=False)
x,y = p(row["LON"], row["LAT"])
return pd.Series("X": x , "Y": y)
My_data = My_data.merge(My_data.apply(rule, axis=1), left_index= True, right_index= True)
python convert latitude-longitude utm pyproj
New contributor
user149052 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I have 9888562 records in dataframe and I would like to convert my lat, long to UTM x,y. according to my code, I have used pyproj package but because my data are too much it takes a long time and finally, it doesn't work.
I wonder whether you know another way or package that I can use for my data?
def rule(row):
p = Proj(proj='utm',zone=10,ellps='WGS84', preserve_units=False)
x,y = p(row["LON"], row["LAT"])
return pd.Series("X": x , "Y": y)
My_data = My_data.merge(My_data.apply(rule, axis=1), left_index= True, right_index= True)
python convert latitude-longitude utm pyproj
python convert latitude-longitude utm pyproj
New contributor
user149052 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user149052 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 5 hours ago


TomazicM
3,6384 gold badges9 silver badges23 bronze badges
3,6384 gold badges9 silver badges23 bronze badges
New contributor
user149052 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 8 hours ago
user149052user149052
61 bronze badge
61 bronze badge
New contributor
user149052 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user149052 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
what do you mean it doesn't work? can you give a pair of input points and output returned?
– Ian Turton♦
4 hours ago
Yes. I have tried my code for several rows and it works but when I try my code for large data(9888562 rows) it takes along time. I waited for 8 hours but it was running and I interrupted it.
– user149052
4 hours ago
add a comment |
what do you mean it doesn't work? can you give a pair of input points and output returned?
– Ian Turton♦
4 hours ago
Yes. I have tried my code for several rows and it works but when I try my code for large data(9888562 rows) it takes along time. I waited for 8 hours but it was running and I interrupted it.
– user149052
4 hours ago
what do you mean it doesn't work? can you give a pair of input points and output returned?
– Ian Turton♦
4 hours ago
what do you mean it doesn't work? can you give a pair of input points and output returned?
– Ian Turton♦
4 hours ago
Yes. I have tried my code for several rows and it works but when I try my code for large data(9888562 rows) it takes along time. I waited for 8 hours but it was running and I interrupted it.
– user149052
4 hours ago
Yes. I have tried my code for several rows and it works but when I try my code for large data(9888562 rows) it takes along time. I waited for 8 hours but it was running and I interrupted it.
– user149052
4 hours ago
add a comment |
1 Answer
1
active
oldest
votes
You can directly use shapely or GeoPandas but with 9888562 records It will take a long time to do (if you want a Progress bar during the pandas operations, you can use tqdm)
1) With your solution and the first 4 points
import pandas as pd
df = pd.DataFrame('LAT':[47.9767,47.9803,47.9801,47.9798], 'LON':[-122.2450,-122.2458,-122.2472,-122.2465])
My_data = df.merge(df.apply(rule, axis=1), left_index= True, right_index= True)
print(My_data)
LAT LON X Y
0 47.9767 -122.2450 556344.793287 5.313986e+06
1 47.9803 -122.2458 556281.177583 5.314386e+06
2 47.9801 -122.2472 556176.922041 5.314363e+06
3 47.9798 -122.2465 556229.484294 5.314330e+06
2) With shapely
from shapely.geometry import Point
df['geometry'] = df.apply(lambda row: Point(row.LON, row.LAT), axis=1)
print(df)
LAT LON geometry
0 47.9767 -122.2450 POINT (-122.245 47.9767)
1 47.9803 -122.2458 POINT (-122.2458 47.9803)
2 47.9801 -122.2472 POINT (-122.2472 47.9801)
3 47.9798 -122.2465 POINT (-122.2465 47.9798)
# change the projection of points
from functools import partial
from shapely.ops import transform
import pyproj
project = partial(
pyproj.transform,
pyproj.Proj(init='epsg:4326'), # source coordinate system
pyproj.Proj('+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')) # destination coordinate system
sdf = df.copy()
sdf['project'] = sdf.geometry.apply(lambda row: transform(project,row))
print(sdf)
LAT LON geometry project
0 47.9767 -122.2450 POINT (-122.245 47.9767) POINT (556344.7932874847 5313986.318933257)
1 47.9803 -122.2458 POINT (-122.2458 47.9803) POINT (556281.1775833125 5314385.854768319)
2 47.9801 -122.2472 POINT (-122.2472 47.9801) POINT (556176.9220411006 5314362.605105238)
3 47.9798 -122.2465 POINT (-122.2465 47.9798) POINT (556229.4842943319 5314329.77191091)
3) Directly with GeoPandas
import geopandas as gpd
# change to GeoDataFrame
geodf = gpd.GeoDataFrame(df)
geodf.crs= 'init': 'epsg:4326'
# change the projection of geodf
geodf = geodf.to_crs("+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_def")
print(geodf)
LAT LON geometry
0 47.9767 -122.2450 POINT (556344.7932874847 5313986.318933257)
1 47.9803 -122.2458 POINT (556281.1775833125 5314385.854768319)
2 47.9801 -122.2472 POINT (556176.9220411006 5314362.605105238)
3 47.9798 -122.2465 POINT (556229.4842943319 5314329.77191091)
4) If you want the X and Y values, it is easy
geodf["x"] = geodf.geometry.apply(lambda row:row.x)
geodf["y"] = geodf.geometry.apply(lambda row:row.y)
print(geodf)
LAT LON geometry x y
0 47.9767 -122.2450 POINT (556344.7932874847 5313986.318933257) 556344.793287 5.313986e+06
1 47.9803 -122.2458 POINT (556281.1775833125 5314385.854768319) 556281.177583 5.314386e+06
2 47.9801 -122.2472 POINT (556176.9220411006 5314362.605105238) 556176.922041 5.314363e+06
3 47.9798 -122.2465 POINT (556229.4842943319 5314329.77191091) 556229.484294 5.314330e+06
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
user149052 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f334271%2fconverting-large-data-with-lat-and-long-into-x-and-y%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can directly use shapely or GeoPandas but with 9888562 records It will take a long time to do (if you want a Progress bar during the pandas operations, you can use tqdm)
1) With your solution and the first 4 points
import pandas as pd
df = pd.DataFrame('LAT':[47.9767,47.9803,47.9801,47.9798], 'LON':[-122.2450,-122.2458,-122.2472,-122.2465])
My_data = df.merge(df.apply(rule, axis=1), left_index= True, right_index= True)
print(My_data)
LAT LON X Y
0 47.9767 -122.2450 556344.793287 5.313986e+06
1 47.9803 -122.2458 556281.177583 5.314386e+06
2 47.9801 -122.2472 556176.922041 5.314363e+06
3 47.9798 -122.2465 556229.484294 5.314330e+06
2) With shapely
from shapely.geometry import Point
df['geometry'] = df.apply(lambda row: Point(row.LON, row.LAT), axis=1)
print(df)
LAT LON geometry
0 47.9767 -122.2450 POINT (-122.245 47.9767)
1 47.9803 -122.2458 POINT (-122.2458 47.9803)
2 47.9801 -122.2472 POINT (-122.2472 47.9801)
3 47.9798 -122.2465 POINT (-122.2465 47.9798)
# change the projection of points
from functools import partial
from shapely.ops import transform
import pyproj
project = partial(
pyproj.transform,
pyproj.Proj(init='epsg:4326'), # source coordinate system
pyproj.Proj('+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')) # destination coordinate system
sdf = df.copy()
sdf['project'] = sdf.geometry.apply(lambda row: transform(project,row))
print(sdf)
LAT LON geometry project
0 47.9767 -122.2450 POINT (-122.245 47.9767) POINT (556344.7932874847 5313986.318933257)
1 47.9803 -122.2458 POINT (-122.2458 47.9803) POINT (556281.1775833125 5314385.854768319)
2 47.9801 -122.2472 POINT (-122.2472 47.9801) POINT (556176.9220411006 5314362.605105238)
3 47.9798 -122.2465 POINT (-122.2465 47.9798) POINT (556229.4842943319 5314329.77191091)
3) Directly with GeoPandas
import geopandas as gpd
# change to GeoDataFrame
geodf = gpd.GeoDataFrame(df)
geodf.crs= 'init': 'epsg:4326'
# change the projection of geodf
geodf = geodf.to_crs("+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_def")
print(geodf)
LAT LON geometry
0 47.9767 -122.2450 POINT (556344.7932874847 5313986.318933257)
1 47.9803 -122.2458 POINT (556281.1775833125 5314385.854768319)
2 47.9801 -122.2472 POINT (556176.9220411006 5314362.605105238)
3 47.9798 -122.2465 POINT (556229.4842943319 5314329.77191091)
4) If you want the X and Y values, it is easy
geodf["x"] = geodf.geometry.apply(lambda row:row.x)
geodf["y"] = geodf.geometry.apply(lambda row:row.y)
print(geodf)
LAT LON geometry x y
0 47.9767 -122.2450 POINT (556344.7932874847 5313986.318933257) 556344.793287 5.313986e+06
1 47.9803 -122.2458 POINT (556281.1775833125 5314385.854768319) 556281.177583 5.314386e+06
2 47.9801 -122.2472 POINT (556176.9220411006 5314362.605105238) 556176.922041 5.314363e+06
3 47.9798 -122.2465 POINT (556229.4842943319 5314329.77191091) 556229.484294 5.314330e+06
add a comment |
You can directly use shapely or GeoPandas but with 9888562 records It will take a long time to do (if you want a Progress bar during the pandas operations, you can use tqdm)
1) With your solution and the first 4 points
import pandas as pd
df = pd.DataFrame('LAT':[47.9767,47.9803,47.9801,47.9798], 'LON':[-122.2450,-122.2458,-122.2472,-122.2465])
My_data = df.merge(df.apply(rule, axis=1), left_index= True, right_index= True)
print(My_data)
LAT LON X Y
0 47.9767 -122.2450 556344.793287 5.313986e+06
1 47.9803 -122.2458 556281.177583 5.314386e+06
2 47.9801 -122.2472 556176.922041 5.314363e+06
3 47.9798 -122.2465 556229.484294 5.314330e+06
2) With shapely
from shapely.geometry import Point
df['geometry'] = df.apply(lambda row: Point(row.LON, row.LAT), axis=1)
print(df)
LAT LON geometry
0 47.9767 -122.2450 POINT (-122.245 47.9767)
1 47.9803 -122.2458 POINT (-122.2458 47.9803)
2 47.9801 -122.2472 POINT (-122.2472 47.9801)
3 47.9798 -122.2465 POINT (-122.2465 47.9798)
# change the projection of points
from functools import partial
from shapely.ops import transform
import pyproj
project = partial(
pyproj.transform,
pyproj.Proj(init='epsg:4326'), # source coordinate system
pyproj.Proj('+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')) # destination coordinate system
sdf = df.copy()
sdf['project'] = sdf.geometry.apply(lambda row: transform(project,row))
print(sdf)
LAT LON geometry project
0 47.9767 -122.2450 POINT (-122.245 47.9767) POINT (556344.7932874847 5313986.318933257)
1 47.9803 -122.2458 POINT (-122.2458 47.9803) POINT (556281.1775833125 5314385.854768319)
2 47.9801 -122.2472 POINT (-122.2472 47.9801) POINT (556176.9220411006 5314362.605105238)
3 47.9798 -122.2465 POINT (-122.2465 47.9798) POINT (556229.4842943319 5314329.77191091)
3) Directly with GeoPandas
import geopandas as gpd
# change to GeoDataFrame
geodf = gpd.GeoDataFrame(df)
geodf.crs= 'init': 'epsg:4326'
# change the projection of geodf
geodf = geodf.to_crs("+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_def")
print(geodf)
LAT LON geometry
0 47.9767 -122.2450 POINT (556344.7932874847 5313986.318933257)
1 47.9803 -122.2458 POINT (556281.1775833125 5314385.854768319)
2 47.9801 -122.2472 POINT (556176.9220411006 5314362.605105238)
3 47.9798 -122.2465 POINT (556229.4842943319 5314329.77191091)
4) If you want the X and Y values, it is easy
geodf["x"] = geodf.geometry.apply(lambda row:row.x)
geodf["y"] = geodf.geometry.apply(lambda row:row.y)
print(geodf)
LAT LON geometry x y
0 47.9767 -122.2450 POINT (556344.7932874847 5313986.318933257) 556344.793287 5.313986e+06
1 47.9803 -122.2458 POINT (556281.1775833125 5314385.854768319) 556281.177583 5.314386e+06
2 47.9801 -122.2472 POINT (556176.9220411006 5314362.605105238) 556176.922041 5.314363e+06
3 47.9798 -122.2465 POINT (556229.4842943319 5314329.77191091) 556229.484294 5.314330e+06
add a comment |
You can directly use shapely or GeoPandas but with 9888562 records It will take a long time to do (if you want a Progress bar during the pandas operations, you can use tqdm)
1) With your solution and the first 4 points
import pandas as pd
df = pd.DataFrame('LAT':[47.9767,47.9803,47.9801,47.9798], 'LON':[-122.2450,-122.2458,-122.2472,-122.2465])
My_data = df.merge(df.apply(rule, axis=1), left_index= True, right_index= True)
print(My_data)
LAT LON X Y
0 47.9767 -122.2450 556344.793287 5.313986e+06
1 47.9803 -122.2458 556281.177583 5.314386e+06
2 47.9801 -122.2472 556176.922041 5.314363e+06
3 47.9798 -122.2465 556229.484294 5.314330e+06
2) With shapely
from shapely.geometry import Point
df['geometry'] = df.apply(lambda row: Point(row.LON, row.LAT), axis=1)
print(df)
LAT LON geometry
0 47.9767 -122.2450 POINT (-122.245 47.9767)
1 47.9803 -122.2458 POINT (-122.2458 47.9803)
2 47.9801 -122.2472 POINT (-122.2472 47.9801)
3 47.9798 -122.2465 POINT (-122.2465 47.9798)
# change the projection of points
from functools import partial
from shapely.ops import transform
import pyproj
project = partial(
pyproj.transform,
pyproj.Proj(init='epsg:4326'), # source coordinate system
pyproj.Proj('+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')) # destination coordinate system
sdf = df.copy()
sdf['project'] = sdf.geometry.apply(lambda row: transform(project,row))
print(sdf)
LAT LON geometry project
0 47.9767 -122.2450 POINT (-122.245 47.9767) POINT (556344.7932874847 5313986.318933257)
1 47.9803 -122.2458 POINT (-122.2458 47.9803) POINT (556281.1775833125 5314385.854768319)
2 47.9801 -122.2472 POINT (-122.2472 47.9801) POINT (556176.9220411006 5314362.605105238)
3 47.9798 -122.2465 POINT (-122.2465 47.9798) POINT (556229.4842943319 5314329.77191091)
3) Directly with GeoPandas
import geopandas as gpd
# change to GeoDataFrame
geodf = gpd.GeoDataFrame(df)
geodf.crs= 'init': 'epsg:4326'
# change the projection of geodf
geodf = geodf.to_crs("+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_def")
print(geodf)
LAT LON geometry
0 47.9767 -122.2450 POINT (556344.7932874847 5313986.318933257)
1 47.9803 -122.2458 POINT (556281.1775833125 5314385.854768319)
2 47.9801 -122.2472 POINT (556176.9220411006 5314362.605105238)
3 47.9798 -122.2465 POINT (556229.4842943319 5314329.77191091)
4) If you want the X and Y values, it is easy
geodf["x"] = geodf.geometry.apply(lambda row:row.x)
geodf["y"] = geodf.geometry.apply(lambda row:row.y)
print(geodf)
LAT LON geometry x y
0 47.9767 -122.2450 POINT (556344.7932874847 5313986.318933257) 556344.793287 5.313986e+06
1 47.9803 -122.2458 POINT (556281.1775833125 5314385.854768319) 556281.177583 5.314386e+06
2 47.9801 -122.2472 POINT (556176.9220411006 5314362.605105238) 556176.922041 5.314363e+06
3 47.9798 -122.2465 POINT (556229.4842943319 5314329.77191091) 556229.484294 5.314330e+06
You can directly use shapely or GeoPandas but with 9888562 records It will take a long time to do (if you want a Progress bar during the pandas operations, you can use tqdm)
1) With your solution and the first 4 points
import pandas as pd
df = pd.DataFrame('LAT':[47.9767,47.9803,47.9801,47.9798], 'LON':[-122.2450,-122.2458,-122.2472,-122.2465])
My_data = df.merge(df.apply(rule, axis=1), left_index= True, right_index= True)
print(My_data)
LAT LON X Y
0 47.9767 -122.2450 556344.793287 5.313986e+06
1 47.9803 -122.2458 556281.177583 5.314386e+06
2 47.9801 -122.2472 556176.922041 5.314363e+06
3 47.9798 -122.2465 556229.484294 5.314330e+06
2) With shapely
from shapely.geometry import Point
df['geometry'] = df.apply(lambda row: Point(row.LON, row.LAT), axis=1)
print(df)
LAT LON geometry
0 47.9767 -122.2450 POINT (-122.245 47.9767)
1 47.9803 -122.2458 POINT (-122.2458 47.9803)
2 47.9801 -122.2472 POINT (-122.2472 47.9801)
3 47.9798 -122.2465 POINT (-122.2465 47.9798)
# change the projection of points
from functools import partial
from shapely.ops import transform
import pyproj
project = partial(
pyproj.transform,
pyproj.Proj(init='epsg:4326'), # source coordinate system
pyproj.Proj('+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')) # destination coordinate system
sdf = df.copy()
sdf['project'] = sdf.geometry.apply(lambda row: transform(project,row))
print(sdf)
LAT LON geometry project
0 47.9767 -122.2450 POINT (-122.245 47.9767) POINT (556344.7932874847 5313986.318933257)
1 47.9803 -122.2458 POINT (-122.2458 47.9803) POINT (556281.1775833125 5314385.854768319)
2 47.9801 -122.2472 POINT (-122.2472 47.9801) POINT (556176.9220411006 5314362.605105238)
3 47.9798 -122.2465 POINT (-122.2465 47.9798) POINT (556229.4842943319 5314329.77191091)
3) Directly with GeoPandas
import geopandas as gpd
# change to GeoDataFrame
geodf = gpd.GeoDataFrame(df)
geodf.crs= 'init': 'epsg:4326'
# change the projection of geodf
geodf = geodf.to_crs("+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_def")
print(geodf)
LAT LON geometry
0 47.9767 -122.2450 POINT (556344.7932874847 5313986.318933257)
1 47.9803 -122.2458 POINT (556281.1775833125 5314385.854768319)
2 47.9801 -122.2472 POINT (556176.9220411006 5314362.605105238)
3 47.9798 -122.2465 POINT (556229.4842943319 5314329.77191091)
4) If you want the X and Y values, it is easy
geodf["x"] = geodf.geometry.apply(lambda row:row.x)
geodf["y"] = geodf.geometry.apply(lambda row:row.y)
print(geodf)
LAT LON geometry x y
0 47.9767 -122.2450 POINT (556344.7932874847 5313986.318933257) 556344.793287 5.313986e+06
1 47.9803 -122.2458 POINT (556281.1775833125 5314385.854768319) 556281.177583 5.314386e+06
2 47.9801 -122.2472 POINT (556176.9220411006 5314362.605105238) 556176.922041 5.314363e+06
3 47.9798 -122.2465 POINT (556229.4842943319 5314329.77191091) 556229.484294 5.314330e+06
edited 2 hours ago
answered 4 hours ago
genegene
39.3k1 gold badge60 silver badges127 bronze badges
39.3k1 gold badge60 silver badges127 bronze badges
add a comment |
add a comment |
user149052 is a new contributor. Be nice, and check out our Code of Conduct.
user149052 is a new contributor. Be nice, and check out our Code of Conduct.
user149052 is a new contributor. Be nice, and check out our Code of Conduct.
user149052 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f334271%2fconverting-large-data-with-lat-and-long-into-x-and-y%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
what do you mean it doesn't work? can you give a pair of input points and output returned?
– Ian Turton♦
4 hours ago
Yes. I have tried my code for several rows and it works but when I try my code for large data(9888562 rows) it takes along time. I waited for 8 hours but it was running and I interrupted it.
– user149052
4 hours ago