Re: [Qgis-user] Python script for QGIS

2019-12-28 Thread LE LAMER Romain
Hi,
Thanks for the code but it doesn’t work :/
ERROR 5: map_11_0_309.tiff: GDALDataset::GetRasterBand(2) - Illegal band #

it is quite complex to understand and the help of gdal is not very provided…

this is what gdalinfo returns to me
For .tiff :
gdalinfo map_11_0_309.tiff
Driver: GTiff/GeoTIFF
Files: map_11_0_309.tiff
Size is 256, 256
Coordinate System is:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4326"]]
Origin = (-180.000,-18.6328125)
Pixel Size = (0.001373291015625,-0.001373291015625)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (-180.000, -18.6328125) (180d 0' 0.00"W, 18d37'58.13"S)
Lower Left  (-180.000, -18.9843750) (180d 0' 0.00"W, 18d59' 3.75"S)
Upper Right (-179.6484375, -18.6328125) (179d38'54.38"W, 18d37'58.13"S)
Lower Right (-179.6484375, -18.9843750) (179d38'54.38"W, 18d59' 3.75"S)
Center  (-179.8242188, -18.8085938) (179d49'27.19"W, 18d48'30.94"S)
Band 1 Block=256x128 Type=Byte, ColorInterp=Palette
  Image Structure Metadata:
NBITS=2
  Color Table (RGB with 4 entries)
0: 60,89,96,255
1: 109,178,200,255
2: 138,193,212,255
3: 161,205,220,255

For the original png :
gdalinfo map_11_0_309.png
Driver: PNG/Portable Network Graphics
Files: map_11_0_309.png
Size is 256, 256
Coordinate System is `'
Corner Coordinates:
Upper Left  (0.0,0.0)
Lower Left  (0.0,  256.0)
Upper Right (  256.0,0.0)
Lower Right (  256.0,  256.0)
Center  (  128.0,  128.0)
Band 1 Block=256x1 Type=Byte, ColorInterp=Palette
  Image Structure Metadata:
NBITS=2
  Color Table (RGB with 4 entries)
0: 60,89,96,255
1: 109,178,200,255
2: 138,193,212,255
3: 161,205,220,255

RGB 59,89,95,255 is missing in this tile

Is it possible, via gdal_calc.py, or goal_translate or other program (that I 
don’t know) to tell him:
If, in the color table, RGB 59,89,95,255 AND / OR RGB 60,89,96,255 are present 
it is necessary to replace them with RGB 255, 255, 255, 255 and all the other 
entries are to be replaced by RGB 0, 0, 0 , 255 ?

which would only make 2 entries in the color table on 1 band.

Thanks

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Python script for QGIS

2019-12-27 Thread LE LAMER Romain
Hi,
Is it possible via gdal_translate, or other gdal program, to binarize a tile?

I would like the colors RGB 59,89,95,255 & 60,89,96,255  change to white (color 
entry 0) and that the other colors 109,178,200,255; 138,193,212,255 & 
161,205,220,255 change to black (color entry 1)

I don't understand how to use the -b and / or -mask arguments in this code
l = 'gdal_translate -a_srs EPSG:4326 -a_ullr ' + ullr + f_in + f_out + '\n'

Thanks
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] Python script for QGIS

2019-12-23 Thread LE LAMER Romain

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 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
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Georeference png files

2019-12-22 Thread LE LAMER Romain
Hi Nick,
Thanks for this method.
I didn't manage to do it in the QGIS python console but I installed gdal on the 
mac and it does the job perfectly.
I have more than to make a script to convert the whole and I could exploit that 
on QGIS.

> Le 22 déc. 2019 à 21:06, Nick Hopton  a écrit :
> 
> It is possible to assign georeferenced bounds to a raster using
> gdal_translate:
> 
> gdal_translate -a_ullr input.png output.tiff
> 
> Where:
>  = upper left x
>  = upper left y
>  = lower right x
>  = lower right  y
> 
> The resulting tiff won't contain CRS data.
> 
> Nick.
> 
> 
> 
> 
> --
> Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-User-f4125267.html
> ___
> Qgis-user mailing list
> Qgis-user@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] Georeference png files

2019-12-22 Thread LE LAMER Romain
@Nicolas :
I tried to save it in .geoTiff format (right click, export, save as) I end up 
with a white or black tile … 
If you want to try, here is the png and the coordinates (if you get there, I 
would like to know the method)

[cid:FA974430-F7BF-4AD9-BC9D-316070788235]

N = 71,71875
W = -180
S = 71,3671875
E = -179,6484375

@ Paolo & @ Nicolas :
Thanks, I will try the method with the .pngw file
(without being mistaken in the calculation)
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] Georeference png files

2019-12-22 Thread LE LAMER Romain
Hi,
I have a complete map in tiles of 256 x 256 px in png format not georeferenced. 
(if I open them in QGIS they are superimposed on each other)
1024 tiles in Longitude and 512 tiles in Latitude = 524288 tiles.
Each tile is named as follows: map_Z_X_Y.png
Z => zoom (11).
X => from 0 to 1023.
Y => from 0 to 511.

# If I say no nonsense, I can, by calculation, know the Longitude and Latitude:
lonN = (360 * (X / 1024)) - 180.
latW = 90 - (180 * (Y / 512)).

In the same principle, I can determine the South East coordinates.
I know that the whole map is divided into 1024 tiles of 256px in longitude, 
1024 x 256 = 262144px for 360 ° so a tile = (256 x 360) / 262144 = 0.3515625 °
Same reflection for the latitude, 512 tiles of 256px or 512 x 256 = 131 072px 
for 180 ° so a tile = (256 x 180) / 131 072 = 0.3515625 °

lonE = lonN + 0.3515625
latS = latW - 0.3515625

How can I add these coordinates to the png file?

Thanks
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Re: [Qgis-user] "Activate" ASTER Global Digital Elevation Model V002

2019-12-22 Thread LE LAMER Romain
Hi,
Thanks for your advice but I found the mapping I need.
I also have a question on this one, I will open another topic

Le 2 déc. 2019 à 19:37, Nicolas Cadieux 
mailto:nicolas.cadi...@archeotec.ca>> a écrit :

Hi,
I tested ASTER 2.  They are horrible.  If you are between plus of minus 60, go 
with SRTM data.  ALOS AW3D30 is far superior to ASTER also and covers about the 
same ground.
Nicolas

Le 2 déc. 2019 à 11:31, LE LAMER Romain 
mailto:rlela...@hotmail.fr>> a écrit :


Hi,
I need ASTGTM v2 except now we are in v3.
(Minimum water body detection size v2 => 1 km², v3 => 0.2 km²)
In the doc, I understand that it is possible to display the v3 in v2 via the 
num file, indicating a number in the range 60 - 110. (any of them ?)
I'm using QGIS 3.10 on macOS and I don't know where to put this damn number to 
"activate" version 2 of the tile.
Thanks for enlightening my lantern ;)
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org<mailto:Qgis-user@lists.osgeo.org>
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

[Qgis-user] "Activate" ASTER Global Digital Elevation Model V002

2019-12-02 Thread LE LAMER Romain
Hi,
I need ASTGTM v2 except now we are in v3.
(Minimum water body detection size v2 => 1 km², v3 => 0.2 km²)
In the doc, I understand that it is possible to display the v3 in v2 via the 
num file, indicating a number in the range 60 - 110. (any of them ?)
I'm using QGIS 3.10 on macOS and I don't know where to put this damn number to 
"activate" version 2 of the tile.
Thanks for enlightening my lantern ;)
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user