[gdal-dev] Python/Java GDAL - How to estimate the geo coordinates and width / height without warping dataset?

Frank Warmerdam warmerdam at pobox.com
Tue May 19 10:03:07 PDT 2020


Pham,

My point was that I use gdalwarp itself along with all the options (such as
setting the target resolution), but to VRT format.  I imagine the
"commandline gdalwarp API" interface would be able to do this from Java.
  If often just shell out and run the command.

Best regards,
Frank


On Tue, May 19, 2020 at 12:37 PM Pham Huu Bang <a09550 at gmail.com> wrote:

> @Even Rouault <even.rouault at spatialys.com>
>
> Unfortunately, this method is not enough to solve my problem as I *also
> have a given geo X, Y resolutions *in target CRS (EPSG:4326) as input.
>
> Below is what I've with Python GDAL:
>
>     src_ds = gdal.GetDriverByName("VRT").Create("", 1830, 1830)
>     src_ds.SetGeoTransform([600000.000, 60, 0,  5900040, 0, -60])
>
>      // source CRS EPSG:32632
>     src_srs = osr.SpatialReference()
>     src_srs.ImportFromEPSG(32632)
>     src_wkt = src_srs.ExportToWkt()
>
>      // destination CRS EPSG:4326
>     dst_srs = osr.SpatialReference()
>     dst_srs.ImportFromEPSG(4326)
>     dst_wkt = dst_srs.ExportToWkt()
>
>    // This method doesn't have the possibility to add the given geo X, Y
> resolutions in EPSG:4326  (!)
>     dst_ds = gdal.AutoCreateWarpedVRT(src_ds,
>                                       src_wkt,
>                                       dst_wkt,
>                                       gdal.GRA_NearestNeighbour,
>                                       0.125)
>
> On Tue, 19 May 2020 at 18:14, Even Rouault <even.rouault at spatialys.com>
> wrote:
>
>> On mardi 19 mai 2020 12:01:58 CEST Frank Warmerdam wrote:
>>
>> > Pham,
>>
>> >
>>
>> > I have sometimes taken the approach of doing a "gdalwarp to VRT" which
>>
>> > creates the configuration of the target dataset in VRT format, but does
>> not
>>
>> > actually resample any imagery. The you can open the VRT and query it's
>>
>> > configuration. There are also lower level apis to get this information
>> but
>>
>> > they are not normally exposed through SWIG in Java, Python, etc as far
>> as I
>>
>> > know.
>>
>> >
>>
>>
>>
>> gdal.AutoCreateWarpedVRT() is available in Java bindings:
>>
>>
>>
>> https://gdal.org/java/org/gdal/gdal/gdal.html
>>
>>
>>
>> Even
>>
>>
>>
>> --
>>
>> Spatialys - Geospatial professional services
>>
>> http://www.spatialys.com
>>
>

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam,
warmerdam at pobox.com
light and sound - activate the windows | +1 650-701-7823
and watch the world go round - Rush    | Geospatial Software Developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200519/acd4decc/attachment.html>


More information about the gdal-dev mailing list