Skip to content
jorgenevil edited this page Feb 26, 2016 · 4 revisions

Import data

Put shapefiles in PostGIS database

1. Check projection, must be 3857. (WGS-1984 is 4326!)  

 Note: SRID must be 3857 in db. If .prj is not this, must ogr2ogr and reproject
 //             type            OUT                    IN 
 ogr2ogr -f "ESRI Shapefile" glims_polygons_3857.shp glims_polygons.shp  -s_srs EPSG:4326 -t_srs EPSG:3857 

2. Create an .sql  
shp2pgsql -c -D -s 3857 -I simplified_land_polygons.shp public.osm_simplified_land_polygons > simplified_land_polygons.sql


3. Import into db  
 // then psql it into db like so:
 psql -d osmnode -f geo_glims_polygons_3857.sql

4. Check the_geom field, must be same (geometry)
ALTER TABLE geo_glims_polygons RENAME COLUMN geom TO geometry;    

5. Add entry to queries.js
Tricky: Natural Earth Bathymetry

First must create tables with -d option, then subsequently append with -a option.

shp2pgsql -I -s 3857 -d ne_10m_bathymetry_K_200.shp.reprojected.shp public.ne_bathymetry > ne_bathymetry_K.sql
shp2pgsql -I -s 3857 -a ne_10m_bathymetry_A_10000.shp.reprojected.shp public.ne_bathymetry > ne_bathymetry_A.sql

Then insert each file into db:

psql -U postgres -d osmnode -f ne_bathymetry_G.sql

Put OSM data in PostGIS database

// bleeding edge imposm3  
imposm3 import \  
  -connection postgis://osm:osm@localhost/osm \
  -mapping mapping.json \  
  -write -appendcache -read germany-latest.osm.pbf -deployproduction

// old version of imposm  
imposm -U gisuser -d osmdb -m osm-bright/imposm-mapping.py \
  --read --write --optimize --deploy-production-tables ../osm/planet-141229.osm.pbf

// old way
osm2pgsql -s -U gisuser -d osmdb new-york-latest.osm

Convert .CSV to ESRI Shapefile

First you need to create a definition file, called .vrt. Here you define what kind of geometry it is, projection, and x/y columns.

<OGRVRTDataSource>
    <OGRVRTLayer name="trimmedAndSlimmed">
        <SrcDataSource>trimmedAndSlimmed.csv</SrcDataSource>
        <GeometryType>wkbPoint</GeometryType>
        <LayerSRS>EPSG:32632</LayerSRS>
        <GeometryField encoding="PointFromColumns" x="x" y="y"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

Then you can run: ogr2ogr -f "ESRI Shapefile" test.shp test.vrt

Clone this wiki locally