[postgis-users] pgsql2shp usage

Chris Hermansen chris.hermansen at timberline.ca
Mon Jan 11 13:09:51 PST 2010


Ok well it seems to me that your second step, namely pgsql2shp, is not 
necessary if you have no use for a shape file in the end.  So let's 
focus on your osm2pgsql command

In your first e-mail, you said:

> I downloaded an OSM map file namely "india.osm.bz2".
> I transported it in PostgreSQL database "gis" with the command :
>
> ./osm2pgsql -m -d gis india.osm.bz2 
>
> The above command resulted in the creation of the following tables filled with data in database "gis"
>
> gis=# \d
>                  List of relations
>  Schema |        Name        |   Type   |  Owner
> --------+--------------------+----------+----------
>  public | geometry_columns   | table    | anisha
>  public | planet_osm_line    | table    | anisha
>  public | planet_osm_point   | table    | anisha
>  public | planet_osm_polygon | table    | anisha
>  public | planet_osm_roads   | table    | anisha
>  public | polygon_oid_seq    | sequence | postgres
>  public | spatial_ref_sys    | table    | anisha
So what is wrong with this?  Looks like your data is in the postgis database...



Anisha Kaul wrote:
>
> Hi,
>
> Many thanks to all of you for bothering to reply !!
>
> From Chris Hermansen
>
> > Anisha, why are you converting to shape file?
>
> I failed to load the map directly from the database !
>
> So I thought it will be a boostup for me if I manage to load the map 
> from a shape file, and then I can go for the database reading !
>
> I didn't have any problem in loading a world map from a shape file 
> directly downloaded from the internet, but I am facing problems when I 
> convert the postgres data in a shape file and then try to load it.
>
> From Regina
>
> > Never worked with osm data, but since I created the .prj generator in
>
> > pgsql2shp, I can tell you it reads the srid of the geometry and looks up the
> > srtext in spatial ref and outputs that to the .prj file.
> > I suspect osm data is in Mercator not long lat.  If you want your output to
> > be in long lat, you need to transform and use an sql statement
> > pgsql2shp -f "/path/to/filename" -h myserver -u apguser -P apgpassword
> > mygisdb 
> > 	"SELECT field1 AS hs_num, field2...., ST_Transform(the_geom,4326) As
> > the_geom FROM planet_osm_line"
> I tried what u said as follows:
> ______________________________________________
>
> pgsql2shp -f ../data/myfile gis "SELECT *, ST_Transform(way,4326) As 
> the_geom FROM planet_osm_line"
>
> Output:
>
> Preparing table for user query... Failed: ERROR: AddToPROJ4SRSCache: 
> Cannot find SRID (4326) in spatial_ref_sys
>
> ______________________________________________
>
> Then With reference to this 
> http://postgis.refractions.net/pipermail/postgis-users/2008-February/018486.html 
> web page I executed the following in the postgres database
>
> ______________________________________________
>
> gis=# SELECT UpdateGeometrySRID ('public', 'planet_osm_polygon','way', 
> 4236);
>
> Output:
>
> ERROR: constraint "enforce_srid_way" of relation "planet_osm_polygon" 
> does not exist
>
> CONTEXT: SQL statement "ALTER TABLE public.planet_osm_polygon DROP 
> constraint enforce_srid_way"
>
> PL/pgSQL function "updategeometrysrid" line 53 at EXECUTE statement
>
> SQL statement "SELECT UpdateGeometrySRID('', $1 , $2 , $3 , $4 )"
>
> PL/pgSQL function "updategeometrysrid" line 4 at SQL statement
>
> ______________________________________________
>
> I don't know what to do now, please guide !
>
> -- 
>
> Regards,
>
> Anisha Kaul
>
>
> 	
>
> Hi-Tech Gears Limited, Gurgaon, India
>
> 	
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users


-- 
Regards,

Chris Hermansen · chris.hermansen at timberline.ca · skype:clhermansen
tel+1.604.714.2878   ·  fax+1.604.733.0631   ·   mob+1.778.840.4625
Timberline Natural Resource Group Ltd   ·  http://www.timberline.ca
401  ·  958 West 8th Avenue  ·  Vancouver BC  ·  Canada  ·  V5Z 1E5




More information about the postgis-users mailing list