Zoom to particular Latitude Longitude into map

View: New views
4 Messages — Rating Filter:   Alert me  

Zoom to particular Latitude Longitude into map

by Balram () :: Rate this Message:

| View Threaded | Show Only this Message

Hi friends,

I have created python script to render map using mapnik. I have done basic map operation like pan to left, right,top, bottom but pan takes only integer values so we can't use it for zooming to particular latlong. I have also done zoom to map.

But I am not able to zoom at particular latitude longitude values. I don't want to use Envelope() which takes four parameter.

My code is as below:

    myMap = Map(900,450,"+proj=latlong +datum=WGS84")
    p = Projection("+proj=latlong +datum=WGS84")
    myMap.zoom_to_box(p.forward(Envelope(52.132633,5.291266,52.182633,5.361266)))
    myMap.zoom(0.4)    
    render_to_file(myMap,"proj.png","png")

Please help me.
Any help would be greatly appreciated!!!
Thank You!!!

BalRam

Re: Zoom to particular Latitude Longitude into map

by ajayre :: Rate this Message:

| View Threaded | Show Only this Message

I use zoom_to_box and it works for me. The only other option I can see
is to pan and zoom to a specific point and zoom level. But I don't feel
it gives me enough control.

If the bounding box in the envelope does not match the proportions of
your image (900 x 450) then the box is expanded in the longer direction.
You can then use env = myMap.envelope() to get the actual envelope used.

You could always write your own function to take a single coordinate for
the center and a scale denominator then construct an envelope from those
values.

Andy

Balram wrote:

> Hi friends,
>
> I have created python script to render map using mapnik. I have done basic
> map operation like pan to left, right,top, bottom. I have also done zoom to
> map.
>
> But I am not able to zoom at particular latitude longitude values. I don't
> want to use Envelope() which takes four parameter.
>
> My code is as below:
>
>     myMap = Map(900,450,"+proj=latlong +datum=WGS84")
>     p = Projection("+proj=latlong +datum=WGS84")
>    
> myMap.zoom_to_box(p.forward(Envelope(52.132633,5.291266,52.182633,5.361266)))
>     myMap.zoom(0.4)    
>     render_to_file(myMap,"proj.png","png")
>
> Please help me.
> Any help would be greatly appreciated!!!
> Thank You!!!
>
> BalRam

--
Andy
PGP Key ID: 0xDC1B5864
_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users

Re: Zoom to particular Latitude Longitude into map

by Dane Springmeyer :: Rate this Message:

| View Threaded | Show Only this Message


On Sep 22, 2009, at 9:14 AM, Andrew Ayre wrote:

> If the bounding box in the envelope does not match the proportions of
> your image (900 x 450) then the box is expanded in the longer  
> direction.
> You can then use env = myMap.envelope() to get the actual envelope  
> used.


You can also modify the Map's 'aspect_fix_mode', which controls what  
dimension to change if the bbox proportions do not match your output  
image:

http://svn.mapnik.org/trunk/docs/api_docs/python/mapnik._mapnik.aspect_fix_mode-class.html
http://svn.mapnik.org/trunk/docs/api_docs/python/mapnik._mapnik.Map-class.html#aspect_fix_mode

These are not documented yet on the wiki - anyone? :)

Dane
_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users

Re: Zoom to particular Latitude Longitude into map

by Dane Springmeyer :: Rate this Message:

| View Threaded | Show Only this Message

Balram,

This would be a useful function - would you mind creating a trac  
ticket for this feature request?

Dane


On Sep 21, 2009, at 11:54 PM, Balram wrote:

>
> Hi friends,
>
> I have created python script to render map using mapnik. I have done  
> basic
> map operation like pan to left, right,top, bottom. I have also done  
> zoom to
> map.
>
> But I am not able to zoom at particular latitude longitude values. I  
> don't
> want to use Envelope() which takes four parameter.
>
> My code is as below:
>
>    myMap = Map(900,450,"+proj=latlong +datum=WGS84")
>    p = Projection("+proj=latlong +datum=WGS84")
>
> myMap
> .zoom_to_box
> (p.forward(Envelope(52.132633,5.291266,52.182633,5.361266)))
>    myMap.zoom(0.4)
>    render_to_file(myMap,"proj.png","png")
>
> Please help me.
> Any help would be greatly appreciated!!!
> Thank You!!!
>
> BalRam
> --
> View this message in context: http://www.nabble.com/Zoom-to-particular-Latitude-Longitude-into-map-tp25530594p25530594.html
> Sent from the Mapnik - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Mapnik-users mailing list
> Mapnik-users@...
> https://lists.berlios.de/mailman/listinfo/mapnik-users

_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users