Page 1 of 1

get lat lon from Viirs VNP09GA

Posted: Wed Aug 09, 2023 11:37 am America/New_York
by ger.smit
How can I get with Python the latitude and longitude from the Viirs VNP09GA file to generate coastlines.
Tried many examples without success.
Not technically inclined to calculate myself, so I think there should be a solution using UpperLeftPointMtrs and LowerRightMtrs?
I hope someone can help me out, thank you
Regards Ger

Re: get lat lon from Viirs VNP09GA

Posted: Wed Aug 09, 2023 2:29 pm America/New_York
by LP DAAC - dgolon
Hi @ger.smit I'll talk to our developers and see if they have any ideas and get back to you. In the meantime we'll open this up to the community to see if any other VIIRS users have any suggestions.

Re: get lat lon from Viirs VNP09GA

Posted: Tue Aug 15, 2023 9:54 am America/New_York
by LP DAAC - afriesz
@ger.smit ,

Could you give more details about what you are trying to accomplish? Are you asking how extract pixels based on Lat/Lon or how to extract coastlines from an image (VNP09GA tile)? Also, please pass along any scripts or resources that you've been referencing.

Re: get lat lon from Viirs VNP09GA

Posted: Tue Aug 15, 2023 11:15 am America/New_York
by ger.smit
I enjoy the images as downloaded and edited, the only thing that is wrong is the coastlines and country borders.
I've looked for a basis to find the lath and lon coordinates that the lines need, but I can't, I don't have that knowledge.
I borrowed the script from https://hdfeos.org/zoo/LPDAAC/VNP09GA.A2020305.h30v07.001.2020306101330.h5.py , and am working on getting the correct coordination using a script I found elsewhere.
But as I said, I can't and it is possible that you understand me and can provide a solution.

------- This is what i am doing now but without result -----------------
# Construct the grid. The needed information is in a string dataset
# called 'StructMetadata.0'. Use regular expressions to retrieve
# extents of the grid.
ul_regex = re.compile(r'''UpperLeftPointMtrs=\((?P<upper_left_x>[+-]?\d+\.\d+),(?P<upper_left_y>[+-]?\d+\.\d+)\)''', re.VERBOSE)
match = ul_regex.search(s)
x0 = np.float(match.group('upper_left_x'))
y0 = np.float(match.group('upper_left_y'))
lr_regex = re.compile(r'''LowerRightMtrs=\(
(?P<lower_right_x>[+-]?\d+\.\d+)
,
(?P<lower_right_y>[+-]?\d+\.\d+)
\)''', re.VERBOSE)
match = lr_regex.search(s)
x1 = np.float(match.group('lower_right_x'))
y1 = np.float(match.group('lower_right_y'))
ny, nx = data.shape
x = np.linspace(x0, x1, nx, endpoint=False)
y = np.linspace(y0, y1, ny, endpoint=False)
xv, yv = np.meshgrid(x, y)
lon = xv / 68000.0
lat = yv / 111000.0
print('lon -- lat : ',lon,'-- ',lat)

Thanks in advange and gretings
Ger

Re: get lat lon from Viirs VNP09GA

Posted: Fri Sep 01, 2023 9:15 am America/New_York
by LP DAAC - afriesz
@ger.smit ,

I'm still not quite sure if I'm understanding your objective, but maybe this will help you get started. I've started to update a VIIRS Python resource we have to support VNP09GA version 2 (https://git.earthdata.nasa.gov/projects/LPDUR/repos/nasa_viirs_surfacereflectance/browse/VIIRS_V2_SurfaceReflectance_Tutorial.ipynb?at=refs%2Fheads%2Fv2update). This will walk you through how to work with the VNP09GA file and in Step 7 show you how to grab and set the georeferencing info. Take a look and let me know if you have any questions.

Regarding your comment: "...the only thing that is wrong is the coastlines and country borders." Could you explain a bit more?

Re: get lat lon from Viirs VNP09GA

Posted: Sat Sep 09, 2023 5:41 am America/New_York
by ger.smit
Your colleague eoshelp@hdfgroup.org helped me to create coastlines like in https://hdfeos.org/zoo/LPDAAC/VNP09GA.A2020305.h30v07.001.2020306101330.h5.py .
Is it also possible to create coastlines in the py file you provided https://git.earthdata.nasa.gov/projects/LPDUR/repos/nasa_viirs_surfacereflectance/browse/VIIRS_V2_SurfaceReflectance_Tutorial.ipynb?at=refs%2Fheads%2Fv2update .
This gives an idea if the clouds dominate.

Thanks for an answer and of course thanks for the explanation above.

Re: get lat lon from Viirs VNP09GA

Posted: Wed Sep 20, 2023 9:58 am America/New_York
by LP DAAC - jwilson
@ger.smit Thank you for your message. After further review, our science team has no further recommendations.
LP DAAC User Services