You are here: Foswiki>OCF Web>OCFIT>GisNotes (2022 Feb 20, clif)Edit Attach

GIS Notes

Workflow

Here is my rough workflow for creating an interim Geo-referenced map for fair use.

Plugins

Currently I use these plugins:
  • GPS Tools
  • Georeferencer
  • Points2One
Go to Plugins -> Manage to install them.

Satellite imagery

First it's nice to have some satellite imagery as your base map to compare things to. If someone has a higher res source please let me know.

Follow the instructions here: http://planet.qgis.org/planet/tag/world%20imagery/

They reference a plugin for this, but I couldn't find it or make it work. You will probably have to change the project CRS to EPSG 3857, and check the "Enable on the fly CRS transformations" box. Under Properties -> Style I like to bump up the Brightness a bit to make it easier to read the black portions of the map layers above it. Also make sure any new layers you create are EPSG 3857 as well, or you might have troubles.

Get Waypoints

Download the most recent GPS waypoints using GPSBabel. Use the GPS XML output format, and save.

Import that file into a layer by clicking GPS Tools button in the Manage layers toolbar.Remove the Routes and Tracks. Enable just the GPS layer. Zoom the map so just the OCF area shows, use the select area tool to select all those showing, Open properties of the current GPS layer and select save as, and in the resulting dialog click on "Save only selected features". Pick a filename to save to, and make that a vector point layer to use for correcting maps. Now remove the GPS layer, as we are done with it. The file will be preserved.

Then in this new layer, right click on it in the layers panel and select properties. Then enable labels. Now select any other groups to move into other layers such as cable runs. Open properties of the current layer and select save as, and in the resulting dialog click on "Save only selected features". Pick a filename to save to, this creates a new layer with the selected points. Don't forget to delete them from the source layer.

Now you can use the the Points2One plugin at the bottom of the tool bar to make lines out of the points, and add them to the appropriate layer.

Operations Map

Front side

Start with operations-map-front-draft-2019-03-07.pdf and pull out two jpg files from it like so:

convert -quality 95 -density 300x300 operations-map-front-draft-2019-03-07.pdf operations-map-front-300dpi.jpg
convert -quality 95 -density 600x600 operations-map-front-draft-2019-03-07.pdf operations-map-front-600dpi.jpg

Find a previous version of the operations map or peach pit that has been georeferenced, or just zoom the Satellite image to the correct area. Next start the Georeferencing process, by selecting Raster -> Georeferencer. Add either the 300dpi or 600dpi files above, and go through the settings selecting what you want. In particular, I think you have to pick EPSG 3857 for the CRS. Pick road intersections in the four corners of the map. Use the option "From Map Canvas", and get the points from the satellite layer. Press the play button to generate the georeferenced file. Once the new layer is loaded, it can replace the first one. By the way the georefrenceer always produces tif files no matter what the suffix is! Also be sure to select compression LZW.

Now open it's properties, Under Band rendering, select Singleband gray. Under Transparency -> Transparent pixel list,, click on the "+" button. Add something like "From 100 To 255 Percent 100", then press OK. If you have a satellite image as the base lmap, it will now become visible.

Keep the Georefenceer open and continue to add points using the last iteration and the satellite imagery as the two layers. Just before you update it remove the current layer, and let the update add it back in. Each time you write the latest version you will have to set the transparency again.
Clipping

Now, because the map gets rotated and there are some black artifacts, it's nice to clip those areas off. We do that with a custom made polygon. In the layer management tool bar, click on New Shapfile Layer, and pick polygon. Enable editing on this new layer, either in the properties or by clicking the pencil button in a tool bar. Use the add feature button to draw an outline around the part of the map you want to keep. You can add, delete, and move points with the Node Tool button. Save that layer.

Now go to Raster -> Extraction -> Clipper. Set the input and output files; eg: /home/clif/Maps/OCF/operations-map/operations-map-front-300dpi_modified.tif and /home/clif/Maps/OCF/operations-map/operations-map-front-300dpi_modified_clipped.tif. Select Mask Layer for the clipping mode, and Check the No data value box (which defaults to zero), to remove the black box around your map. Note that the black ink on the map is rarely fully black, it's value is often 7 or 8. This gives us a way to remove the generated black artifacts which do have pixel values of 0. Now select the Previously created shape layer for the mask. Click OK, and close those dialogs when done.

You can add transparency to the new layer like we did before.
Compressing

You might notice that the clipping operation generates much larger files, and there is no option for compressing them in the dialog box. However, there is the option to edit the produced command line by clicking the edit button. Add these command line switches to whats there just before the "-of" switch:
-co COMPRESS=JPEG -co JPEG_QUALITY=95 -co PHOTOMETRIC=YCBCR -co TILED=YES --config GDAL_TIFF_INTERNAL_MASK YES
Stacking the two sides

If you want to stack the back image on top of the front but have them appear as one map you need to make that area transparent on the front raster. Use these commands to "burn" the back side clipping polygon into the front side. This makes that area transparent along with the rest of the white area:

cp operations-map-front-300dpi_modified_clipped.tif operations-map-front-300dpi_modified_clipped_diff.tif
gdal_rasterize -b 1 -b 2 -b 3 -burn 255 -burn 255 -burn 255 -l Basemap_bk_2015f-flat_clip ../Basemap_bk_2015f-flat_clip.shp operations-map-front-300dpi_modified_clipped_diff.tif

Note that the name of the shape layer must be correct and come before it's file path. If the name is not spelled correctly you will get an missleading error message.

Back side

Start with the Basemap_bk_2015f-flat.tif which is high quality, but too big and slow to load. Convert it to a smaller jpg but with a high enough quality to keep the booth numbers clear. It's handy having the black border, (an artifact of some QGIS operations), to be distinguishable from the image itself. So if you have an image with some perfectly black pixels, like we do here. It's a good idea to bump them all up to say a value of 10. We can't use something as low as 1 because the jpg compression process will dither the pixel values, and if our target is too close to zero then some of the dithered values will reach zero. We can convert our tif to a jpg and make this adjustment with one command:
convert -quality 95 'Basemap_bk_2015f-flat.tif[0]' -fuzz 10% -fill 'gray(10)' -opaque 'gray(0)' Basemap_bk_2015f-flat.jpg

-quality sets the jpg quality, the '[0]' in the input file name selects the first image in the tif. Tifs can have more than one image in them! -fuzz finds black pixels within 10% of 0, -opaque is the color you're looking to replace, -fill is the color you're replacing it with.

Start the Geo reference process, use Basemap_bk_2015f-flat.jpg and save to Basemap_bk_2015f-flat_modified.tif. Follow the georeference instructions here:

https://www.qgistutorials.com/en/docs/georeferencing_basics.html

Then to add more reference points later, pull up the current layer and also load it in the Georeference window, along with the waypoints layer. Then you can bounce back and forth between windows to get the points matched up.
Clipping

Make a clipping mask that goes around the public area as you did for the front side. and clip out the part you want to keep.

Notes:

To edit lat/log of points: https://gis.stackexchange.com/questions/141521/how-to-digitize-building-footprints-with-orthogonal-edges/142247#142247

-- ClifCox - 18 May 2019
Topic revision: r14 - 2022 Feb 20, clif
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback