[PYTHON] How to get the pixel value of the point from the satellite image by specifying the latitude and longitude

background

I am doing research to find chlorophyll values from satellite images using neural network regression. For that purpose, first, as data acquisition and preprocessing, I would like to write about how to specify the latitude and longitude from satellite image data and acquire the pixel value at that point. Before that, what is a satellite image? ↓ Basics of satellite data

Satellite image data to be used

Use the Landsat 8 image. It is published as open data on AWS. AWS Landsat Data Landsat image data published on AWS can be searched by location by specifying path and row. By the way, since we will use the data of Lake Biwa this time, we searched for the data of path 110 row 35 and obtained it. The above page has a complete list of available scenes, so I sorted them by path and row to get them.

Click here for how to check path and row ↓ path/row coverter

Library to use

Use ** rasterio ** and ** pyproj **. ** rasterio ** is a library for handling raster data. rasterio ** pyproj ** is a library that transforms the coordinate system. pyproj The Landsat data is in Geotif file format, and the coordinate data is embedded as a tag, but since it uses UTM coordinates, it needs to be converted from latitude / longitude to the UTM coordinate system.

import rasterio as rio import pyproj ↑ Please install it with pip etc. in advance.

Load Geotif with rasterio

B5 = rio.open ('file path')

Coordinate system conversion

utm = pyproj.Proj(B5.crs) lonlat = pyproj.Proj(init='epsg:4326') lat,lon = (35.445,136.0638888889) east,north = pyproj.transform(lonlat,utm,lon,lat)

Verify that the latitude and longitude have been converted to the UTM coordinate system.

east,north (596554.9414823324, 3922913.584464462)

Get the row and column of the image at that point from the coordinates

The data is of type array, and you can get the row and column corresponding to the coordinates with the index method. row, col = B5.index(east,north)

print(f'row,col=({row},{col})') row,col=(6086,5625)

Also, the following code is required to access the pixel values of the array data. B5read = B5.read(1) This 1 is the index of the band of the satellite image, but this time there is only one band 5, so specify 1.

Get pixel value

B5read[row,col]

21530

Summary

That's all, now you can easily find the pixel value of the specified point from latitude and longitude. However, this pixel value is called the DN value, which is influenced by the intensity and angle of the sun's light, and is a reflection called TOA to be used for inputting a neural network that uses the chlorophyll value as an output. I'm thinking of converting it to a rate. I'd really like to find pure SR (Surface Reflectance) for atmospheric correction, but it's difficult, so I'll give up this time and introduce how to find TOA next time. ** Click here for satellite image processing level ↓ ** Illustration! What is satellite data preprocessing

Thank you for reading to the end!

Recommended Posts

How to get the pixel value of the point from the satellite image by specifying the latitude and longitude
Get the address from latitude and longitude
Give latitude and longitude point sequence data and try to identify the road from OpenStreetMap data
How to get and set the NTP server name by DHCP
How to get followers and followers from python using the Mastodon API
[Python] How to get the first and last days of the month
Find the distance from latitude and longitude (considering the roundness of the earth).
Find the waypoint from latitude and longitude (considering the roundness of the earth).
[Python Kivy] How to get the file path by dragging and dropping
Read the graph image with OpenCV and get the coordinates of the final point of the graph
[Django] How to get data by specifying SQL.
Change the decimal point of logging from, to.
How to get the "name" of a field whose value is limited by the choice attribute in Django's model
How to save the feature point information of an image in a file and use it for matching
How to get the number of digits in Python
How to execute a schedule by specifying the Python time zone and execution frequency
[Blender] How to get the selection order of vertices, edges and faces of an object
Get the image of "Suzu Hirose" by Google image search.
[Django 2.2] Sort and get the value of the relation destination
How to check if the contents of the dictionary are the same in Python by hash value
Get the output value of the command (as received by xargs)
How to test the attributes added by add_request_method of pyramid
How to calculate the amount of calculation learned from ABC134-D
Get the value while specifying the default value from dict in Python
Let's guess the development status of the city from the satellite image.
How to get the last (last) value in a list in Python
How to get all the keys and values in the dictionary
How to get a list of links from a page from wikipedia
[Python] How to use the for statement. A method of extracting by specifying a range or conditions.
How to get the ID of Type2Tag NXP NTAG213 with nfcpy
[Python] Try to graph from the image of Ring Fit [OCR]
[EC2] How to install chrome and the contents of each command
[EC2] How to install and download chromedriver from the command line
How to find the memory address of a Pandas dataframe value
How to get the vertex coordinates of a feature in ArcPy
Get and set the value of the dropdown menu using Python and Selenium
I summarized how to change the boot parameters of GRUB and GRUB2
How to get the Python version
Get the value from the [Django] Form
I tried to sort out the objects from the image of the steak set meal-⑤ Similar image feature point detection
From the introduction of GoogleCloudPlatform Natural Language API to how to use it
[Python] How to specify the window display position and size of matplotlib
I tried moving the image to the specified folder by right-clicking and left-clicking
How to crop the lower right part of the image with Python OpenCV
Learning record (4th day) #How to get the absolute path from the relative path
How to get the date and time difference in seconds with python
[Image recognition] How to read the result of automatic annotation with VoTT
I measured 6 methods to get the index of the maximum value (minimum value) of the list
How to get a value from a parameter store in lambda (using python)
[GPS] Use pyproj to calculate distance, azimuth, and elevation from GPS latitude and longitude
How to get a sample report from a hash value using VirusTotal's API
I tried to verify and analyze the acceleration of Python by Cython
__Getattr__ and __getattribute__ to customize the acquisition of object attributes by dots
Get the song name from the title of the video you tried to sing
[python] Send the image captured from the webcam to the server and save it
How to sort by specifying a column in the Python Numpy array.
Internal / external judgment with Python: Obtain the city / town / village name from the latitude / longitude information of any point
How to get rid of long comprehensions
How to check the version of Django
How to get colored output to the console
How to operate Linux from the console