Create Vectortile from Parcels' Shapefiles by Tippecanoe - WASAC/vt-parcels GitHub Wiki
create database
psql -h localhost -p 25432 -U docker -d postgres
create database rw_parcels;
\c rw_parcels;
create extension postgis;
select postgis_version();
\q
transform CRS to EPSG:4326
Use QGIS to transform CRS to 4326. Shapefiles can be created under wgs84 folder.
import Shapefiles
Use QGIS to import Shapefiles, or import by shp2pgsql
command
cd PARCELS_21_07_2020/wgs84
shp2pgsql -I -s 4326 eastern_province.shp eastern_province.shp | psql -h localhost -p 25432 -U docker -d rw_parcels
shp2pgsql -I -s 4326 kigali_city_province.shp kigali_city_province | psql -h localhost -p 25432 -U docker -d rw_parcels
shp2pgsql -I -s 4326 northern_province.shp northern_province | psql -h localhost -p 25432 -U docker -d rw_parcels
shp2pgsql -I -s 4326 southern_province.shp southern_province | psql -h localhost -p 25432 -U docker -d rw_parcels
shp2pgsql -I -s 4326 western_province.shp western_province | psql -h localhost -p 25432 -U docker -d rw_parcels
create spatial index
CREATE INDEX idx_eastern_province_geometry ON public.eastern_province USING gist(geom);
CREATE INDEX idx_kigali_city_province_geometry ON public.kigali_city_province USING gist(geom);
CREATE INDEX idx_northern_province_geometry ON public.northern_province USING gist(geom);
CREATE INDEX idx_southern_province_geometry ON public.southern_province USING gist(geom);
CREATE INDEX idx_western_province_geometry ON public.western_province USING gist(geom);
Convert Shapefiles to GeoJSON by ogr2ogr
cd PARCELS_21_07_2020_wgs84
mkdir geojson
ogr2ogr -f GeoJSON ./geojson/eastern_province.geojson ./shp/eastern_province.shp
ogr2ogr -f GeoJSON ./geojson/kigali_city_province.geojson ./shp/kigali_city_province.shp
ogr2ogr -f GeoJSON ./geojson/northern_province.geojson ./shp/northern_province.shp
ogr2ogr -f GeoJSON ./geojson/southern_province.geojson ./shp/southern_province.shp
ogr2ogr -f GeoJSON ./geojson/western_province.geojson ./shp/western_province.shp
Merge GeoJSON files into a combined mbtiles by using tippecanoe
tippecanoe -z 15 -Z 15 -o parcels.mbtiles -l parcels --coalesce-densest-as-needed --extend-zooms-if-still-dropping ./geojson/eastern_province.geojson ./geojson/kigali_city_province.geojson ./geojson/northern_province.geojson ./geojson/southern_province.geojson ./geojson/western_province.geojson
Create mbtiles separately for each province
tippecanoe -rg -z 15 -Z 15 -o parcels_eastern.mbtiles ./geojson/eastern_province.geojson
tippecanoe -rg -z 15 -Z 15 -o parcels_kigali.mbtiles ./geojson/kigali_city_province.geojson
tippecanoe -rg -z 15 -Z 15 -o parcels_northern.mbtiles ./geojson/northern_province.geojson
tippecanoe -rg -z 15 -Z 15 -o parcels_southern.mbtiles ./geojson/southern_province.geojson
tippecanoe -rg -z 15 -Z 15 -o parcels_western.mbtiles ./geojson/western_province.geojson
tippecanoe -f -o parcels_kigali.mbtiles \
--coalesce-smallest-as-needed \
--coalesce-densest-as-needed \
--coalesce-fraction-as-needed \
--simplify-only-low-zooms \
--no-feature-limit \
--no-tile-size-limit \
--minimum-zoom=15 \
--maximum-zoom=15 \
--calculate-feature-density \
--drop-smallest-as-needed \
./geojson/kigali_city_province.geojson