0

I'm new to Python and I have a data set which contains longitude and latitude coordinates(WGS84) points, and a .img raster file of CONUS in meters and with the projection of Albers Conical Equal Area.

What I'm trying to do is to display the points on the image and get the raster value of those points. The metadata of the image contains the projection information, including projection parameters and bounding coordinates(longitude and latitude). But I don't really understand the projection, and how can I connect the lat_lon points with the image in meters with projection? Is there any pkg which can be useful in python?

I've searched related questions, here is an example which would like to convert lat_lon to xy on Mercator projection in Java, I'm not sure if this can be used in Python, too.

0

I've got the answer to the question, the solution is to use pyproj. To convert the lat_lon to a xy coordinate, we should get the proj4 string of two projections, which can be searched in spatial reference.

And part of my code is as follows:

## -----Define inProj & outProj-----
import pyproj
# WGS84
inProj = pyproj.Proj("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
# SR-ORG:8363
outProj = pyproj.Proj("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs")
# Reference List:http://spatialreference.org/ref/sr-org/8363/

## Test
lon1,lat1 = [-130.232828,52.877264]
x1,y1 = pyproj.transform(inProj,outProj,lon1,lat1)
print(x1,y1)

[output] -2333039.9159161123 3734811.9184863623

This works for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.