[gdal-dev] Need Help with gdal2tiles for large super overlay ingooglemaps
Chris Smemoe
csmemoe at aquaveo.com
Wed Oct 30 14:20:03 PDT 2019
Nick,
That's lots of info and questions. Just from a quick overview, it looks
like you need to set your ground control points to the correct lat/lon
coordinates (or whatever coordinate system you want to use) and you also
need to set your image's projection. You can do both of these with the -gcp
and the -a_srs flags in gdal_translate. You would need to pass the exact
longitude/latitude of known points on your image as the 3rd and 4th
arguments to the -gcp flag. The first and second arguments of the -gcp are
the column and row of the image corresponding to the lat/lon coordinate.
You could use EPSG:4326 (WGS 84) for your -a_SRS argument. There might be
other problems once you get past this though. You could also try posting
this to gis.stackexchange and you might get a better response.
Chris
_____
From: gdal-dev [mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Nick
Licata
Sent: Wednesday, October 30, 2019 2:58 PM
To: gdal-dev at lists.osgeo.org
Subject: [gdal-dev] Need Help with gdal2tiles for large super overlay
ingooglemaps
I included as much detail as I could. I put links to all images because I
wasn't sure they would embed in the email list. Experienced programmer but
brand new to gdal.
Overview: My drone is taking multiple high resolution images that slightly
overlap each other in order to view 1 large high resolution image with great
detail after they are put together. I want to superimpose those images in
google maps as a super-overlay. It is a large area being imaged and there
can be from 800 to 1500 images. I am trying to follow these instructions:
https://developers.google.com/kml/articles/raster#step-3:-get-information-ab
out-the-image
I am using python3 3.6.8 and gdal 2.4.0 on ubuntu.
My plan is to execute gdal2tiles for each of these images that will compose
the 'single' large image to be super-overlayed in google maps (using
javascript).
These are the steps I took using this image downloaded locally:
https://s3.amazonaws.com/app-dev.mydroneop.com/DJI_0001.JPG
1. I run this command:
>gdalinfo DJI_0001.JPG -json
(the full output of this command is here:
https://s3.amazonaws.com/app-dev.mydroneop.com/gdalinfo-output.json)
But as I understand it the important part is this:
"cornerCoordinates":{
"upperLeft":[
0.0,
0.0
],
"lowerLeft":[
0.0,
3648.0
],
"lowerRight":[
5472.0,
3648.0
],
"upperRight":[
5472.0,
0.0
],
"center":[
2736.0,
1824.0
]
}
2. I then run this command and it produces this file:
https://s3.amazonaws.com/app-dev.mydroneop.com/output.vrt
> gdal_translate -of VRT -a_srs EPSG:4326 -gcp 0 0 -180 90 -gcp 5472 0 180
90 -gcp 5472 3648 180 -90 DJI_0001.JPG output.vrt
The -180 90 and 180 90 does not seem right, does not seem those should not
be variable specific to the images long/lat in some way.
3. Then I run this command:
gdalwarp -of VRT -t_srs EPSG:4326 output.vrt output2.vrt
and it produces this file:
https://s3.amazonaws.com/app-dev.mydroneop.com/output2.vrt
4. Then finally I run this command:
gdal2tiles.py -p geodetic -k output2.vrt
and it produces a folder of sub folders with images, but here is the doc
file is produces:
https://s3.amazonaws.com/app-dev.mydroneop.com/tiles/doc.kml
The other files (images and kmls) are accessible relative to that file's
location if you need to see them.
I then build a basic web page consuming googlemaps and 'import' the kml file
like this:
======START HTML=======
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=GOOGLE_MAPS_KEY
<https://maps.googleapis.com/maps/api/js?key=GOOGLE_MAPS_KEY&callback=initMa
p> &callback=initMap"></script>
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
// center: new google.maps.LatLng(43.6424359, -79.37448849999998),
zoom: 2,
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.ROAD
});
var layers = [];
layers [0] = new
google.maps.KmlLayer("https://s3.amazonaws.com/app-dev.mydroneop.com/tiles/d
oc.kml",{
preserveViewport: false,
map: map
});
}
======END HTML=======
Full Source is here:
https://s3.amazonaws.com/app-dev.mydroneop.com/index.html
Here is the problem and my questions:
1. I only run this on a single image while I get it to work, but the single
image appears in the center of the world map and not in the long/lat
associated to the image file. The image also appears stretched on it's
edges. As can be seen here:
https://s3.amazonaws.com/app-dev.mydroneop.com/result-zoomed-in.png
https://s3.amazonaws.com/app-dev.mydroneop.com/result-zoomed-out.png
2. What am I doing wrong with the placement of the images not being at
correct long lat position and rather being in the center of the world map? I
assume this has something to do with the 180 90 in the gdal_translate
command but don't know where to derive those numbers from if I should be
deriving them.
3. Is it ok that I want to run gdal2tiles on each individual image that make
up this large orthomosaic image that will be super-overlayed? Or should
those images be stitched together and then gdal2tiles be run on the single
super large image (400 mb and higher).
4. Why don't the images change as I zoom in? (the purpose of the tiles I
thought) in my google maps html file?
5. In the doc.kml file, will those relative links (relative to kml file)
work when the doc.kml is used in new google.maps.KmlLayer('doc.kml')?
6. Using this command below I thought it converted x and y pixel position in
the image to real world long/lat, how do I get long/lat from the command's
output?:
> gdallocationinfo DJI_0001.JPG 10 10
Report:
Location: (10P,10L)
Band 1:
Value: 45
Band 2:
Value: 75
Band 3:
Value: 13
I have searched and read many docs but can't find a sample for what I am
trying to do, just pieces here and there and I haven't been able to put a
complete process together. If there is somewhere that has a relatively
complete explanation for what I am trying to do feel free to just point me
there.
Thank you for your patience if you read through all that, I appreciate any
help that can be offered.
Nick
--
Nick Licata
nalicata at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20191030/ecc65cdd/attachment-0001.html>
More information about the gdal-dev
mailing list