Closed geohacker closed 4 years ago
I'll try a few things to see what's going on.
rio cogeo validate --strict ~/Downloads/wp_2020_1km_urban_pop.tif
said that it's a valid cloud optimized geotiff"/cog/tiles/WebMercatorQuad/7/87/63@1x?url=http://localhost:5000/wp_2020_1km.tif&resampling_method=nearest&bidx=1&rescale=0,24688.365234375&color_map=cfastie"
Ha, actually it does work, when I do something like http://covid-publi-131wmiy217ice-1414663655.us-east-1.elb.amazonaws.com/cog/wp_2020_1km_urban_pop/tiles/1/1/1.png?bidx=1&rescale=0,2
Looking closely at the requests while running titiler locally, and supplying the rescale and bidx params. It does seem to work.
I'm guessing what the rescale is doing is scaling the input domain to the range we specify. https://gdal.org/programs/gdal_translate.html#cmdoption-gdal-translate-scale
In today's scrum we decided it would be better if the client (browser) did not need to specify bidx
and rescale
query string parameters. Ideally there would be
cc @geohacker @bitner @pieschker
Wouldn't it be a COP, not a COG at that point?
Cloud optimized PNG? Yeah, we could register copeo.org
? 🤔
Please elaborate if you have concerns or different action plan. thx
cc @pieschker @bitner @geohacker
The visualization COG also should have a nice color ramp baked in.
Although, color ramp != color map. titiler
allow color maps to be defined in it's config https://github.com/developmentseed/titiler/tree/master/docs#color-maps
I need to go through each of these and decide if each one is Classification values (color map) or Continuous values (color ramp). If someone already knows, please add a comment here.
Band 1 Block=961x2 Type=Float32, ColorInterp=Gray
Band 1 Block=961x2 Type=Float32, ColorInterp=Gray
Band 1 Block=961x2 Type=Float32, ColorInterp=Gray
Band 1 Block=2881x2 Type=Byte, ColorInterp=Gray
) The legend and byte values are defined in this PDF http://due.esrin.esa.int/files/GLOBCOVER2009_Validation_Report_2.2.pdf cc @bitner @geohacker @pieschker
Getting a bit confused on terminology too because of color_formula
vs color_map
https://github.com/developmentseed/titiler/blob/master/docs/COG.md color_map cfastie
was also mentioned Slack . 🤔
I filled in the raster layer details above. (source https://github.com/worldbank/HNP/wiki/Data-Extraction-for-Dashboard-creation#tiff-package)
We will do the coloring in titiler
because it supports easy ways to define a bitmap color table (for LandCover), and also supports cfastie
and other common color formulas which will be easy to change out. (we probably want to use a diverging color scheme on the continous value layers).
I am modifying load_tifs.sh
to translate the float64 layers into Uint16 cogs, which will have less friction with the titiler
stack.
cc @geohacker @bitner @pieschker
It looks like the 3 raster layers having continuous values (wp_2020_1km, WP_2020_1km_urban_pop, WP2020_vulnerability_map) are not normalized to range of [-1.0,1.0]. Rather they are zero-based and maxing out at some arbitrary float number. My interpretation is these are not suitable for a diverging color scheme such as cfastie
. For this iteration, I will try one of the other builtin titiler
color schemes, like viridis
or magma
.
processing.run("qgis:rasterlayerstatistics", { 'INPUT': '/Users/alex/repos/covid-wb/s3-data/home/wb411133/data/Projects/CoVID/KEN/WP2020_vulnerability_map.tif', 'BAND': 1})
{'MAX': 1370.6923828125, 'MEAN': 0.9884854401589904, 'MIN': 0.0, 'RANGE': 1370.6923828125, 'STD_DEV': 5.82703651077801, 'SUM': 661674.3609045054, 'SUM_OF_SQUARES': 22728399.768185552}
processing.run("qgis:rasterlayerstatistics", { 'INPUT': '/Users/alex/repos/covid-wb/s3-data/home/wb411133/data/Projects/CoVID/KEN/WP_2020_1km.tif', 'BAND': 1})
{'MAX': 143742.84375, 'MEAN': 82.09278176709948, 'MIN': 0.0, 'RANGE': 143742.84375, 'STD_DEV': 562.3922669420514, 'SUM': 54951430.444824584, 'SUM_OF_SQUARES': 211715211030.541}
processing.run("qgis:rasterlayerstatistics", { 'INPUT': '/Users/alex/repos/covid-wb/s3-data/home/wb411133/data/Projects/CoVID/KEN/WP_2020_1km_urban_pop.tif', 'BAND': 1})
{'MAX': 143742.84375, 'MEAN': 9.452564410674107, 'MIN': -0.0, 'RANGE': 143742.84375, 'STD_DEV': 420.89467855908333, 'SUM': 10146732.383300781, 'SUM_OF_SQUARES': 190161688977.4985}
cc @geohacker @pieschker @bitner
I converted the (wp_2020_1km, WP_2020_1km_urban_pop, WP2020_vulnerability_map) geotiffs to Uint16 and uploaded to s3 in the merged_tifs folder: Now the tiling endpoints are failing with a different set of rasterio error(s), which can be seen in: CloudWatch Logs | Log groups | /ecs/covidwbapi-staging/api | ecs/api/d18b5108-aac8-47ec-90e1-1ae93debbb87.
LC/landcover: I emailed Benjamin to ask about just leveraging the Globcover geotiff from ESA, instead of making work by merging and coloring the landuse classification ourselves.
cc @pieschker @geohacker @bitner
Raster update
re: landcover raster layer. No response yet, from Benjamin to my email. I did some spot check of the GlobCover 2009 product from ESA, and it appears to be a different product than what’s included in the s3 data. In QGIS I overlayed the KEN LC.tif over the GLOBCOVER_L4_200901_200912_V2.3.color.tif and browsed around the country, and they are indeed different. Maybe it’s just a different year. Now I suspect maybe the 2015 product is only for available purchase and that’s what WB has provided. In any case, I am going to proceed with trying to get titiler
to color the byte values in a legend based on legend in the product PDF.
re: (wp_2020_1km, WP_2020_1km_urban_pop, WP2020_vulnerability_map) I modified the load_tifs.sh
script in my branch #28 to create a uint16 file for the tiler visualization. Testing with with URLs like this
http://covid-publi-131wmiy217ice-1414663655.us-east-1.elb.amazonaws.com/cog/{layer_name}/tiles/{z}/{x}/{y}?color_map=magma , e.g.
http://covid-publi-131wmiy217ice-1414663655.us-east-1.elb.amazonaws.com/cog/wp2020_vulnerability_map/tiles/{z}/{x}/{y}?color_map=magma
Note: specifying a color map is required.
The only one not working is wp_2020_1km_urban_pop
and in the Logs I see a rasterio error: IndexError: index 2476 is out of bounds for axis 0 with size 256
. I suspect there could have been data corruption in my s3 upload. Going to continue digging into this today.
> aws s3 ls s3://covid-wb/merged_tifs --recursive
2020-07-13 12:51:43 0 merged_tifs/2020-06-24/
2020-07-13 12:54:50 578302517 merged_tifs/2020-06-24/lc.tif
2020-07-13 12:54:54 983182331 merged_tifs/2020-06-24/wp2020_vulnerability_map.tif
2020-07-13 12:55:00 1236963880 merged_tifs/2020-06-24/wp_2020_1km.tif
2020-07-13 12:54:59 64597113 merged_tifs/2020-06-24/wp_2020_1km_urban_pop.tif
2020-07-13 12:56:31 72242665 merged_tifs/lc.tif
2020-07-13 16:01:39 46283379 merged_tifs/wp2020_vulnerability_map.tif
2020-07-13 16:00:52 968306219 merged_tifs/wp2020_vulnerability_map_data.tif
2020-07-13 16:03:12 181040095 merged_tifs/wp_2020_1km.tif
2020-07-13 16:02:30 1239914347 merged_tifs/wp_2020_1km_data.tif
2020-07-13 16:04:09 21196695 merged_tifs/wp_2020_1km_urban_pop.tif
2020-07-13 16:03:45 64311161 merged_tifs/wp_2020_1km_urban_pop_data.tif
@bitner note the file sizes are now a lot smaller. Your files I moved into 2020-06-24 folder. The new *_data.tif
are the float64 tiffs. The *.tif are the uint16 tifs, except lc.tif is unchanged in format, it is remains as byte values.
Also just noting I think your files may have been inflated because for me the find
was matching many copies of the country tifs. I cleaned up my local copy of the s3 bucket so there should only be 1 copy of each country tiff (hence the smaller sizes even for the float64)
cc @pieschker @geohacker @bitner
Over in https://github.com/developmentseed/covid-wb-api/pull/22#issuecomment-655802770, @guidorice and I were able to confirm that
wp2020_vulnerability_map.tif
,wp_2020_1km.tif
andwp_2020_1km_urban_pop.tif
are causing a 500 from titiler.For example, if you do
curl http://covid-publi-131wmiy217ice-1414663655.us-east-1.elb.amazonaws.com/cog/wp_2020_1km/tiles/13/5865/3796.png
this returnsInternal Server Error
. In the cloudwatch logs, I can see the following error:cc @bitner @pieschker