[mapserver-users] Basic Projection Help

Matthew Pettis matthew.pettis at gmail.com
Sat Jun 28 12:05:17 EDT 2008


Thanks to the both of you for your help -- that helps me quite a bit to
understand that how to reproject a srid=-1 on the fly and how i should go
about permanently fixing it in my geometry table.

Take care,
Matt

On Sat, Jun 28, 2008 at 9:35 AM, Paul Spencer <pspencer at dmsolutions.ca>
wrote:

> There is normally a constraint set on postgis tables that specifies the
> SRID, if you want to change the SRID then you need to drop the constraint,
> set the SRID and optionally put back the constraint with the correct SRID.
>
> I do not believe this is necessary to achieve what you want, though.  An
> SRID of -1 tells postgis to return the geometry as is to mapserver.
>  Mapserver then doesn't know what the projection of the data is, but that is
> okay because you can provide an PROJECTION object on your layer in
> mapserver.  Then mapserver knows what the projection of the data is without
> having to consult postgis and will be able to reproject the data for you.
>
> So you should be able to leave your data in the database with SRID -1 and
> put
>
> PROJECTION
>  "init=epsg:26915"
> END
>
> in your layer.  Then if you use a different projection at the MAP level,
> mapserver knows that your data is in UTM zone 15 and will reproject it on
> the fly.
>
> If you are *always* going to reprojecting your data then you should
> actually transform it in the database so that you don't suffer from
> reprojection overhead on every request.
>
> Cheers
>
> Paul
>
>
> On 28-Jun-08, at 2:12 AM, pcreso at pcreso.com wrote:
>
>  Hi Matthew,
>>
>> If you loaded it from shapefiles using shp2pgsql, then use the -s flag to
>> set the srid to the correct value.
>>
>> If you \d your table, I think you'll find a constraint on it setting the
>> srid, as well as the geometrycolumns entry.
>>
>> The simplest way to get things working with mapserver may well be to leave
>> it as -1 in the database (& geometrycolumns entry) & in your mapserver
>> mapfile data statement, specify the sql returns setsrid(geom,26915) instead
>> of geom, so postgis returns the values with the appropriate SRID set,
>> irrespective of what the database actually stores.
>>
>> That will get things working until you load the data with the correct
>> srid.
>>
>> HTH,
>>
>>  Brent Wood
>>
>>
>>
>> --- On Sat, 6/28/08, Matthew Pettis <matthew.pettis at gmail.com> wrote:
>>
>>  From: Matthew Pettis <matthew.pettis at gmail.com>
>>> Subject: [mapserver-users] Basic Projection Help
>>> To: "Mapserver-users" <mapserver-users at lists.osgeo.org>
>>> Date: Saturday, June 28, 2008, 5:47 PM
>>> Hello,
>>>
>>> I'm trying to get a handle on projections and
>>> reprojections.  I have a
>>> dataset in a postgis database table that is in epsg:26915
>>> (it's the state of
>>> MN).  I know this from the metadata provided by the
>>> provider (state of
>>> Minnesota itself).
>>>
>>> When I loaded it into postgis, the geometry_columns row for
>>> this
>>> table/column combo set srid=-1.  As I know that this is in
>>> epsg:26915, I
>>> manually changed the geometry_columns row entry to it (see:
>>> ===
>>> geometry_columns === section).
>>>
>>> Problem is, I get an error of using two different
>>> geometries.  Anybody have
>>> any idea how i set the srid to the correct value of
>>> epsg:26915?  I'd like to
>>> set this correctly so I can reproject it as necessary.  The
>>> map will render
>>> with srid=-1, but then I don't think I can reproject
>>> the image correctly,
>>> right?
>>>
>>> below are what I think are the important sections to this
>>> problem.  Thanks
>>> in advance for your help.
>>>
>>> Matt
>>>
>>> === url ===
>>> ======================================================================
>>> http://localhost/cgi-bin/mapserv.exe?map=C:\ms4w\Apache\htdocs\ol<http://localhost/cgi-bin/mapserv.exe?map=C:%5Cms4w%5CApache%5Chtdocs%5Col>
>>> \mapreproj.map&mode=map
>>> ======================================================================
>>>
>>> === error message ===
>>> ======================================================================
>>> msDrawMap(): Image handling error. Failed to draw layer
>>> named 'state'.
>>> msPOSTGISLayerWhichShapes(): Query error. Error executing
>>> POSTGIS SQL
>>> statement (in FETCH ALL): DECLARE mycursor BINARY CURSOR
>>> FOR SELECT
>>> asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text
>>> from
>>> shp_state WHERE the_geom &&
>>> setSRID('BOX3D(141095.125 4809728.25,810342.625
>>> 5478975.75)'::BOX3D,
>>> find_srid('','shp_state','the_geom')
>>> ) -ERROR:
>>> Operation on two geometries with different SRIDs
>>> ======================================================================
>>>
>>> === geometry_columns ===
>>> ======================================================================
>>>
>>> oid;f_table_catalog;f_table_schema;f_table_name;f_geometry_column;coor_dimension;srid;type
>>> 336791;"''";"public";"shp_state";"the_geom";2;26915;"MULTIPOLYGON"
>>> ======================================================================
>>>
>>> === mapreproj.map ===
>>> ======================================================================
>>> MAP
>>>
>>>   ################
>>>   # Map attributes
>>>   ################
>>>  IMAGETYPE   PNG
>>>  EXTENT      184056.505 4809728.25 767381.245 5478975.75
>>>  SIZE        600 600
>>>  IMAGECOLOR  255 255 255
>>>  FONTSET
>>> "C:/ms4w/Apache/htdocs/fonts/fonts.list"
>>>
>>>   ####################
>>>   # Web settings
>>>   ####################
>>>  WEB
>>>   IMAGEPATH   "C:/ms4w/Apache/htdocs/tmp/"
>>>   IMAGEURL    "/tmp/"
>>>  END
>>>
>>>   ####################
>>>   # State
>>>   # Background shows through missing precincts to show
>>> where no votes will
>>> be coming from
>>>   ####################
>>>  LAYER
>>>   NAME              "state"
>>>
>>>   CONNECTIONTYPE    postgis
>>>   CONNECTION        "user=postgres dbname=gisvote
>>> password=postgres"
>>>   DATA              "the_geom from shp_state"
>>>   STATUS            default
>>>   TYPE              polygon
>>>
>>>   CLASS
>>>     NAME            "state"
>>>     COLOR           200 200 200
>>>   END
>>>
>>>  END # Layer state
>>>
>>> END
>>> ======================================================================
>>>
>>>
>>> --
>>> It is from the wellspring of our despair and the places
>>> that we are broken
>>> that we come to repair the world.
>>> -- Murray
>>> Waas_______________________________________________
>>> mapserver-users mailing list
>>> mapserver-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>>
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>
>
> __________________________________________
>
>   Paul Spencer
>   Chief Technology Officer
>   DM Solutions Group Inc
>   http://www.dmsolutions.ca/
>
>


-- 
It is from the wellspring of our despair and the places that we are broken
that we come to repair the world.
-- Murray Waas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080628/d9ff1c84/attachment.html


More information about the mapserver-users mailing list