Skip to content

Add tile scripts#5

Open
Robinlovelace wants to merge 6 commits into
mem48:masterfrom
Robinlovelace:master
Open

Add tile scripts#5
Robinlovelace wants to merge 6 commits into
mem48:masterfrom
Robinlovelace:master

Conversation

@Robinlovelace

Copy link
Copy Markdown
Contributor

No description provided.

@Robinlovelace

Copy link
Copy Markdown
Contributor Author

Update: the result looks good, but with red background instead of transparency:

image

@Robinlovelace

Copy link
Copy Markdown
Contributor Author

Trying to fix it with:

gdal_translate -mask 4 dutch_slc-10m-merge2.tif dutch_slc-10m-merge2.tif

@nikolai-b

Copy link
Copy Markdown

@Robinlovelace where does the bicycle-100m.tif come from? Given you aren't colouring it (just tiling it) I'm assuming it is pre-coloured.

@Robinlovelace

Copy link
Copy Markdown
Contributor Author

@nikolai-b we have the raw .tifs on our hds here - around 30GB each.

@Robinlovelace

Copy link
Copy Markdown
Contributor Author

bicycle-100m.tif is a test dataset at low res.

@nikolai-b

Copy link
Copy Markdown

Does it come from https://github.com/mem48/pct-raster-tests/blob/master/R/rasterise.R#L66 ? In that case it has likely been coloured in https://github.com/mem48/pct-raster-tests/blob/master/R/rasterise.R#L62 .

I wanted to just run that script with alpha = T e.g. #3 (comment)

@Robinlovelace

Copy link
Copy Markdown
Contributor Author

Does it come from https://github.com/mem48/pct-raster-tests/blob/master/R/rasterise.R#L66 ?

No I'm running GDAL 2.4 from bash.

I think the alpha setting, via -a 0.0 should solve it, as per latest commit to this PR.

@Robinlovelace

Copy link
Copy Markdown
Contributor Author

I think I've diagnosed the issue. Here's a hint:

image

@Robinlovelace

Copy link
Copy Markdown
Contributor Author

Fixed with

gdal_translate -a_nodata 255 dutch_slc-10m-merge2.tif dutch_slc-10m-merge2-nodata.tif

@Robinlovelace

Copy link
Copy Markdown
Contributor Author

Hi guys, I had a good shot at this and am close to a solution. The problem is now easy to debug based on this release:

https://github.com/npct/pct-lsoa-vis/releases/download/0.0.1/dutch_slc-10m-merge2-test.tif

Reproducible example showing that it's the 255,0,0 value of the 'transparent' area that is the problem:

u = "https://github.com/npct/pct-lsoa-vis/releases/download/0.0.1/dutch_slc-10m-merge2-test.tif"
download.file(url = u, destfile = "test.tif")
remotes::install_cran("magick")
#> Skipping install of 'magick' from a cran remote, the SHA1 (2.0) has not changed since last install.
#>   Use `force = TRUE` to force installation
library(magick)
#> Linking to ImageMagick 6.9.7.4
#> Enabled features: fontconfig, freetype, fftw, lcms, pango, x11
#> Disabled features: cairo, ghostscript, rsvg, webp
i = image_read("test.tif")
i

i_fixed = image_transparent(image = i, color = "red")
i_fixed

Created on 2019-02-28 by the reprex package (v0.2.1)

@Robinlovelace

Copy link
Copy Markdown
Contributor Author

Heads-up @mem48 and @nikolai-b - see my code to debug this. Plan to try with magick to fix it as GDAL solution is not clear to me.

@Robinlovelace

Copy link
Copy Markdown
Contributor Author

But if either of you find a GDAL solution (which I'm sure exists) that would be preferable.

@Robinlovelace

Copy link
Copy Markdown
Contributor Author

@Robinlovelace

Copy link
Copy Markdown
Contributor Author

Update: I have another tile set to test. Please can you give this a spin @nikolai-b - not working in the leaflet.html file contained within - see .zip attached.
raster_w-alpha.zip

@Robinlovelace

Copy link
Copy Markdown
Contributor Author

@nikolai-b apologies for the iterative nature of this but I've finally got a test tileset that I'm confident will work. Please test these (deliberately tiny) tiles:
output2.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants