GIScience / openrouteservice

🌍 The open source route planner api with plenty of features.
https://openrouteservice.org
GNU General Public License v3.0
1.43k stars 392 forks source link

Missing documentation about population data setup with Docker #881

Open elpaso opened 3 years ago

elpaso commented 3 years ago

I'll see if I find the time to contribute that.

for now, quick notes:

Prepare your data

Source: https://data.jrc.ec.europa.eu/dataset/jrc-ghsl-ghs_pop_gpw4_globe_r2015a

Crop your raster using a mask if you don't need the whole world

I am using a shapefile with the USA boundaries in EPSG:54009 usa_54009.shp to clip the raster:

gdalwarp -of GTiff -co "COMPRESS=LZW" -cutline usa_54009.shp -multi -r bilinear -wo NUM_THREADS=ALL_CPUS -overwrite -crop_to_cutline GHS_POP_E2015_GLOBE_R2019A_54009_250_V1_0.tif GHS_POP_E2015_GLOBE_R2019A_54009_250_V1_0_USA_LZW.tif

gdaladdo GHS_POP_E2015_GLOBE_R2019A_54009_250_V1_0_USA_LZW.tif 2 4 8 16 32 64

Import into postgis

I am using the target DB qgis_tests

raster2pgsql -s 954009 -t 1024x1024 -l 2,4,8,16,32 -I -C  GHS_POP_E2015_GLOBE_R2019A_54009_250_V1_0_USA_LZW.tif ghs_pop_2015_esri54009 | psql qgis_tests

If your postgis is missing EPSG:54009 you can add it with:

cat <<<_TXT_ 
INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) values ( 954009, 'esri', 54009, '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ', 'PROJCS["World_Mollweide",GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mollweide"],PARAMETER["False_Easting",0],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",0],UNIT["Meter",1],AUTHORITY["EPSG","54009"]]');
_TXT_ | psql qgis_tests

Add to app.config services.isochrones section:

"statistics_providers": {
                    "provider1": {
                        "enabled": true,
                        "provider_name": "postgresql",
                        "provider_parameters": {
                            "host": "[IP of local db]",
                            "port": 5432,
                            "db_name": "qgis_tests",
                            "user": "my username",
                            "password": "my passwor",
                            "table_name": "ghs_pop_2015_esri54009",
                            "geometry_column": "rast"
                        },
                        "property_mapping": {
                            "total_pop": "total_pop"
                        },
                        "attribution": "European Commission, Joint Research Centre (JRC); Columbia University, Center for International Earth Science Information Network - CIESIN (2015):  GHS population grid, derived from GPW4, multitemporal (1975, 1990, 2000, 2015). European Commission, Joint Research Centre (JRC) [Dataset] PID: http://data.europa.eu/89h/jrc-ghsl-ghs_pop_gpw4_globe_r2015a"
           }
nilsnolde commented 3 years ago

Yep, that's almost exactly how we set it up back in the days. Only I think I used a tile size of 50 x 50, I think 1024 x 1024 could be a little inefficient for a spatial index. I think you're much more experienced with raster (distribution) though, so what's your take @elpaso ? I didn't perf test it I think, was more a gut feeling back then.

elpaso commented 3 years ago

@nilsnolde I can't say I thought much about it :smile: I just wanted to reduce the rows in my DB. Maybe something in the middle like 256 would work.

EmmanuelLM commented 1 year ago

Hi, I have successfully added 2020 population data to my local instance of openrouteservice. I was hoping to also add 2025 population data using the instructions above and add it as a second statistics providers under the attribute "total_pop2025", however this seems to fail with "Parameter 'attributes' has incorrect value of 'total_pop2025' - does this mean Openrouteservice limits the attributes that can be added or am I missing something?

TheGreatRefrigerator commented 6 months ago

Hi, I have successfully added 2020 population data to my local instance of openrouteservice. I was hoping to also add 2025 population data using the instructions above and add it as a second statistics providers under the attribute "total_pop2025", however this seems to fail with "Parameter 'attributes' has incorrect value of 'total_pop2025' - does this mean Openrouteservice limits the attributes that can be added or am I missing something?

Although a bit late: See the warning in our new documentation https://giscience.github.io/openrouteservice/run-instance/configuration/ors/endpoints/isochrones#statistics-providers You currently have to implement new attributes manually.