Water/Blend Masking using shapefile

#1
Hi anyone that can help,

I am looking for a way to clip an fs earth tile bmp file using a shape file to avoid having to manually apply water and blend masks.

I really hope there is an easier way.

Now the bmp file is not a geotif so no coordinates but I'm hoping someone can steer me in the direction of some useful instructions.
Thanks
Kelvin
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#2
Hi,

It won't help you much now, but I have some scenproc features in development that will help with this. I only never tested them with FSET input, but it should work I think. I hope to get some of these features out in not too long.
 
#3
Hi,

It won't help you much now, but I have some scenproc features in development that will help with this. I only never tested them with FSET input, but it should work I think. I hope to get some of these features out in not too long.
Thanks Arno,
I am undertaking a massive task for a freeware New Zealand photorealism and I have hundreds of tiles, it would be great to move away from the ancient way of Masking and have a smarter and more intuitive method.

Keep me posted as I would love to try out these alpha features.
 
#4
Hi,

It won't help you much now, but I have some scenproc features in development that will help with this. I only never tested them with FSET input, but it should work I think. I hope to get some of these features out in not too long.
Hi Arno,

Has there been any progress on being able to create water/blend masks using shapefiles for photo scenery?
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#5
Hi,

This feature is still not released. I have been working on it the last weeks, since I needed it for a project I'm working on. But I'm not clear yet when it will be released.
 

dave hoeffgen

Resource contributor
#9
Could you share with me how to do this? I use Global Mapper and QGis and i'm having trouble converting the shapefiles to Raster.
My trick:
As you can geo reference images in QGis I create a black one, reference it to cover the entire world and call it "globalsource.tif". Why? I need an input file because I didn't get along with the creation option.
Next I use gdalwarp.exe (see documentation: https://gdal.org/gdalwarp.html) to crop an image out of "globalsource.tif" that matches my aerial imagery exactly regarding georeference and resolution.
Last I use gdal_rasterize.exe (documentation: https://gdal.org/gdal_rasterize.html) to rasterize the information from the shapefile into the image.

It is advisable to write a batch file for the gdal steps. I use them directly through command line, not via QGis.

Alternatively, if your imagery has an alpha channel you can skip the first two steps and directly rasterize your water mask into the image's alpha channel.
The alpha channel is where resample.exe looks for the water mask by default anyway, if you don't specify a "Channel_LandWaterMask = ..." entry.
 
#10
My trick:
As you can geo reference images in QGis I create a black one, reference it to cover the entire world and call it "globalsource.tif". Why? I need an input file because I didn't get along with the creation option.
Next I use gdalwarp.exe (see documentation: https://gdal.org/gdalwarp.html) to crop an image out of "globalsource.tif" that matches my aerial imagery exactly regarding georeference and resolution.
Last I use gdal_rasterize.exe (documentation: https://gdal.org/gdal_rasterize.html) to rasterize the information from the shapefile into the image.

It is advisable to write a batch file for the gdal steps. I use them directly through command line, not via QGis.

Alternatively, if your imagery has an alpha channel you can skip the first two steps and directly rasterize your water mask into the image's alpha channel.
The alpha channel is where resample.exe looks for the water mask by default anyway, if you don't specify a "Channel_LandWaterMask = ..." entry.
Thanks very much Dave. Would you mind me asking further questions if I get stuck?
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#12
Hi,

gdal_rasterize can make the GeoTIFF file for you as well (if you use a recent version). With -te you specify the extends (lat/lon) and with -tr you can specify the resolution you want or with -ts the size. Here is an example I use:

Code:
gdal_rasterize -te -127.99 22.76 -65.26 51.65 -tr 0.01 0.01 -burn 1 -ot Byte myfile.shp myfile.tif
 
#13
Hi,

gdal_rasterize can make the GeoTIFF file for you as well (if you use a recent version). With -te you specify the extends (lat/lon) and with -tr you can specify the resolution you want or with -ts the size. Here is an example I use:

Code:
gdal_rasterize -te -127.99 22.76 -65.26 51.65 -tr 0.01 0.01 -burn 1 -ot Byte myfile.shp myfile.tif
Thanks Arno! Is there a way to use the extents in the shape file?
 
#14
Hi Dave,

Can you give me a breakdown of the process below that you noted as I have the Tif file with RGB channels and the correct projection all done.
"Next I use gdalwarp.exe (see documentation httpsgdal.orggdalwarp.html) to crop an image out of globalsource.tif that matches my aerial imagery exactly regarding georeference and resolution."

The bit i'm concerned about is now getting matching tiles with my BMP aerial imagery then doing the masking thing, this is where i'm a little lost.

Thanks in advance.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#15
Thanks Arno! Is there a way to use the extents in the shape file?
I assume that normally you want to match the extends of your images for the water/blend mask and not those of your SHP that might cover a different area.

According to the gdal_rasterize documentation it will use the shp extends if you don't provide the -te option. So probably if you use only -tr or -ts it should pick the extends from the SHP.
 

dave hoeffgen

Resource contributor
#16
Hi Dave,

Can you give me a breakdown of the process below that you noted as I have the Tif file with RGB channels and the correct projection all done.
"Next I use gdalwarp.exe (see documentation httpsgdal.orggdalwarp.html) to crop an image out of globalsource.tif that matches my aerial imagery exactly regarding georeference and resolution."

The bit i'm concerned about is now getting matching tiles with my BMP aerial imagery then doing the masking thing, this is where i'm a little lost.

Thanks in advance.
Do you know your bmp's extents?
 
Top