• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX Watermask from shapefile?

Messages
527
Country
australia
Hi,

I was just wondering if it is possible to take a shapefile with coastline information and convert that to a geotiff somehow to kind of automate the process of creating a water mask for a country's coastline. I have found several shapefiles with land and water polygons representing a country, or continents coastline, but I can't really figure out how to do a conversion to geotiff (or geotiffs), and therefore tiff files of a certain size that can then be recoloured to use as a watermask when running through FSX resample.

I'm sure this method won't be as accurate as hand drawing along a coastline, but I'm just wondering if there is a quick way to do it.

Cheers,

Scott
 
Messages
7,450
Country
us-illinois
Hello:

Conversion of Geo-referenced vector SHP to raster GeoTiff is possible using payware GIS utilities such as ESRI ArcGIS, GlobalMapper etc., or various other freeware utilities (most of which utilize GDAL function libraries):

https://www.google.com/#q=gdal_rasterize examples


Other options:

https://www.google.com/#q=GIS convert SHP to GeoTIFF&btnK=Google Search


NOTE: Even 'Google Earth Enterprise' utilizes GDAL to perform such conversions:

https://support.google.com/earthenterprise/answer/4525555?hl=en

https://support.google.com/earthenterprise/answer/4525555?hl=en#h.wwsxau-f5geku


CAVEAT: Reportedly the version of GDAL_Rasterize must be at least 1.8.0 for a less cumbersome workflow

http://gis.stackexchange.com/questions/22704/how-to-convert-a-vector-layer-to-raster

"Convert Vector to Raster wraps GDAL's gdal_rasterize, which until version 1.8.0, didn't create the output raster. So the cell size, projection, and so on are determined by the raster not the command line options.


It is something of a Catch-22 for sure because GDAL has no easy method of creating an empty image. You can try creating two one-pixel images for the top left and bottom right in a paint program, run gdal_translate on them to georeference them, then create a VRT from those, and finally use gdal_translate to convert from the VRT to a GeoTIFF or similar, but it is a pain for sure!


The better alternative would be to upgrade to GDAL >= 1.8.0 and use the new -tr and -te parameters of gdal_rasterize.
"



FYI: News on the most recent (as of this date) release for the new version 1.11.0 of GDAL/OGR:

http://courses.neteler.org/gdalogr-1-11-0-released/


BTW: Another "gothcha" is that some GIS vector to raster utilities may have problems with correctly interpreting / processing SHP files with multi-part polygon entities and/or 'holes' (aka "multipolygons with disjunct parts"):

http://wiki.openstreetmap.org/wiki/Relation:multipolygon

http://wiki.openstreetmap.org/wiki/Multipolygon_relation_proposed_edit

http://wiki.openstreetmap.org/wiki/Talk:Relation:multipolygon

http://www.paulnorman.ca/blog/2014/03/osm2pgsql-multipolygons/


Hope this helps with establishing a successful workflow ! :)

GaryGB
 
Last edited:
Messages
527
Country
australia
Hi Gary,

Thanks very much for your reply and all the information.

I have been able to combine the shapefile and geotiff files in QGIS Valmeira, which along with fwtools, is the GIS program I use most often. When I say I have combined them, I mean I can display them both on the screen, but as yet have been unable to export any cropped file which contains the shapefile data within the bounds of each geotiff. I think I am now considering if it's even worth using this method, as the shapefile data I have found does not seem to match the resolution of the geotiff, and therefore any watermask I do produce will be inaccurate. I am trying to do the coastlines of a photoscenery of France I am currently making, so there is obviously a lot of coastline to draw, but this may be my only option if I want it to be accurate. I was really just looking for a quick way, as I don't know if I will even release anything as freeware (although I would like to), so I was just looking for a quicker way of producing the scenery. I have found ways of speeding up a few other processes such as writing out the inf files, using batch commands, and I am still producing the bulk area of France, so it will be a long lasting project either way.

I will definitely look in to all of the information you have provided, and see if there is some way I can do what I want with the shapefiles and geotiffs. Thanks again for you help.

Cheers,

Scott
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,859
Country
netherlands
Hi,

I would try gdal_rasterize. I think you might be able to burn the vector data as a 4th band into your imagery.
 
Messages
527
Country
australia
I have had some success with this. I have found a coastline shapefile for the world which is fairly accurate (but of course not perfect) and also a more accurate waterways shapefile for Europe. I am currently searching for a more accurate coastline shapefile before I continue with the coastal work. I have combined the shapefiles in to one shapefile for the area I need, and then used gdal_rasterize via QGIS 2.20 (Raster-Conversion-Rasterize). I actually tried this method before, but my mistake was not having an existing GeoTiff to act as a template for the coordinates required. I am using the original BMP (which comes with a .bpw world file), making that completely white, and then converting to a GeoTiff. I then use this Geotiff along with the merged shapefile to create an output GeoTiff which has the water "shapes" burned in to it. I then have to use colour exchange in GIMP to convert the burned colour or colours (there are only usually one or two colours, for coast and inland water) to black. The water mask is then done. From a distance it looks pretty good, but there are several inaccuracies I have noticed, especially along the coast. I think this is to be expected though; due to tides, waves, etc, a country's coastline is constantly changing.

Here are a few pics of my progress so far:

2015-5-31_13-57-46-636.jpg


2015-5-31_13-57-55-574.jpg


2015-5-31_14-0-52-666.jpg


2015-6-2_22-46-52-731.jpg


2015-5-31_14-3-4-990.jpg


2015-6-2_22-52-46-251.jpg


2015-6-2_22-53-1-904.jpg


2015-6-2_22-53-51-840.jpg


2015-6-2_22-58-40-773.jpg


2015-6-2_23-1-25-985.jpg


2015-5-31_13-57-33-949.jpg


2015-6-2_23-8-55-888.jpg


2015-6-2_23-4-38-927.jpg


2015-6-2_22-53-13-759.jpg


2015-6-2_22-53-28-707.jpg


2015-6-2_22-55-47-16.jpg


Cheers,
 
Last edited:
Messages
527
Country
australia
Thanks Gary, I will keep plugging away at it. I am starting to realise how big France really is. I just purchased another 4TB HDD recently to do the work I have done already, and now I think I need another one :rolleyes: :).

Cheers,

Scott
 

rhumbaflappy

Administrator
Staff member
Resource contributor
Messages
5,932
Country
us-wisconsin
And this is just one season, daytime, with no autogen. Now you know why Microsoft used the landclass/vector system.

Dick
 
Messages
527
Country
australia
Absolutely Dick, I think at least 70% of my total hard drive space is taken up by photo scenery files, along with source and working images. It's the working images that mostly add up and take up all the space. I really need to go through and clean it up one day, but I can't bring myself to delete some files, thinking that I will need them again one day.

The project is at a standstill at the moment, because the France hydrography shapefile I thought was very accurate turned out to have a lot of holes and inaccuracies in it. There are whole portions of large rivers missing, yet there is even water data for features the size of small dams. I can't really understand this. I am downloading some OSM data from Geofabrik today (there's another 24 GB), so I'm hoping that this will feature the missing waterways, and maybe be a bit more accurate.

Cheers,

Scott
 

dave hoeffgen

Resource contributor
Messages
1,439
Country
germany
this thread seems the most appropriate to my question:

I tried to create a geotiff from a shapefile using gdal_rasterize where the background is black and the polygons (all polygons in the shapefile) have a certain grayscale.
I tried it in command line and in qgis without success. What I managed to to was getting the polygons painted into an existing geotiff but I failed creating a new one.
I either get an image which can't be read or an error message not to use the -b parameters in a gdal dataset, depending if I set them or not.

Can someone please help me setting up a proper command? (QGIS isn't able aswell to generate the full command)

Thanks in advance
 
Messages
527
Country
australia
Hi Dave, I just stumbled back on to this thread while looking at another topic in FSX Terrain. I will try and answer your question.

I did start experimenting with fwtools (command line), but ended up using qgis exclusively to create watermasks using shapefiles. Originally I had the same problem, not being able to create a new Geotiff with fwtools or qgis. Eventually I worked out that the trick is to create a Geotiff (in my case pure white, and yours could probably start off like this also) by simply using Raster/Conversion/Translate. I just used a heap of tifs which were either painted or created white. As I was creating a heap of white geotiffs of only two sizes I just painted over two of my image files in white, and then copied and renamed the files to make up the 30 or 40 files for each section I was working on. then I renamed the .bpw world files that were generated with my images to .tfw and used the batch mode of "Translate" to convert the number of tifs to geotiffs. Then I used Raster/Conversion/Rasterize on each geotiff individually, in my case using a shapefile of coastlines and waterways of France, which I had previously merged in to one shapefile. This is where the trick I learned came in handy. Previously I was trying to do this and export a new file using the command line method, but instead, when using the qgis rasterize function, you just overwrite the geotiff that has previously been created. So the imported geotiff and the exported geotiff will have the same name, and the exported (rasterized) geotiff will have the shapefile data imprinted on to it. Then just use GIMP or Photoshop etc to select the colours and change them to whatever you like.

In my case I started off selecting the bluish, rasterized imprint and converting to black for the water mask, but eventually I figured out that the colour of the shapefile imprint of the internal waterways was actually 0,255,255. The coast colours varied very slightly from this colour. I could just leave the water mask as white and "Bluish", as the inf command "Channel_LandWaterMask = 2.0" is specifying that just the red channel needs to be 0, as it is (Red,Green,Blue : 0,255,255)

So my tip would be just do as you have done in qgis, and use rasterize to paint the polygons on to your Geotiff, but just choose to overwrite your input Geotiff with your output. You will then have an image ready to be touched up with the right masks/colours in your image editing program.

A bit more info on my process can be found here:

http://www.fsdeveloper.com/forum/threads/gimp-batch-mode.434943/


Hopefully that helps.

Cheers,
 

dave hoeffgen

Resource contributor
Messages
1,439
Country
germany
My problem is: I don't even have a geotiff and need to create this as well to simply make a black/grey building mask.
However unable to do this in a single step I found making a black image of any resolution and setting a defined resolution and georeference using GDALwarp does the trick.
So one step is making my black geotiff, the second one is burning in my shapes. That's best done using batch files as any parameter may be changed.
 
Top