Convert between CSV and GeoTIFF with GDAL in Python

Поделиться
HTML-код
  • Опубликовано: 27 авг 2024

Комментарии • 51

  • @sandeepbhatti3124
    @sandeepbhatti3124 Год назад +1

    Thank you so much! I was looking to convert CSV to Tiff and none of other posts on internet seemed to work. Your tutorial was perfect solution to my use case. Thanks again!

  • @seyedpeyman6092
    @seyedpeyman6092 7 месяцев назад

    Useful and Clear ! Thank You for this Great Tutorial

  • @mountainmanpedro
    @mountainmanpedro 2 года назад +2

    This is such a clear and useful tutorial--thank you for this--extremely helpful.

  • @antonstsezhkin6578
    @antonstsezhkin6578 11 месяцев назад

    Bless you for covering different use cases!
    And thanks than mine is included.

  • @gunnarorsteinsson1170
    @gunnarorsteinsson1170 3 года назад +1

    Omg it worked, thank you! I'd been struggling with solving this particular problem for hours.

  • @johnegyir9704
    @johnegyir9704 9 месяцев назад

    Clearly explained! Thank you very much. This is really helpful.

  • @alejandrocalderon7452
    @alejandrocalderon7452 Год назад +1

    You are amazing! Everything was so clear. Thank you very much!

  • @johnowusukonduah2305
    @johnowusukonduah2305 2 года назад

    Great video. This was what I've been looking for all this while. Thank you Madam.

  • @adeniranibrahim6071
    @adeniranibrahim6071 Год назад

    Nice video. Detailed and explanatory

  • @gulnihalkurt1761
    @gulnihalkurt1761 2 года назад

    amazing tutorials

  • @rodrigo.cedeno
    @rodrigo.cedeno 3 года назад

    Great tutorial! It really helped me a lot! Thank you!

  • @oceancolor1069
    @oceancolor1069 2 года назад

    hot damn ... thank you so much!

  • @elnuisance
    @elnuisance 3 года назад +1

    I only have a csv file with x, y, z(value) data. I am trying to interpolate them by rasterizing using your method. But I am stuck at xRes, yRes

  • @lluisarruevicedo933
    @lluisarruevicedo933 2 года назад

    where are you from? I need to find you to thank you taht you just saved my day! Pd. Don't tell my boss you told me how to do my work hahahahah

  • @brianlee5287
    @brianlee5287 3 года назад +2

    Very great tutorial! Do you have any advice on converting from xy to lat long?

    • @makingsenseremotely6207
      @makingsenseremotely6207  3 года назад +1

      I use geopandas. Here is an example that I have for converting lat/lon into UTM coordinates. You would just have to switch the EPSG codes.
      gdf = df.set_geometry(gpd.points_from_xy(df.longitude, df.latitude), crs="EPSG:4326")
      proj_df = gdf.to_crs("EPSG:32719")
      df["x"] = proj_df.geometry.x
      df["y"] = proj_df.geometry.y

    • @brianlee5287
      @brianlee5287 3 года назад

      @@makingsenseremotely6207 Very useful! I ended up using osr/ogr to transform the spatial reference, but geopandas is much more elegant. Thanks for the channel!

  • @pratikbhattacharjee2025
    @pratikbhattacharjee2025 2 года назад

    I have successfully converted the xyz file to a GeoTif format with no error message. But the output GeoTif file is not there in my directory and the variable is empty too.

  • @johnowusukonduah2305
    @johnowusukonduah2305 2 года назад

    How can we do similar for multiband raster?

  • @MuradEllafi
    @MuradEllafi 2 года назад

    I got this error : ModuleNotFoundError: No module named 'sogeo'
    can you help me please?

  • @saisskumar1502
    @saisskumar1502 3 года назад

    Hi. I am getting the "Null pointer received" error.. what is the fix? I followed the steps as it is.

  • @antonstsezhkin6578
    @antonstsezhkin6578 11 месяцев назад

    Oh! one more thing: you operate with x and y - which one should be latitude and which one the longitude?

    • @ecoro_
      @ecoro_ 7 месяцев назад +1

      x is lon and y is lat, like in a map ... right?

    • @antonstsezhkin6578
      @antonstsezhkin6578 7 месяцев назад

      @@ecoro_ thanks!

  • @liminzhang5516
    @liminzhang5516 2 года назад

    Thank you for your great info. after I run this line code
    dfn = pd.DataFrame({"x":x, "y":y, "value":flat})
    raise ValueError("arrays must all be same length")
    ValueError: arrays must all be same length
    is my DEM.TIF file not right? can you post your DEM.TIF file download link?

  • @heetjoshi1910
    @heetjoshi1910 3 года назад

    I have tried your way to make Geotiff from CSV but the problem is whatever input Lat-Long I have given, when I'm checking my output geotiff's Lat-Long, They both are not same. How is it possible??
    Thank you very much for your tutorial.

  • @mahsabozorgi
    @mahsabozorgi Год назад

    Thank you for the video, How can I conver GeoTIFF to Binary?

  • @asmitasubedi8215
    @asmitasubedi8215 2 года назад

    Thank you for the video! How can I convert a number of .hdf files to csv? Any help would be appreciated.

  • @Theworldfrommyeye.x
    @Theworldfrommyeye.x 3 года назад

    Please make some videos on conversion of .grd file to CSV. It would be great if you can guide me to do so. I am thinking of using python mrgs and gdal public libraries.

  • @anusrutimitra1115
    @anusrutimitra1115 3 года назад +1

    is it possible to make landsat 8 geotiff to csv?

  • @mariafernandamoralesoreamu6019
    @mariafernandamoralesoreamu6019 3 года назад

    Hi! If i want to interpolate to a new cell resolution (size) in the output raster, what do I have to add to the gdal.grid code? For example, I had a 1000x1000 cell resolution, which gave me the xyz coordinate points, and I want the interpolated raster with a new cell resolution of 10x10 m. Thanks!

    • @makingsenseremotely6207
      @makingsenseremotely6207  3 года назад

      Hi. For some reason, there is no gdal.Grid() option to set the x+y resolution of the output raster, only height+width in pixels. The command-line version of that program, however, allows you to specify a target resolution. So you have two options:
      1) run gdal_grid as a subprocess and specify the output file resolution with -tr 10 10
      2) resample the interpolated raster to the desired resolution with gdal.Translate() or gdal.Warp()

    • @mariafernandamoralesoreamu6019
      @mariafernandamoralesoreamu6019 3 года назад

      @@makingsenseremotely6207 Thanks! It works with using gdal_grid as a subprocess. But now I get the error "Failed to find field 'z' on layer file, skipping", so it returns an empty raster. Do you know why this could be? I checked with ogrinfo and the points appear to have a Z value.

    • @makingsenseremotely6207
      @makingsenseremotely6207  3 года назад

      What format does your input data have? If you are using csv + vrt, then make sure that in the vrt file, the value for z under Geometry Field corresponds to the z column name in your csv file. If you are directly using e.g. a shapefile as input, try explicitly setting the z value with the option -zfield "whateveryourfieldnameis"

  • @stergiod5995
    @stergiod5995 3 года назад

    hey, first of all thank you for your videos!! I have a question, what about change jp2 raster (like Sentrinel) to tiff? I am trying to translate all the bands as tiff in a new folder. Thanks anyway.

    • @makingsenseremotely6207
      @makingsenseremotely6207  3 года назад +1

      Hey, if you want to convert each band to a separate new tiff, gdal.Translate("output.tif", "input.jp2") should work. If you want to merge all jp2 files into one multiband tiff raster, build a virtual raster with gdal.BuildVRT() first. Be sure to set separate = True, so each input file will be placed in a separate band. Then you can translate the vrt file to tiff with gdal.Translate().

    • @stergiod5995
      @stergiod5995 3 года назад

      @@makingsenseremotely6207 Yeap i found it! Thanks anyway
      I did it like this, i needed the bands seperated.
      for image in rawSat_folder:
      raw = gdal.Open(f'{RawSat_folder}/{image}')
      trans = gdal.Translate(f'{satImage_folder}/{image}.tiff', raw)
      trans = None

  • @repsolrider6877
    @repsolrider6877 3 года назад

    i have a 2.5Gb GeoTiff image and i used your code to extract pixel and its values but, the xyz file size is going on increasing it got upto almost 21gb and my anaconda environment got crashed, it happens everytime i run the code, can you help me where i was doing wrong?

    • @makingsenseremotely6207
      @makingsenseremotely6207  3 года назад +1

      As I mentioned in this video, it is not a good idea to do this for very large data sets, because the xyz files will get huge. Try to subset your data or just work with it in geotiff format. If you just want to extract pixel values at certain locations, there are better ways to do this than just turning the entire raster into xyz. Here is an example: gis.stackexchange.com/questions/317391/python-extract-raster-values-at-point-locations

    • @repsolrider6877
      @repsolrider6877 3 года назад

      By increasing the paging file size to 100Gb did the trick, i got output csv file of 12gb, btw this GeoTiff image is our whole state so i need each and every pixel data and their coordinates to store it in db for future usage, and thank you so much your code helped me a lot, before py i used rasterToPoints() function in R to get coordinates and values of every pixel, but it got crashed every time, so i switched to py spyder and increased paging file size, i got output in 10min. About the link you gave me i have doubt, i have single GeoTiff file and i want to clip this GeoTiff file using coordinates only, not by shape file, csv file or extents how can we do that, that links suggests using shape file, thanks in advance

    • @makingsenseremotely6207
      @makingsenseremotely6207  3 года назад +2

      Glad to hear you found a way to make it work for you. The link I sent you is not about clipping a raster, but about extracting raster values at specific point locations. For clipping a geotiff file with coordinates I use gdal.Warp("dem_clipped.tif", dem, outputBounds = (xmin, ymin, xmax, ymax), dstNodata = -9999)

    • @repsolrider6877
      @repsolrider6877 3 года назад

      I'm assuming the "dem" in the gdal.Warp() function is a dataframe which consists coordinates of a polygon right? If yes, can you show me few rows(3 should be enough) of that dataframe.

    • @makingsenseremotely6207
      @makingsenseremotely6207  3 года назад

      No. The dem is the dataset/geotiff that you want to clip (opened as gdal.Dataset). You could also just provide the filename, e.g. "dem.tif". It's further explained in my "Splitting raster data" video.

  • @yuhuibao1728
    @yuhuibao1728 3 года назад

    Very impressive, hope one day i could write code without looking turorial everywhere.

  • @mohammadferdosian6173
    @mohammadferdosian6173 3 года назад

    Hi, do you have any ENVI tutorial ?

    • @doitnew
      @doitnew 3 года назад

      ruclips.net/video/siP-OfNVmOw/видео.html