|
From: Lionel R. <lro...@li...> - 2006-04-20 15:58:19
|
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 - lro...@li... LIMAIR http://www.limair.asso.fr |
|
From: Jeff W. <js...@fa...> - 2006-04-20 17:42:26
|
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 : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |
|
From: Jeff W. <js...@fa...> - 2006-04-20 19:26:17
|
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 : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |
|
From: Lionel R. <lro...@li...> - 2006-04-21 08:47:17
|
Hi,
Thanks Jeff for the link, after some compilation problems, shpproj works fi=
ne,=20
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")
=2D------------------------------------------------------------------------=
=2D-
exceptions.TypeError Traceback (most recent=
=20
call last)
/home/lionel/Etudes_Techniques/ETD-2005-13_OZONE/Implantations/<console>
/usr/lib/python2.4/site-packages/matplotlib/toolkits/basemap/basemap.py in=
=20
readshapefile(self, shapefile, name, drawbounds, linewidth, color,=20
antialiased, ax)
1338 ax.set_yticks([])
1339 # set axes limits to fit map region.
=2D> 1340 self.set_axes_limits(ax=3Dax)
1341 # save segments/polygons and shape attribute dicts as class=
=20
attributes.
1342 self.__dict__[name]=3Dshpsegs
/usr/lib/python2.4/site-packages/matplotlib/toolkits/basemap/basemap.py in=
=20
set_axes_limits(self, ax)
1920 # make sure aspect ratio of map preserved.
1921 # plot is re-centered in bounding rectangle.
=2D> 1922 ax.set_aspect('equal',adjusts=3D'position')
1923 ax.apply_aspect()
1924
TypeError: set_aspect() got an unexpected keyword argument 'adjusts'
###################################
The same problem happens when trying examples :-(
Le Jeudi 20 Avril 2006 21:26, Jeff Whitaker a =C3=A9crit=C2=A0:
> 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=
=20
> > geographic coords. Is there a way to automatically transforms the coord=
s?
> > 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
=2D-=20
Lionel Roubeyrie - lro...@li...
LIMAIR
http://www.limair.asso.fr
|
|
From: Jeff W. <js...@fa...> - 2006-04-21 12:48:36
|
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 :-(
>
>
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
|
|
From: Lionel R. <lro...@li...> - 2006-04-21 13:08:43
|
Oups, I have forgotten to update my local svn repository. Now it works righ= t,=20 I just need to understand exactly how to use it, 'cause the result is a whi= te=20 plot :-) Your examples work fine! Thanks Le Vendredi 21 Avril 2006 14:48, Jeff Whitaker a =C3=A9crit=C2=A0: > 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 =2D-=20 Lionel Roubeyrie - lro...@li... LIMAIR http://www.limair.asso.fr |