geographic projection

Hi all,
I try to play with the Basemap module, but I'm starting with two problems:
1- All my datas are in Lambert coordonates, and Basemap want geographic
coords. Is there a way to automatically transforms the coords?
2- Trying to set a shapefile in the plot, I get:
ValueError: shapefile must have lat/lon vertices - it looks like this one has
vertices in map projection coordinates
Is the first question can be apply to shapefile?
Thanks

···

--
Lionel Roubeyrie - lroubeyrie@...1068...
LIMAIR
http://www.limair.asso.fr

Lionel Roubeyrie wrote:

Hi all,
I try to play with the Basemap module, but I'm starting with two problems:
1- All my datas are in Lambert coordonates, and Basemap want geographic coords. Is there a way to automatically transforms the coords?
  
Lionel: Basemap does not require the data to be in geographic coordinates for plotting. It's quite easy to plot the data if it is already in projection coordinates. I think your problem is probably related to the next point ...
2- Trying to set a shapefile in the plot, I get:
ValueError: shapefile must have lat/lon vertices - it looks like this one has vertices in map projection coordinates
Is the first question can be apply to shapefile?
  
The shapefile interface is not very smart yet - it doesn't know how to deal with projections, so it just assumes the data is lon/lat. If you can somehow load the data into python (perhaps by converting it to a text file?), then basemap should be quite happy to plot. it.

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg

Lionel Roubeyrie wrote:

Hi all,
I try to play with the Basemap module, but I'm starting with two problems:
1- All my datas are in Lambert coordonates, and Basemap want geographic coords. Is there a way to automatically transforms the coords?
2- Trying to set a shapefile in the plot, I get:
ValueError: shapefile must have lat/lon vertices - it looks like this one has vertices in map projection coordinates
Is the first question can be apply to shapefile?
Thanks

Lionel: Regarding the last point - there is an easy-to-use utility called shpproj that can convert shp files from projection to geographic coordinates (http://shapelib.maptools.org/shapelib-tools.html). Once it is converted to geographic coordinates, you can use the Basemap to read the shapefile and plot the data. The fillstates.py and hurrtracks.py examples show how to plot data from shapefiles.

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg

Hi,
Thanks Jeff for the link, after some compilation problems, shpproj works fine,
but now I have another problem when trying to insert a shapefile:

···

################################
lionel[Implantations]
211>m.readshapefile("/home/lionel/SIG/France/Vecteurs/test/test","test")
---------------------------------------------------------------------------
exceptions.TypeError Traceback (most recent
call last)

/home/lionel/Etudes_Techniques/ETD-2005-13_OZONE/Implantations/<console>

/usr/lib/python2.4/site-packages/matplotlib/toolkits/basemap/basemap.py in
readshapefile(self, shapefile, name, drawbounds, linewidth, color,
antialiased, ax)
   1338 ax.set_yticks([])
   1339 # set axes limits to fit map region.
-> 1340 self.set_axes_limits(ax=ax)
   1341 # save segments/polygons and shape attribute dicts as class
attributes.
   1342 self.__dict__[name]=shpsegs

/usr/lib/python2.4/site-packages/matplotlib/toolkits/basemap/basemap.py in
set_axes_limits(self, ax)
   1920 # make sure aspect ratio of map preserved.
   1921 # plot is re-centered in bounding rectangle.
-> 1922 ax.set_aspect('equal',adjusts='position')
   1923 ax.apply_aspect()
   1924

TypeError: set_aspect() got an unexpected keyword argument 'adjusts'

###################################
The same problem happens when trying examples :frowning:

Le Jeudi 20 Avril 2006 21:26, Jeff Whitaker a écrit :

Lionel Roubeyrie wrote:
> Hi all,
> I try to play with the Basemap module, but I'm starting with two
> problems: 1- All my datas are in Lambert coordonates, and Basemap want
> geographic coords. Is there a way to automatically transforms the coords?
> 2- Trying to set a shapefile in the plot, I get:
> ValueError: shapefile must have lat/lon vertices - it looks like this
> one has vertices in map projection coordinates
> Is the first question can be apply to shapefile?
> Thanks

Lionel: Regarding the last point - there is an easy-to-use utility
called shpproj that can convert shp files from projection to geographic
coordinates (http://shapelib.maptools.org/shapelib-tools.html). Once it
is converted to geographic coordinates, you can use the Basemap to read
the shapefile and plot the data. The fillstates.py and hurrtracks.py
examples show how to plot data from shapefiles.

-Jeff

--
Lionel Roubeyrie - lroubeyrie@...1068...
LIMAIR
http://www.limair.asso.fr

Lionel Roubeyrie wrote:

Hi,
Thanks Jeff for the link, after some compilation problems, shpproj works fine, but now I have another problem when trying to insert a shapefile:
################################
lionel[Implantations]
211>m.readshapefile("/home/lionel/SIG/France/Vecteurs/test/test","test")
---------------------------------------------------------------------------
exceptions.TypeError Traceback (most recent call last)

/home/lionel/Etudes_Techniques/ETD-2005-13_OZONE/Implantations/<console>

/usr/lib/python2.4/site-packages/matplotlib/toolkits/basemap/basemap.py in readshapefile(self, shapefile, name, drawbounds, linewidth, color, antialiased, ax)
   1338 ax.set_yticks([])
   1339 # set axes limits to fit map region.
-> 1340 self.set_axes_limits(ax=ax)
   1341 # save segments/polygons and shape attribute dicts as class attributes.
   1342 self.__dict__[name]=shpsegs

/usr/lib/python2.4/site-packages/matplotlib/toolkits/basemap/basemap.py in set_axes_limits(self, ax)
   1920 # make sure aspect ratio of map preserved.
   1921 # plot is re-centered in bounding rectangle.
-> 1922 ax.set_aspect('equal',adjusts='position')
   1923 ax.apply_aspect()
   1924

TypeError: set_aspect() got an unexpected keyword argument 'adjusts'

###################################
The same problem happens when trying examples :frowning:

Lionel: Are you running matplotlib from svn (not 0.87.2)? If so, you'll need the svn version of basemap as well. The axes aspect ratio handling has changed, and svn basemap has been updated to handle the new syntax.

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/CDC1 FAX : (303)497-6449
325 Broadway Web : http://www.cdc.noaa.gov/~jsw
Boulder, CO, USA 80305-3328 Office: Skaggs Research Cntr 1D-124

Oups, I have forgotten to update my local svn repository. Now it works right,
I just need to understand exactly how to use it, 'cause the result is a white
plot :slight_smile: Your examples work fine!
Thanks

···

Le Vendredi 21 Avril 2006 14:48, Jeff Whitaker a écrit :

Lionel: Are you running matplotlib from svn (not 0.87.2)? If so,
you'll need the svn version of basemap as well. The axes aspect ratio
handling has changed, and svn basemap has been updated to handle the new
syntax.

-Jeff

--
Lionel Roubeyrie - lroubeyrie@...1068...
LIMAIR
http://www.limair.asso.fr