2

I am trying to query data from a GeoTIFF file by latitude and longitude. I have a dataset that has ~1 million data points in the U.S., and for each point, I need to query the CDL data by lat/lon programmatically in python.

I tried converting the GeoTIFF file into XYZ in QGIS, however, it was taking an extremely long time and failed.

After researching, it looks like GDAL might be an option. However, I am still unsure how to go about this.

I'm looking for the fastest way to query a large amount of data from the GeoTIFF file by lat/lon.

I am a complete beginner.

5
  • What programming language will you be using? Do you actually need to export the entire raster to xyz, or do you just need to be able to query it by lon, lat?
    – user2856
    Commented Jul 3, 2022 at 2:46
  • I don't think this question is offtopic. The OP is asking what gdal command line tools might help and how to use them. gis.stackexchange.com/questions/270148/what-are-gdal-utilities might help. Note that querying a GeoTIFF from the command line one point at a time will be slow. By CDL, do you mean soil data? Commented Jul 3, 2022 at 12:37
  • @user2856 I'm looking to query it by lon, lat. Also, I completely forgot to mention the language, I would like to use python - sorry!
    – Akhila Ram
    Commented Jul 3, 2022 at 13:55
  • @barrycarter Thank you for the link. CDL stands for Cropland Data Layer (dataset linked).
    – Akhila Ram
    Commented Jul 3, 2022 at 13:58
  • 1
    Suggest you look at rasterio, specifically rasterio.open then opened_dataset.sample([lon, lat], [another_lon, another_lat],... [more_lon, more_lat]])
    – user2856
    Commented Jul 3, 2022 at 21:25

0