notes_natearth.txt

CrunchyData example

from: https://access.crunchydata.com/documentation/pg_tileserv/latest/examples/

on rserver

create db:

    $ createdb naturalearth
    $ psql naturalearth
    naturalearth=# create extension postgis;
    CREATE EXTENSION

populate db:

    cd /home/wturner/openmaptiles/wdb-map-gen/data/natearth

    shp2pgsql -D -s 4326 ne_50m_admin_0_countries.shp | psql naturalearth

    Field gdp_md_est is an FTDouble with width 11 and precision 2
    Field min_zoom is an FTDouble with width 3 and precision 1
    Field min_label is an FTDouble with width 3 and precision 1
    Field max_label is an FTDouble with width 4 and precision 1
    Shapefile type: Polygon
    Postgis type: MULTIPOLYGON[2]
    SET
    SET
    BEGIN
    CREATE TABLE
    ALTER TABLE
                            addgeometrycolumn
    --------------------------------------------------------------------------
     public.ne_50m_admin_0_countries.geom SRID:4326 TYPE:MULTIPOLYGON DIMS:2
    (1 row)

    COPY 241
    COMMIT
    ANALYZE

NOW THAT THE TABLE HAS A GEOM COLUMN...

send to opal4:

    $ pg_dump -Fc -dnaturalearth -fne.dmp
    $ scp ne.dmp wendell@ilikecarrots.com:

opal4

create database:

    > . pgmine.sh
    > createdb naturalearth
    > psql naturalearth
    naturalearth=# create extension postgis;
    CREATE EXTENSION

get from rserver:

    > pg_restore -Fc --no-owner -dnaturalearth ne.dmp

    # grant all privileges on database naturalearth to tiles;
    # grant all privileges on table ne_50m_admin_0_countries to tiles;
    GRANT

configure pg_tileserv

    vim config/ilc_tileserv.toml
    DbConnection = "postgresql://tiles:xxxx@localhost:55432/naturalearth"

view: https://notes.carrotseverywhere.com/mypg_tileserv.html

YIPEE!!!

attempt at states

laptop:

03:27:56 openmaptiles $ sput ne_50m_admin_1_states_provinces.zip

opal4:

> mv ~/cssi/stupid_tx/ne_50m_admin_1_states_provinces.zip .
> mkdir states
> cd states

> unzip ../ne_50m_admin_1_states_provinces.zip
Archive:  ../ne_50m_admin_1_states_provinces.zip
  inflating: ne_50m_admin_1_states_provinces.README.html
 extracting: ne_50m_admin_1_states_provinces.VERSION.txt
 extracting: ne_50m_admin_1_states_provinces.cpg
  inflating: ne_50m_admin_1_states_provinces.dbf
  inflating: ne_50m_admin_1_states_provinces.prj
  inflating: ne_50m_admin_1_states_provinces.shp
  inflating: ne_50m_admin_1_states_provinces.shx

and:

> export LD_LIBRARY_PATH=/home/wendell/usr/local/lib64/:$LD_LIBRARY_PATH

> shp2pgsql -D -s 4326 ne_50m_admin_1_states_provinces.shp | psql naturalearth

Field latitude is an FTDouble with width 9 and precision 5
Field longitude is an FTDouble with width 9 and precision 4
Field min_label is an FTDouble with width 3 and precision 1
Field max_label is an FTDouble with width 3 and precision 1
Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
SET
SET
BEGIN
CREATE TABLE
ALTER TABLE
                                addgeometrycolumn
---------------------------------------------------------------------------------
 public.ne_50m_admin_1_states_provinces.geom SRID:4326 TYPE:MULTIPOLYGON DIMS:2
(1 row)

COPY 100
COMMIT
ANALYZE

and:

naturalearth=# grant all privileges on table ne_50m_admin_1_states_provinces to tiles;
GRANT

edit html:

> cp mypg_tileserv.html  mypg_states.html
> vim mypg_states.html

< var vectorSourceLayer = "public.ne_50m_admin_1_states_provinces";

NEEDE TO RESTART pg_tileserv

then:

https://notes.carrotseverywhere.com/mypg_states.html

YIPEE!!!

index of layers:

https://tiles.ilikecarrots.com/index.html

Friday, after Issue #2

download ne_10m_urban_areas.zip from here:

    https://www.naturalearthdata.com/downloads/10m-cultural-vectors/

and open it up:

    cd ~/openmaptiles/natearth/friday
    unzip ne_10m_urban_areas.zip

  inflating: ne_10m_urban_areas.README.html
 extracting: ne_10m_urban_areas.VERSION.txt
 extracting: ne_10m_urban_areas.cpg
  inflating: ne_10m_urban_areas.dbf
  inflating: ne_10m_urban_areas.prj
  inflating: ne_10m_urban_areas.shp
  inflating: ne_10m_urban_areas.shx

and MANUALLY put it into the d.b.:

export LD_LIBRARY_PATH=/home/wendell/usr/local/lib64:/home/wendell/usr/local/lib

then:

> shp2pgsql -D -s 4326 ne_10m_urban_areas.shp | psql naturalearth

Field area_sqkm is an FTDouble with width 13 and precision 3
Field min_zoom is an FTDouble with width 6 and precision 1
Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
SET
SET
BEGIN
CREATE TABLE
ALTER TABLE
                         addgeometrycolumn
--------------------------------------------------------------------
 public.ne_10m_urban_areas.geom SRID:4326 TYPE:MULTIPOLYGON DIMS:2
(1 row)

COPY 11878
COMMIT
ANALYZE

and DON'T FORGET:

naturalearth=# grant select on ne_10m_airports to tiles;
naturalearth=# grant select on  ne_10m_urban_areas to tiles;

Thursday, Oct. 21: oceans & lakes

load database

browse data at NaturalEarth

startup:

    . pgmine.sh
    cd openmaptiles/natearth/
    (activate vm)
    export LD_LIBRARY_PATH=/home/wendell/usr/local/lib64/:$LD_LIBRARY_PATH
    wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/physical/ne_10m_ocean.zip
    wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/physical/ne_10m_lakes.zip

    unzip ne_10m_lakes.zip
    unzip ne_10m_ocean.zip

and insert into d.b.:

    shp2pgsql -D -s 4326 ne_10m_ocean.shp | psql naturalearth

    shp2pgsql -D -s 4326 ne_10m_lakes.shp | psql naturalearth

Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
SET
SET
BEGIN
CREATE TABLE
ALTER TABLE
                      addgeometrycolumn
--------------------------------------------------------------
 public.ne_10m_ocean.geom SRID:4326 TYPE:MULTIPOLYGON DIMS:2
(1 row)

COPY 1
COMMIT
ANALYZE

and, of course:

    grant select on all tables in schema public to tiles;

Q: do we need to restart postgis or tileserv???
A: we'll at least to pg_tileserv

HOWEVER, it looks bad to use different resolutions, so will use ne 10 always.

vue

in OL_nascnrs.vue:

in the template section:

        <vl-layer-vector-tile id="osm_oceans" ref="dbg_z_osm_oceans" z-index:7 :declutter="true">
          <vl-source-vector-tile :format-factory="vtFormatFactory"
                                 :url="ilc_url_oceans" >
          </vl-source-vector-tile>
            <vl-style-func :factory="water_factory"></vl-style-func>
        </vl-layer-vector-tile>

        <vl-layer-vector-tile id="osm_lakes" ref="dbg_z_osm_lakes" z-index:7 :declutter="true">
          <vl-source-vector-tile :format-factory="vtFormatFactory"
                                 :url="ilc_url_lakes" >
          </vl-source-vector-tile>
            <vl-style-func :factory="water_factory"></vl-style-func>
        </vl-layer-vector-tile>

and in the data() section:

        ilc_url_oceans: 'https://tiles.ilikecarrots.com/' +
                         'public.ne_50m_ocean/' +
                         '{z}/{x}/{y}.pbf',

        ilc_url_lakes: 'https://tiles.ilikecarrots.com/' +
                         'public./ne_50m_rivers_lake_centerlines/' +
                         '{z}/{x}/{y}.pbf',

Hey, wait: the great lakes didn't show up in the rivers_lakes dataset!! :-(

Ocean Problem

problem with pg_tileserv translate on -180 90, solved by cropping the ocean file:

    ogr2ogr -clipsrc -179 -80 179 80 foo ne_50m_ocean.shp
    cd foo
    shp2pgsql -D -s 4326 ne_50m_ocean.shp | psql naturalearth

    grant select on all tables in schema public to tiles;

done.