[gdal-dev] Python-GDAL - How do I create a GeoTIFF from this array?

Joseph McGlinchy jmcglinchy at hydrosat.com
Tue Jul 30 07:11:36 PDT 2024


I think you want to


  *
Create a dataset with the geotiff driver with appropriate data type, and 1 band
  *
Construct geotransform from the longitude/latitude arrays (google: gdal python geotransform)
  *
Write the 3rd band (values) of your array to that dataset

Otherwise, yeah the XYZ approach looks good since if you create a numpy array from that list, it should be shape [number of pixels, 3]

________________________________
From: gdal-dev <gdal-dev-bounces at lists.osgeo.org> on behalf of gdal-dev-request at lists.osgeo.org <gdal-dev-request at lists.osgeo.org>
Sent: Tuesday, July 30, 2024 5:14 AM
To: gdal-dev at lists.osgeo.org <gdal-dev at lists.osgeo.org>
Subject: gdal-dev Digest, Vol 242, Issue 48

Send gdal-dev mailing list submissions to
        gdal-dev at lists.osgeo.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.osgeo.org/mailman/listinfo/gdal-dev
or, via email, send a message with subject or body 'help' to
        gdal-dev-request at lists.osgeo.org

You can reach the person managing the list at
        gdal-dev-owner at lists.osgeo.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of gdal-dev digest..."


Today's Topics:

   1. ogr2ogr postgres index generation (Hanskaspar Frei)
   2. Python-GDAL - How do I create a GeoTIFF from this array?
      (Stefan Gofferje)
   3. Issue with GeoJSON to DGN Conversion and Back
      (Shahrukh Mirza Nawandish)


----------------------------------------------------------------------

Message: 1
Date: Tue, 30 Jul 2024 08:57:05 +0000
From: Hanskaspar Frei <hkfrei at karten-werk.ch>
To: "gdal-dev at lists.osgeo.org" <gdal-dev at lists.osgeo.org>
Subject: [gdal-dev] ogr2ogr postgres index generation
Message-ID: <b2b05d57-4e9c-4ffc-9615-ee8d5fa19f33 at karten-werk.ch>
Content-Type: text/plain; charset="utf-8"

Hi everybody

We used an old GDAL Version (3.2.1) to load data to a postgis db with
ogr2ogr.
There was an automatic spatial index generation taking place, which
seemed to have a logic to avoid duplicated index names.

Examples with GDAL 3.2.1:

For a table with the name
"ch059_liegenschaften_grundstueckpos_hilfslinien" a index named
"ch059_liegenschaften_grundstueckpos_hilfs_wkb_geometry_geom_idx" got
created.
For a table with the name
"ch059_liegenschaften_grundstueckpos_hilfslinien_proj" a index named
"ch059_liegenschaften_grundstueckpos_hilfslinien_proj_wkb_geomet" got
created.


Examples with GDAL 3.9.1:
For a table with the name
"ch059_liegenschaften_grundstueckpos_hilfslinien" a index named
"ch059_liegenschaften_grundstueckpos_hilfs_wkb_geometry_geom_idx" got
created.(equal like GDAL 3.2.1)
For a table with the name
"ch059_liegenschaften_grundstueckpos_hilfslinien_proj" it tries to
create an index named
"ch059_liegenschaften_grundstueckpos_hilfs_wkb_geometry_geom_idx" which
is equal to the one of the table above and therefore not valid in postgres

I am aware that the the maximum identifier length in postgis is 63 Bytes
and therefore the index names get cutted.

But why is this change in the index naming happening between GDAL
Version 3.2.1 and 3.9.1?

We don't want to downgrade to the old GDAL Version, but Is there a way
to go back to the old naming system which avoided duplicated names?




Thanks and best regards

Hanskaspar Frei

--
[logo]
Karten-Werk GmbH
Hanskaspar Frei
Via Vincenzo Dalberti 13
6718 Olivone

Phone: +41 79 360 72 83
Web: https://karten-werk.ch | E-Mail: hkfrei at karten-werk.ch<mailto:hkfrei at karten-werk.ch>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240730/3f0680d5/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logomarker.png
Type: image/png
Size: 2456 bytes
Desc: logomarker.png
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240730/3f0680d5/attachment-0001.png>

------------------------------

Message: 2
Date: Tue, 30 Jul 2024 09:03:13 +0000
From: Stefan Gofferje <lists at home.gofferje.net>
To: gdal-dev at lists.osgeo.org
Subject: [gdal-dev] Python-GDAL - How do I create a GeoTIFF from this
        array?
Message-ID:
        <0107019102e11de9-fc989f77-4e56-433e-a182-a0f9670aaacf-000000 at eu-central-1.amazonses.com>

Content-Type: text/plain; charset=UTF-8; format=flowed

Hi all,

I'm still learning Python and GDAL.

I'm pulling the NOAA Aurora forecast in Python and create an array from
it in this format:

[ [lon, lat, value], [lon, lat, value], [lon, lat, value] ...]

like

[ [-180,-90,0], [-180,-89,0], ... , [359, 89, 0], [359, 90, 0] ]

I would like to write this into a 1 band GeoTIFF but I'm missing some
understanding of data types apparently.
I was wondering if somebody could point me in the right direction...

-Stefan

--
  (o_   Stefan Gofferje            | SCLT, MCP, CCSA
  //\   Reg'd Linux User #247167   | VCP #2263
  V_/_  https://www.gofferje.net   | https://www.saakeskus.fi



------------------------------

Message: 3
Date: Tue, 30 Jul 2024 14:04:39 +0300
From: Shahrukh Mirza Nawandish <mirza.nawandish at haritaevi.com>
To: "gdal-dev at lists.osgeo.org" <gdal-dev at lists.osgeo.org>
Subject: [gdal-dev] Issue with GeoJSON to DGN Conversion and Back
Message-ID: <327921722337401 at mail.yandex.com>
Content-Type: text/plain; charset="us-ascii"

An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240730/8fd52840/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: converter_from_dgn.geojson
Type: application/json
Size: 6893 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240730/8fd52840/attachment.json>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: peak_sample_data_UTM_EPSG_32643.dgn
Type: application/octet-stream
Size: 2658 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240730/8fd52840/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: peak_sample_data.GeoJSON
Type: application/json
Size: 3081 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240730/8fd52840/attachment-0001.json>

------------------------------

Subject: Digest Footer

_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


------------------------------

End of gdal-dev Digest, Vol 242, Issue 48
*****************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240730/b361ba9b/attachment-0001.htm>


More information about the gdal-dev mailing list