Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone, how can i get the x, y based on longitude and latitude?
Lets say i have geostationary image data ( float* data = new float[ 2750* 2750] ) and i want to extract the some are of my data.

What I have tried:

In order to do this i am using the Proj4 library.
C++
double dCenterLon = 80;
QString strProj = QString( "+proj=geos +h=35785831.0 +lon_0=%1 +a=6400000" ).arg( dCenterLon );

projCtx _ctx = pj_ctx_alloc();
projPJ _projection = = pj_init_plus_ctx( _ctx, qPrintable( strProj ) );

int vLon;            //I have
int vLat;            //I have
int x;             //I have to calculte this
int y;             //I have to calculte this
int nResolution;     //I have
int dColumnOffset;   //I have
int dLineOffset;     //I have

projUV data;
data.u = vLon * DEG_TO_RAD;
data.v = vlat * DEG_TO_RAD;
data = pj_fwd( data, _projection );

x=( data.u / nResolution ) + dColumnOffset + 0.5;
y=( data.v / nResolution * -1 ) + dLineOffset + 0.5;
Posted
Updated 27-Feb-18 15:19pm
v3
Comments
Rick York 23-Feb-18 11:40am    
The row and column in what - a spreadsheet? Your question is far from clear.

I recommend that you read up on mapping projections like Mercator and there are several similar "Related Questions" listed in the column at the right of this page that might be helpful.

1 solution

longitude and latitude are global numbers , to plot your place mark on map
so those can't be converted to X and Y
how can we?

Image is small substance whereas Long / Lat are global number on map (world map)

by the way here are few links about library you are using -
proj.4 — proj.4 4.9.3 documentation[^]

[^]

so link I found simillar to your questions -
Coordinate Conversions[Coordinate Conversions]

Converting Latitude And Longitude to an X Y Coordinates[^]
 
Share this answer
 
Comments
Sukerbek 26-Feb-18 19:14pm    
thank you so much
RDBurmon 27-Feb-18 2:51am    
you can accept and vote the answer
Sukerbek 28-Feb-18 0:12am    
i need to get row, col of my data lets say i have geostationary image data ( float* data = new float[ 2750* 2750] ) and i want to extract the some are of data.
i am using HDF data and i have a library which i can get x,y to lat/lon and lat,lon to x/y based on that library. However when i want to extract some are of my data i need to get x,y to loat/lon as bellow
Sukerbek 28-Feb-18 0:13am    
for( int y = 0; y < extractAreaHeight(); y++ )
{
for( int x= 0; x<extractAreaWidth(); x++ )
{
QPointF posLatLon; QPoint posRowCol;
if( calcLatLon( QPointF( x, y ), posLatLon ) )
{
if( calcRowCol( posLatLon, posRowCol ) )
{
}
}
}
}
I am doing something like this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900