get lat lon from Viirs VNP09GA

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
ger.smit
Posts: 4
Joined: Sun Jul 16, 2023 8:31 am America/New_York
Answers: 0

get lat lon from Viirs VNP09GA

by ger.smit » Wed Aug 09, 2023 11:37 am America/New_York

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

Tags:

LP DAAC - dgolon
User Services
User Services
Posts: 296
Joined: Mon Sep 30, 2019 10:00 am America/New_York
Answers: 0
Has thanked: 18 times
Been thanked: 2 times
Contact:

Re: get lat lon from Viirs VNP09GA

by LP DAAC - dgolon » Wed Aug 09, 2023 2:29 pm America/New_York

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.
Subscribe to the LP DAAC listserv by sending a blank email to lpdaac-join@lists.nasa.gov.

Sign up for the Landsat listserv to receive the most up to date information about Landsat data: https://public.govdelivery.com/accounts/USDOIGS/subscriber/new#tab1.

LP DAAC - afriesz
Subject Matter Expert
Subject Matter Expert
Posts: 59
Joined: Tue Nov 12, 2019 4:02 pm America/New_York
Answers: 2
Been thanked: 2 times

Re: get lat lon from Viirs VNP09GA

by LP DAAC - afriesz » Tue Aug 15, 2023 9:54 am America/New_York

@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.

ger.smit
Posts: 4
Joined: Sun Jul 16, 2023 8:31 am America/New_York
Answers: 0

Re: get lat lon from Viirs VNP09GA

by ger.smit » Tue Aug 15, 2023 11:15 am America/New_York

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

LP DAAC - afriesz
Subject Matter Expert
Subject Matter Expert
Posts: 59
Joined: Tue Nov 12, 2019 4:02 pm America/New_York
Answers: 2
Been thanked: 2 times

Re: get lat lon from Viirs VNP09GA

by LP DAAC - afriesz » Fri Sep 01, 2023 9:15 am America/New_York

@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?

ger.smit
Posts: 4
Joined: Sun Jul 16, 2023 8:31 am America/New_York
Answers: 0

Re: get lat lon from Viirs VNP09GA

by ger.smit » Sat Sep 09, 2023 5:41 am America/New_York

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.

LP DAAC - jwilson
User Services
User Services
Posts: 279
Joined: Mon Sep 30, 2019 12:39 pm America/New_York
Answers: 1
Has thanked: 9 times

Re: get lat lon from Viirs VNP09GA

by LP DAAC - jwilson » Wed Sep 20, 2023 9:58 am America/New_York

@ger.smit Thank you for your message. After further review, our science team has no further recommendations.
LP DAAC User Services

Post Reply