Convert lantitude/longitide to pixel in geotif - gdal

I have two different geotiff files, one for Spain and the other for the Europe.
I selected an area in the geotiff of Spain. What I have to do is to find its correspondence in the geotiff of Europe.
I changed geotiff into numy array. I would like to know given the pixel x_min, y_min, x_max, y_max in the array of data from Spain, how can i find the correspondent x_min, y_min, x_max, y_max of the same area in the array of Europe. I know gdal.GetGeoTranform() can be used to do this, but how?
Thanks

Related

How to compute the lat/lon from EPSG land cover system?

I have a polygon in land cover with 4 coordinates (north-south, east-west) and I would like to compute the latitude and longitude.
For example, Bounding Box: West = -10.61982, East = 44.82124, North = 71.18545, South = 34.56192
Does anybody know the basic steps?
It seems that is the inverse of the following problem:
How to translate a given coordinate into a bounding box of "diameter" x?
Thank you!

Selecting time dimension for a given latitude and longitude from an Xarray dataset

I am looking for suggestion on the fastest way to select a time-series for a given latitude and longitude from an xarray dataset. xarray dataset that I am working with is 3 dimensional of the shape [400, 2000, 7200] where the first dimension is time (400), then latitude (2000) and longitude (7200). I simply need to read in individual time-series for each of the grid cells in a given rectangle. So I am reading in time-series one by one for each grid cell with the given rectangle.
For this selection I am using .sel option.
XR..sel(latitude=Y, longitude=X)
Where XR is a xarray dataset, and Y and X are the given latitude and longitude.
This works well but turns about to be very slow when repeated several times. Is there a faster option to do this?
Thank you for your help!

How to adjust Pixel Spacing and Slice Thickness in DICOM data?

I have a large dicom mri dataset for several patients. For each patient, there is a folder including many 2d slices of .dcm files and the data of each patient has different sizes. For example:
patient1: PixelSpacing=0.8mm,0.8mm, SliceThickness=2mm, SpacingBetweenSlices=1mm, 400x400 pixels
patient2: PixelSpacing=0.625mm,0.625mm, SliceThickness=2.4mm, SpacingBetweenSlices=1mm, 512x512 pixels
So my question is how can I convert all of them into {Pixel Spacing} = 1mm,1mm and {Slice Thickness = 1mm}?
Thanks.
These are two different questions:
About harmonizing positions and pixel spacing, these links will be helpful:
Finding the coordinates (mm) of identical slice locations for two MR datasets acquired in the same scanning session
Interpolation between two images with different pixelsize
http://nipy.org/nibabel/dicom/dicom_orientation.html
Basically, you want to build your target volume and interpolate each of its pixels from the nearest neighbors in the source volumes.
About modifying the slice thickness: If you really want to modify the slice thickness rather than the slice distance, I do not see any chance to do this correctly with the source data you have. This is because the thickness says which width of the raw data was used to calculate the values for a slice in your stack (e.g. by averaging or calculating an integral). With a slice thickness of 2 or 2.4mm in the source volumes, you will not be able to reconstruct the gray values with a thickness of 1 mm. If your question was referring to slice distance rather than slice thickness, answer 1 applies.

Determining the Longitudes and Latitudes from raw NMEA of unknown format

I have a data set that has location data of an animal. The data set has very large number of records. I expect to extract latitude and longitude data from the data set that was provided. It might be important to state that these coordinates correspond to locations in Sri Lanka. I found that longitudes in Sri Lanka range from 79.81-81.81 where latitudes range from 9.77-5.94.
X,Y,Date,Time
540564.950532,697307.393351,24.07.2012,1:30:19
541154.889569,697570.313356,24.07.2012,5:30:48
421860.001784,869773.695226,25.06.2008,20:01
513559.094669,681860.728185,2006.08.19,4:00:36
A real raw data sample can be found from [here][1]
Unfortunately, I am not in a position to ask the sender of the DMS format of x,y coordinates.
What I am after is a mechanism to convert x,y into decimal degree format. The challenge here is that it is unknown the format of the x,y string. it can be DDMMMM.SSSSSS or anything.

lat lon coordinates (WGS84) conversion to local x, y plane

Currently I'm trying the following: I have points from google earth (WGS84) which I want to transform to a local x,y coordinate system: a tangential plane with y positive from south to north and x positive from west to east.
There is no need for the plane to be part of a global coordinate system more than the relation (x=0, y=0) = (lat,lon). The scale at which I'm working is in the order of say 100 kilometers (maximum of for example 200 km's). Very small errors (due to for example the curvature of the earth) are acceptable.
I have relatively little understanding of this topic as of yet. Can anybody help me out? Where would I need to look for example.
Thanks!
I haven't found the answer mathematically but have found that the package basemap (of the mpl_toolkit) should help with this respect (from wgs84 to a transverse mercator projection).