Hi,
I would need help ...

I know how to do all the steps on the QGIS interface except one, the 
binarization of the png with the Raster calculator according to the RGB colors

I have 524 288 png tiles to convert to kml, and even if I wanted to, it's an 
impossible task by hand ... so I would like to automate that.

Here's what I've managed to do so far ...

def run_script(iface):

# 'map_11_' + str(column) + '_' + str(line) + '.png'
for column in range(1023):
for line in range(511):
# Convert World Coordinate to GPS Coordinate
def convWcToGps(column, line):
# lonW
var ulx = (360 * (column / 1024)) - 180
# latN
var uly = 90 - (180 * (line / 512))
# lonE
var lrx = ulx + 0.3515625
# latS
var lry = uly - 0.3515625
return ulx, uly, lrx, lry
# Verbose
print ('map_11_' + str(column) + '_' + str(line) + '.png'
+ '\n lonW (ulx) = ' + ulx
+ '\n latN (uly) = ' + uly
+ '\n lonE (lrx) = ' + lrx
+ '\n latS (lry) = ' + lry)

# Add GPS Coordinate and Projection
# gdal_translate -a_srs EPSG:4326 -a_ullr <ulx> <uly> <lrx> <lry> input.png 
output.tiff
'gdal_translate -a_srs EPSG:4326 -a_ullr ' + str(ulx) + ' ' + str(uly) + ' ' + 
str(lrx) + ' ' + str(lry) + ' /Users/romain/TilesVR/map_11_' + str(column) + 
'_' + line + '.png  /Users/romain/TilesVR/map_11_' + str(column) + '_' + 
str(line) + '.tiff'
print ('Add Coordinate and Projection => DONE')

# Binarisation
# map_11_column_line.tiff to BIN_map_11_column_line.tif
# 0 black = sea, 1 white = land
# land = RGB 59,89,95,255 & RGB 60,89,96,255
# ? code
print ('Binarisation => DONE')

# Polygonisation
# BIN_map_11_column_line.tif to POL_map_11_column_line.shp
'gdal_polygonize.py "/Users/romain/TilesVR/BIN_map_11_' + str(column) + '_' + 
str(line) + '.tif" "/Users/romain/TilesVR/POL_map_11_' + str(column) + '_' + 
str(line) + '.shp" -b 1 -f "ESRI Shapefile" POL_map_11_' + str(column) + '_' + 
str(line) + 'DN'
print ('Polygonisation => DONE')

# Repair geometry
# POL_map_11_column_line.shp to RP_POL_map_11_column_line.shp
# ? code
print ('Repair geometry => DONE')

# Linearisation
# RP_POL_map_11_column_line.shp to LN_map_11_column_line.shp
# ? code
print ('Linearisation => DONE')

# Export kml
# LN_map_11_column_line.shp to KML_map_11_column_line.kml
# ? code
print ('Export Kml => DONE’)


Would you be willing to help me ?

Thanks

_______________________________________________
Qgis-user mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to