From: Rich S. <rsi...@us...> - 2012-10-09 20:38:21
|
Matplotlib folks, Probably the two most common web map services are the OGC-standard WMS service and ESRI's non-standard custom REST service. I was looking for how to do WMS request in basemap and found "testarcgisimage.py" which uses the "arcgisimage" method. It look like there was a "wmsimage" method in Basemap that was folded into a "arcgisimage" method? I think users might find that confusing (at least I did). Should these methods be different? Also for the WMS request, we want to make sure that it's possible to specify ELEVATION and TIME as parameters, since these are necessary to require WMS from > 2D datasets (e.g. time series of remote sensing data, 4D atmospheric and oceanic models, etc). 1. Example of ArcGIS REST request: http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/export?bbox=-1,0,-1,0&bboxSR=4326&imageSR=4326&size=600,800&dpi=96&format=png32&f=image 2. Example of OGC-compliant WMS request, here requesting from temperature data from NAM at 2 m above ground (ELEVATION=2) and for a specified time (TIME=2012-10-09T00%3A00%3A00.000Z). Motherlode only keeps data around for a week or so, so if the URL below stops working, try a date that is more current. http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?LAYERS=Temperature_height_above_ground&ELEVATION=2&TIME=2012-10-09T00%3A00%3A00.000Z&TRANSPARENT=true&STYLES=boxfill%2Frainbow&CRS=EPSG%3A4326&COLORSCALERANGE=271.2%2C308&NUMCOLORBANDS=20&LOGSCALE=false&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&EXCEPTIONS=XML&FORMAT=image%2Fpng&BBOX=-118.82657218194,22.15128433311,-108.63100087893,32.34685563612&WIDTH=256&HEIGHT=256 Thanks, Rich -- Dr. Richard P. Signell USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 |
From: klo uo <kl...@gm...> - 2012-10-10 20:38:15
|
Hi Rich, On Tue, Oct 9, 2012 at 10:38 PM, Rich Signell wrote: > It look like there was a "wmsimage" method in Basemap that was folded > into a "arcgisimage" method? > > IIRC, it was named like that in the test cycle, then renamed correctly to arcgis I made my first step in adding WMS method: https://gist.github.com/b05f1704127accc0a0da But I did not continue as, I saw no one interested and there were tons of non-working WMS servers, and those that do work were only US You can install basemap with by adding that function, and provide additional parameters options. It worked fine when I tested it |
From: Jeff W. <jef...@no...> - 2012-10-10 21:28:54
|
On 10/10/12 2:38 PM, klo uo wrote: > Hi Rich, > > On Tue, Oct 9, 2012 at 10:38 PM, Rich Signell wrote: > > It look like there was a "wmsimage" method in Basemap that was folded > into a "arcgisimage" method? > > > IIRC, it was named like that in the test cycle, then renamed correctly > to arcgis > I made my first step in adding WMS method: > https://gist.github.com/b05f1704127accc0a0da > > But I did not continue as, I saw no one interested and there were tons > of non-working WMS servers, and those that do work were only US > > You can install basemap with by adding that function, and provide > additional parameters options. > It worked fine when I tested it > I wonder whether it would be better to use OWSlib (http://geopython.github.com/OWSLib/) for OGS/WMS support, instead of trying to roll our own solution. It only has ElementTree as a dependency. Klo - would you be interested in rewriting your wmsimage method using OWSlib? I bet it would simplify the code quite a bit. -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-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |
From: klo uo <kl...@gm...> - 2012-10-11 01:16:35
|
On Wed, Oct 10, 2012 at 11:28 PM, Jeff Whitaker wrote: > > I wonder whether it would be better to use OWSlib (http://geopython.github.com/OWSLib/) for OGS/WMS support, instead of trying to roll our own solution. It only has ElementTree as a dependency. Klo - would you be interested in rewriting your wmsimage method using OWSlib? I bet it would simplify the code quite a bit. Hi Jeff, that's good idea :D But really, OWSlib is very small package that doesn't depend on anything so why rewrite, right? I installed it and played with it shortly. It provides all sorts of useful functions for WMS service and it can return HTTPmessage suitable for writing to file object, but not for imshow()/imread() as it's chunked encoded, as I mentioned in that gist sample. So my suggestion is we just use warpimage() and handle WMS that way, as warpimage() uses temp file with urlretrieve(). Although we can use cStringIO and avoid temp file. So user handles WMS through OWSLib the way he likes and then passes it to warpimage() like this (taken from docs): ======================================== m = Basemap(...) img = wms.getmap(layers=['global_mosaic'], styles=['visual_bright'], srs='EPSG:4326', bbox=(-112, 36, -106, 41), size=(300, 250), format='image/jpeg' ) m.warpimage(image=img.url) ======================================== where obviously wms in OWSLib WebMapService class instance |
From: Jeff W. <js...@fa...> - 2012-10-11 01:49:58
|
On 10/10/12 7:16 PM, klo uo wrote: > On Wed, Oct 10, 2012 at 11:28 PM, Jeff Whitaker wrote: >> I wonder whether it would be better to use OWSlib (http://geopython.github.com/OWSLib/) for OGS/WMS support, instead of trying to roll our own solution. It only has ElementTree as a dependency. Klo - would you be interested in rewriting your wmsimage method using OWSlib? I bet it would simplify the code quite a bit. > > Hi Jeff, > > that's good idea :D > But really, OWSlib is very small package that doesn't depend on > anything so why rewrite, right? > > I installed it and played with it shortly. It provides all sorts of > useful functions for WMS service and it can return HTTPmessage > suitable for writing to file object, but not for imshow()/imread() as > it's chunked encoded, as I mentioned in that gist sample. So my > suggestion is we just use warpimage() and handle WMS that way, as > warpimage() uses temp file with urlretrieve(). Although we can use > cStringIO and avoid temp file. > > So user handles WMS through OWSLib the way he likes and then passes it > to warpimage() like this (taken from docs): > > ======================================== > m = Basemap(...) > img = wms.getmap(layers=['global_mosaic'], > styles=['visual_bright'], > srs='EPSG:4326', > bbox=(-112, 36, -106, 41), > size=(300, 250), > format='image/jpeg' > ) > > m.warpimage(image=img.url) > ======================================== > > where obviously wms in OWSLib WebMapService class instance Klo: But warpimage assumes the image is of global extent - perhaps we could make warpimage smart enough to get the georeferencing from the wms instance but that would require some work. There must be some way to let the WMS server do the image warping and convert the result to something imshow can read - perhaps by writing to a png file (or CStringIO instance) and then reading it back in with imread? -Jeff |
From: klo uo <kl...@gm...> - 2012-10-11 02:40:15
|
On Thu, Oct 11, 2012 at 3:31 AM, Jeff Whitaker wrote: > But warpimage assumes the image is of global extent - perhaps we could > make warpimage smart enough to get the georeferencing from the wms > instance but that would require some work. There must be some way to > let the WMS server do the image warping and convert the result to > something imshow can read - perhaps by writing to a png file (or > CStringIO instance) and then reading it back in with imread? Not sure, but as in example posted, 'img' is HTTPmessage pointing to server, and I can't see how we can deduce georeference as 'wms' object is named arbitrary, it could have been named to anything: ======================================== from owslib.wms import WebMapService server = ' http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd ' wms = WebMapService(server) ... ======================================== I don't know how to make WebMapService instance for Basemap class, so can't even tell if that's good idea or not, but we can add optional parameter to warpimage() function which could help georeferencing? boundingbox? Also as I think you mentioned that warpimage() is kind of resource hog, so we should find other way if possible? Anyhow, here is function that can read chunked response, so tell what you think: ======================================== def imshow_chunked(img): if img.headers['transfer-encoding'] == 'chunked': import cStringIO sio_img = cStringIO.StringIO() while True: chunk = img.read() if not chunk: break sio_img.write(chunk) sio_img.seek(0) wms_img = imread(sio_img) sio_img.close() else: wms_img = imread(img) img.close() return imshow(wms_img, origin='upper') ======================================== Where 'img' is as in my previous mail - img = wms.getmap(...) |
From: klo uo <kl...@gm...> - 2012-10-11 04:01:15
|
On Thu, Oct 11, 2012 at 4:40 AM, klo uo wrote: > Not sure, but as in example posted, 'img' is HTTPmessage pointing to > server, and I can't see how we can deduce georeference as 'wms' object is > named arbitrary, it could have been named to anything: > What am I talking about? We can deduce from 'img.url' itself: ======================================== In [23]: import urlparse In [24]: urlparse.parse_qs(img.url) Out[24]: {'COLORSCALERANGE': ['271.2,308'], 'CRS': ['EPSG:4326'], 'STYLES': ['boxfill/rainbow'], 'VERSION': ['1.3.0'], 'bbox': ['-118,22,-108,32'], 'bgcolor': ['0xFFFFFF'], 'exceptions': ['application/vnd.ogc.se_xml'], 'format': ['image/png'], 'height': ['250'], ' http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?layers': ['Temperature_height_above_ground'], 'request': ['GetMap'], 'srs': ['None'], 'transparent': ['TRUE'], 'version': ['1.1.1'], 'width': ['250']} ======================================== So we have all information about the the service in a nice dictionary, reading it's url |
From: klo uo <kl...@gm...> - 2012-10-11 04:16:56
|
I guess that's it? warpimage() as it is now, checks if passed image is url, so we can add additional check if image is url, with urlparse to deduce image coordinates and projection if present, then overlay it over already created Basemap object. |
From: Rich S. <rsi...@us...> - 2012-10-12 11:31:26
|
WMS services are required to respond to "GetCapabiltiies" request, reporting what layers, styles, times, elevations, and projections they have available. So for example, using the Unidata WMS example below, if we do: http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMS&request=GetCapabilities we can see from the XML response that the Coordinate Reference Systems supported are: <CRS>EPSG:4326</CRS> <CRS>CRS:84</CRS> <CRS>EPSG:41001</CRS> <CRS>EPSG:3857</CRS> <CRS>EPSG:27700</CRS> <CRS>EPSG:3408</CRS> <CRS>EPSG:3409</CRS> <CRS>EPSG:32661</CRS> <CRS>EPSG:32761</CRS> And for this server, the supported response types are: <Format>image/jpeg</Format> <Format>image/png</Format> <Format>application/vnd.google-earth.kmz</Format> <Format>image/gif</Format> So I guess one way to proceed if you wanted to use WMS in Matplotlib and avoid reprojection in python would be to: 1. do the WMS GetCapabilities request to find the available supported Coordinate Reference Systems (which will vary with WMS server) 2. setup Basemap to use one of these CRS 3. use the bounding box of your current axis (in projection units) as part of a GetMap request to the WMS. -Rich On Thu, Oct 11, 2012 at 12:16 AM, klo uo <kl...@gm...> wrote: > I guess that's it? > > warpimage() as it is now, checks if passed image is url, so we can add > additional check if image is url, with urlparse to deduce image coordinates > and projection if present, then overlay it over already created Basemap > object. > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 |
From: klo uo <kl...@gm...> - 2012-10-13 23:26:46
|
That's also what that snippet I linked does. You can add it to to Basemap and it should work. However Jeff suggested we use this tiny package OWSlib and handle WMS that way, which is better IMHO, but for some reason we did not got further reply. On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell <rsi...@us...> wrote: > WMS services are required to respond to "GetCapabiltiies" request, > reporting what layers, styles, times, elevations, and projections they > have available. So for example, using the Unidata WMS example below, > if we do: > > > http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMS&request=GetCapabilities > > we can see from the XML response that the Coordinate Reference Systems > supported are: > > <CRS>EPSG:4326</CRS> > <CRS>CRS:84</CRS> > <CRS>EPSG:41001</CRS> > <CRS>EPSG:3857</CRS> > <CRS>EPSG:27700</CRS> > <CRS>EPSG:3408</CRS> > <CRS>EPSG:3409</CRS> > <CRS>EPSG:32661</CRS> > <CRS>EPSG:32761</CRS> > > And for this server, the supported response types are: > <Format>image/jpeg</Format> > <Format>image/png</Format> > <Format>application/vnd.google-earth.kmz</Format> > <Format>image/gif</Format> > > So I guess one way to proceed if you wanted to use WMS in Matplotlib > and avoid reprojection in python would be to: > 1. do the WMS GetCapabilities request to find the available supported > Coordinate Reference Systems (which will vary with WMS server) > 2. setup Basemap to use one of these CRS > 3. use the bounding box of your current axis (in projection units) as > part of a GetMap request to the WMS. > > -Rich > > On Thu, Oct 11, 2012 at 12:16 AM, klo uo <kl...@gm...> wrote: > > I guess that's it? > > > > warpimage() as it is now, checks if passed image is url, so we can add > > additional check if image is url, with urlparse to deduce image > coordinates > > and projection if present, then overlay it over already created Basemap > > object. > > > > > ------------------------------------------------------------------------------ > > Don't let slow site performance ruin your business. Deploy New Relic APM > > Deploy New Relic app performance management and know exactly > > what is happening inside your Ruby, Python, PHP, Java, and .NET app > > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > > http://p.sf.net/sfu/newrelic-dev2dev > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > > -- > Dr. Richard P. Signell (508) 457-2229 > USGS, 384 Woods Hole Rd. > Woods Hole, MA 02543-1598 > |
From: Rich S. <rsi...@us...> - 2012-10-16 14:48:33
|
Klo & Jeff, I tried making a concrete example of using OWSlib with Basemap, but althought the WMS image looks good, the warpimage does not. http://nbviewer.ipython.org/3899690/ Do you see where I went wrong? Thanks, Rich On Sat, Oct 13, 2012 at 7:26 PM, klo uo <kl...@gm...> wrote: > That's also what that snippet I linked does. You can add it to to Basemap > and it should work. > > However Jeff suggested we use this tiny package OWSlib and handle WMS that > way, which is better IMHO, but for some reason we did not got further reply. > > > > On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell <rsi...@us...> wrote: >> >> WMS services are required to respond to "GetCapabiltiies" request, >> reporting what layers, styles, times, elevations, and projections they >> have available. So for example, using the Unidata WMS example below, >> if we do: >> >> >> http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMS&request=GetCapabilities >> >> we can see from the XML response that the Coordinate Reference Systems >> supported are: >> >> <CRS>EPSG:4326</CRS> >> <CRS>CRS:84</CRS> >> <CRS>EPSG:41001</CRS> >> <CRS>EPSG:3857</CRS> >> <CRS>EPSG:27700</CRS> >> <CRS>EPSG:3408</CRS> >> <CRS>EPSG:3409</CRS> >> <CRS>EPSG:32661</CRS> >> <CRS>EPSG:32761</CRS> >> >> And for this server, the supported response types are: >> <Format>image/jpeg</Format> >> <Format>image/png</Format> >> <Format>application/vnd.google-earth.kmz</Format> >> <Format>image/gif</Format> >> >> So I guess one way to proceed if you wanted to use WMS in Matplotlib >> and avoid reprojection in python would be to: >> 1. do the WMS GetCapabilities request to find the available supported >> Coordinate Reference Systems (which will vary with WMS server) >> 2. setup Basemap to use one of these CRS >> 3. use the bounding box of your current axis (in projection units) as >> part of a GetMap request to the WMS. >> >> -Rich >> >> On Thu, Oct 11, 2012 at 12:16 AM, klo uo <kl...@gm...> wrote: >> > I guess that's it? >> > >> > warpimage() as it is now, checks if passed image is url, so we can add >> > additional check if image is url, with urlparse to deduce image >> > coordinates >> > and projection if present, then overlay it over already created Basemap >> > object. >> > >> > >> > ------------------------------------------------------------------------------ >> > Don't let slow site performance ruin your business. Deploy New Relic APM >> > Deploy New Relic app performance management and know exactly >> > what is happening inside your Ruby, Python, PHP, Java, and .NET app >> > Try New Relic at no cost today and get our sweet Data Nerd shirt too! >> > http://p.sf.net/sfu/newrelic-dev2dev >> > _______________________________________________ >> > Matplotlib-users mailing list >> > Mat...@li... >> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > >> >> >> >> -- >> Dr. Richard P. Signell (508) 457-2229 >> USGS, 384 Woods Hole Rd. >> Woods Hole, MA 02543-1598 > > -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 |
From: Jeff W. <js...@fa...> - 2012-10-16 15:44:03
|
On 10/16/12 8:48 AM, Rich Signell wrote: > Klo & Jeff, > > I tried making a concrete example of using OWSlib with Basemap, but > althought the WMS image looks good, the warpimage does not. > > http://nbviewer.ipython.org/3899690/ > > Do you see where I went wrong? > > Thanks, > Rich Rich: warpimage assumes the image is of global extent. In your example, I think you can just pass the image to the basemap imshow method with from matplotlib.image import imread import urllib2 m.imshow(imread(urllib2.urlopen(url)),origin='upper') Klo previously mentioned there might be a problem with the png data from the WMS server being 'chunked', s you might have to use klo's imshow_chunked function http://www.mail-archive.com/mat...@li.../msg25618.html -Jeff > > On Sat, Oct 13, 2012 at 7:26 PM, klo uo <kl...@gm...> wrote: >> That's also what that snippet I linked does. You can add it to to Basemap >> and it should work. >> >> However Jeff suggested we use this tiny package OWSlib and handle WMS that >> way, which is better IMHO, but for some reason we did not got further reply. >> >> >> >> On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell <rsi...@us...> wrote: >>> WMS services are required to respond to "GetCapabiltiies" request, >>> reporting what layers, styles, times, elevations, and projections they >>> have available. So for example, using the Unidata WMS example below, >>> if we do: >>> >>> >>> http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMS&request=GetCapabilities >>> >>> we can see from the XML response that the Coordinate Reference Systems >>> supported are: >>> >>> <CRS>EPSG:4326</CRS> >>> <CRS>CRS:84</CRS> >>> <CRS>EPSG:41001</CRS> >>> <CRS>EPSG:3857</CRS> >>> <CRS>EPSG:27700</CRS> >>> <CRS>EPSG:3408</CRS> >>> <CRS>EPSG:3409</CRS> >>> <CRS>EPSG:32661</CRS> >>> <CRS>EPSG:32761</CRS> >>> >>> And for this server, the supported response types are: >>> <Format>image/jpeg</Format> >>> <Format>image/png</Format> >>> <Format>application/vnd.google-earth.kmz</Format> >>> <Format>image/gif</Format> >>> >>> So I guess one way to proceed if you wanted to use WMS in Matplotlib >>> and avoid reprojection in python would be to: >>> 1. do the WMS GetCapabilities request to find the available supported >>> Coordinate Reference Systems (which will vary with WMS server) >>> 2. setup Basemap to use one of these CRS >>> 3. use the bounding box of your current axis (in projection units) as >>> part of a GetMap request to the WMS. >>> >>> -Rich >>> >>> On Thu, Oct 11, 2012 at 12:16 AM, klo uo <kl...@gm...> wrote: >>>> I guess that's it? >>>> >>>> warpimage() as it is now, checks if passed image is url, so we can add >>>> additional check if image is url, with urlparse to deduce image >>>> coordinates >>>> and projection if present, then overlay it over already created Basemap >>>> object. >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> Don't let slow site performance ruin your business. Deploy New Relic APM >>>> Deploy New Relic app performance management and know exactly >>>> what is happening inside your Ruby, Python, PHP, Java, and .NET app >>>> Try New Relic at no cost today and get our sweet Data Nerd shirt too! >>>> http://p.sf.net/sfu/newrelic-dev2dev >>>> _______________________________________________ >>>> Matplotlib-users mailing list >>>> Mat...@li... >>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>> >>> >>> >>> -- >>> Dr. Richard P. Signell (508) 457-2229 >>> USGS, 384 Woods Hole Rd. >>> Woods Hole, MA 02543-1598 >> > > |
From: Rich S. <rsi...@us...> - 2012-10-16 17:20:15
|
Jeff, Yep, that worked! So here is a working example of OWSlib with Basemap: http://nbviewer.ipython.org/3900648/ I switched the Basemap projection to 'cyl' because we need to ensure that Basemap and WMS are using the same projection, right? (and since I had requested EPSG:4326 from WMS, that's the 'cyl' in Basemap). Thanks! Rich On Tue, Oct 16, 2012 at 11:38 AM, Jeff Whitaker <js...@fa...> wrote: > On 10/16/12 8:48 AM, Rich Signell wrote: >> >> Klo & Jeff, >> >> I tried making a concrete example of using OWSlib with Basemap, but >> althought the WMS image looks good, the warpimage does not. >> >> http://nbviewer.ipython.org/3899690/ >> >> Do you see where I went wrong? >> >> Thanks, >> Rich > > > Rich: warpimage assumes the image is of global extent. In your example, I > think you can just pass the image to the basemap imshow method with > > from matplotlib.image import imread > import urllib2 > m.imshow(imread(urllib2.urlopen(url)),origin='upper') > > Klo previously mentioned there might be a problem with the png data from the > WMS server being 'chunked', s you might have to use klo's imshow_chunked > function > > http://www.mail-archive.com/mat...@li.../msg25618.html > > > -Jeff > >> >> On Sat, Oct 13, 2012 at 7:26 PM, klo uo <kl...@gm...> wrote: >>> >>> That's also what that snippet I linked does. You can add it to to Basemap >>> and it should work. >>> >>> However Jeff suggested we use this tiny package OWSlib and handle WMS >>> that >>> way, which is better IMHO, but for some reason we did not got further >>> reply. >>> >>> >>> >>> On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell <rsi...@us...> wrote: >>>> >>>> WMS services are required to respond to "GetCapabiltiies" request, >>>> reporting what layers, styles, times, elevations, and projections they >>>> have available. So for example, using the Unidata WMS example below, >>>> if we do: >>>> >>>> >>>> >>>> http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMS&request=GetCapabilities >>>> >>>> we can see from the XML response that the Coordinate Reference Systems >>>> supported are: >>>> >>>> <CRS>EPSG:4326</CRS> >>>> <CRS>CRS:84</CRS> >>>> <CRS>EPSG:41001</CRS> >>>> <CRS>EPSG:3857</CRS> >>>> <CRS>EPSG:27700</CRS> >>>> <CRS>EPSG:3408</CRS> >>>> <CRS>EPSG:3409</CRS> >>>> <CRS>EPSG:32661</CRS> >>>> <CRS>EPSG:32761</CRS> >>>> >>>> And for this server, the supported response types are: >>>> <Format>image/jpeg</Format> >>>> <Format>image/png</Format> >>>> <Format>application/vnd.google-earth.kmz</Format> >>>> <Format>image/gif</Format> >>>> >>>> So I guess one way to proceed if you wanted to use WMS in Matplotlib >>>> and avoid reprojection in python would be to: >>>> 1. do the WMS GetCapabilities request to find the available supported >>>> Coordinate Reference Systems (which will vary with WMS server) >>>> 2. setup Basemap to use one of these CRS >>>> 3. use the bounding box of your current axis (in projection units) as >>>> part of a GetMap request to the WMS. >>>> >>>> -Rich >>>> >>>> On Thu, Oct 11, 2012 at 12:16 AM, klo uo <kl...@gm...> wrote: >>>>> >>>>> I guess that's it? >>>>> >>>>> warpimage() as it is now, checks if passed image is url, so we can add >>>>> additional check if image is url, with urlparse to deduce image >>>>> coordinates >>>>> and projection if present, then overlay it over already created Basemap >>>>> object. >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Don't let slow site performance ruin your business. Deploy New Relic >>>>> APM >>>>> Deploy New Relic app performance management and know exactly >>>>> what is happening inside your Ruby, Python, PHP, Java, and .NET app >>>>> Try New Relic at no cost today and get our sweet Data Nerd shirt too! >>>>> http://p.sf.net/sfu/newrelic-dev2dev >>>>> _______________________________________________ >>>>> Matplotlib-users mailing list >>>>> Mat...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>> >>>> >>>> >>>> -- >>>> Dr. Richard P. Signell (508) 457-2229 >>>> USGS, 384 Woods Hole Rd. >>>> Woods Hole, MA 02543-1598 >>> >>> >> >> > -- Dr. Richard P. Signell (508) 457-2229 USGS, 384 Woods Hole Rd. Woods Hole, MA 02543-1598 |
From: Jeff W. <js...@fa...> - 2012-10-16 17:28:56
|
On 10/16/12 11:20 AM, Rich Signell wrote: > Jeff, > Yep, that worked! So here is a working example of OWSlib with > Basemap: http://nbviewer.ipython.org/3900648/ > > I switched the Basemap projection to 'cyl' because we need to ensure > that Basemap and WMS are using the same projection, right? (and since > I had requested EPSG:4326 from WMS, that's the 'cyl' in Basemap). > > Thanks! > Rich Rich: That's right. I'll go ahead and create a wmsimage method, similar to Klo's, but that uses OWSlib. You will then have to specify the projection using the epsg keyword when creating the Basemap instance. -Jeff > > On Tue, Oct 16, 2012 at 11:38 AM, Jeff Whitaker <js...@fa...> wrote: >> On 10/16/12 8:48 AM, Rich Signell wrote: >>> Klo & Jeff, >>> >>> I tried making a concrete example of using OWSlib with Basemap, but >>> althought the WMS image looks good, the warpimage does not. >>> >>> http://nbviewer.ipython.org/3899690/ >>> >>> Do you see where I went wrong? >>> >>> Thanks, >>> Rich >> >> Rich: warpimage assumes the image is of global extent. In your example, I >> think you can just pass the image to the basemap imshow method with >> >> from matplotlib.image import imread >> import urllib2 >> m.imshow(imread(urllib2.urlopen(url)),origin='upper') >> >> Klo previously mentioned there might be a problem with the png data from the >> WMS server being 'chunked', s you might have to use klo's imshow_chunked >> function >> >> http://www.mail-archive.com/mat...@li.../msg25618.html >> >> >> -Jeff >> >>> On Sat, Oct 13, 2012 at 7:26 PM, klo uo <kl...@gm...> wrote: >>>> That's also what that snippet I linked does. You can add it to to Basemap >>>> and it should work. >>>> >>>> However Jeff suggested we use this tiny package OWSlib and handle WMS >>>> that >>>> way, which is better IMHO, but for some reason we did not got further >>>> reply. >>>> >>>> >>>> >>>> On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell <rsi...@us...> wrote: >>>>> WMS services are required to respond to "GetCapabiltiies" request, >>>>> reporting what layers, styles, times, elevations, and projections they >>>>> have available. So for example, using the Unidata WMS example below, >>>>> if we do: >>>>> >>>>> >>>>> >>>>> http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMS&request=GetCapabilities >>>>> >>>>> we can see from the XML response that the Coordinate Reference Systems >>>>> supported are: >>>>> >>>>> <CRS>EPSG:4326</CRS> >>>>> <CRS>CRS:84</CRS> >>>>> <CRS>EPSG:41001</CRS> >>>>> <CRS>EPSG:3857</CRS> >>>>> <CRS>EPSG:27700</CRS> >>>>> <CRS>EPSG:3408</CRS> >>>>> <CRS>EPSG:3409</CRS> >>>>> <CRS>EPSG:32661</CRS> >>>>> <CRS>EPSG:32761</CRS> >>>>> >>>>> And for this server, the supported response types are: >>>>> <Format>image/jpeg</Format> >>>>> <Format>image/png</Format> >>>>> <Format>application/vnd.google-earth.kmz</Format> >>>>> <Format>image/gif</Format> >>>>> >>>>> So I guess one way to proceed if you wanted to use WMS in Matplotlib >>>>> and avoid reprojection in python would be to: >>>>> 1. do the WMS GetCapabilities request to find the available supported >>>>> Coordinate Reference Systems (which will vary with WMS server) >>>>> 2. setup Basemap to use one of these CRS >>>>> 3. use the bounding box of your current axis (in projection units) as >>>>> part of a GetMap request to the WMS. >>>>> >>>>> -Rich >>>>> >>>>> On Thu, Oct 11, 2012 at 12:16 AM, klo uo <kl...@gm...> wrote: >>>>>> I guess that's it? >>>>>> >>>>>> warpimage() as it is now, checks if passed image is url, so we can add >>>>>> additional check if image is url, with urlparse to deduce image >>>>>> coordinates >>>>>> and projection if present, then overlay it over already created Basemap >>>>>> object. >>>>>> >>>>>> >>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>> Don't let slow site performance ruin your business. Deploy New Relic >>>>>> APM >>>>>> Deploy New Relic app performance management and know exactly >>>>>> what is happening inside your Ruby, Python, PHP, Java, and .NET app >>>>>> Try New Relic at no cost today and get our sweet Data Nerd shirt too! >>>>>> http://p.sf.net/sfu/newrelic-dev2dev >>>>>> _______________________________________________ >>>>>> Matplotlib-users mailing list >>>>>> Mat...@li... >>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>>> >>>>> >>>>> -- >>>>> Dr. Richard P. Signell (508) 457-2229 >>>>> USGS, 384 Woods Hole Rd. >>>>> Woods Hole, MA 02543-1598 >>>> >>> > > |
From: Jeff W. <js...@fa...> - 2012-10-16 18:34:53
|
On 10/16/12 11:20 AM, Rich Signell wrote: > Jeff, > Yep, that worked! So here is a working example of OWSlib with > Basemap: http://nbviewer.ipython.org/3900648/ > > I switched the Basemap projection to 'cyl' because we need to ensure > that Basemap and WMS are using the same projection, right? (and since > I had requested EPSG:4326 from WMS, that's the 'cyl' in Basemap). > > Thanks! > Rich Rich: I took your code and made it into a new example. https://github.com/matplotlib/basemap/pull/84 I think it may be better not to try to create a wmsimage method, since OWSlib.wms.WebMapService is quite a complicated beast to wrap. -Jeff > > On Tue, Oct 16, 2012 at 11:38 AM, Jeff Whitaker <js...@fa...> wrote: >> On 10/16/12 8:48 AM, Rich Signell wrote: >>> Klo & Jeff, >>> >>> I tried making a concrete example of using OWSlib with Basemap, but >>> althought the WMS image looks good, the warpimage does not. >>> >>> http://nbviewer.ipython.org/3899690/ >>> >>> Do you see where I went wrong? >>> >>> Thanks, >>> Rich >> >> Rich: warpimage assumes the image is of global extent. In your example, I >> think you can just pass the image to the basemap imshow method with >> >> from matplotlib.image import imread >> import urllib2 >> m.imshow(imread(urllib2.urlopen(url)),origin='upper') >> >> Klo previously mentioned there might be a problem with the png data from the >> WMS server being 'chunked', s you might have to use klo's imshow_chunked >> function >> >> http://www.mail-archive.com/mat...@li.../msg25618.html >> >> >> -Jeff >> >>> On Sat, Oct 13, 2012 at 7:26 PM, klo uo <kl...@gm...> wrote: >>>> That's also what that snippet I linked does. You can add it to to Basemap >>>> and it should work. >>>> >>>> However Jeff suggested we use this tiny package OWSlib and handle WMS >>>> that >>>> way, which is better IMHO, but for some reason we did not got further >>>> reply. >>>> >>>> >>>> >>>> On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell <rsi...@us...> wrote: >>>>> WMS services are required to respond to "GetCapabiltiies" request, >>>>> reporting what layers, styles, times, elevations, and projections they >>>>> have available. So for example, using the Unidata WMS example below, >>>>> if we do: >>>>> >>>>> >>>>> >>>>> http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMS&request=GetCapabilities >>>>> >>>>> we can see from the XML response that the Coordinate Reference Systems >>>>> supported are: >>>>> >>>>> <CRS>EPSG:4326</CRS> >>>>> <CRS>CRS:84</CRS> >>>>> <CRS>EPSG:41001</CRS> >>>>> <CRS>EPSG:3857</CRS> >>>>> <CRS>EPSG:27700</CRS> >>>>> <CRS>EPSG:3408</CRS> >>>>> <CRS>EPSG:3409</CRS> >>>>> <CRS>EPSG:32661</CRS> >>>>> <CRS>EPSG:32761</CRS> >>>>> >>>>> And for this server, the supported response types are: >>>>> <Format>image/jpeg</Format> >>>>> <Format>image/png</Format> >>>>> <Format>application/vnd.google-earth.kmz</Format> >>>>> <Format>image/gif</Format> >>>>> >>>>> So I guess one way to proceed if you wanted to use WMS in Matplotlib >>>>> and avoid reprojection in python would be to: >>>>> 1. do the WMS GetCapabilities request to find the available supported >>>>> Coordinate Reference Systems (which will vary with WMS server) >>>>> 2. setup Basemap to use one of these CRS >>>>> 3. use the bounding box of your current axis (in projection units) as >>>>> part of a GetMap request to the WMS. >>>>> >>>>> -Rich >>>>> >>>>> On Thu, Oct 11, 2012 at 12:16 AM, klo uo <kl...@gm...> wrote: >>>>>> I guess that's it? >>>>>> >>>>>> warpimage() as it is now, checks if passed image is url, so we can add >>>>>> additional check if image is url, with urlparse to deduce image >>>>>> coordinates >>>>>> and projection if present, then overlay it over already created Basemap >>>>>> object. >>>>>> >>>>>> >>>>>> >>>>>> ------------------------------------------------------------------------------ >>>>>> Don't let slow site performance ruin your business. Deploy New Relic >>>>>> APM >>>>>> Deploy New Relic app performance management and know exactly >>>>>> what is happening inside your Ruby, Python, PHP, Java, and .NET app >>>>>> Try New Relic at no cost today and get our sweet Data Nerd shirt too! >>>>>> http://p.sf.net/sfu/newrelic-dev2dev >>>>>> _______________________________________________ >>>>>> Matplotlib-users mailing list >>>>>> Mat...@li... >>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>>> >>>>> >>>>> -- >>>>> Dr. Richard P. Signell (508) 457-2229 >>>>> USGS, 384 Woods Hole Rd. >>>>> Woods Hole, MA 02543-1598 >>>> >>> > > |
From: Jeff W. <jef...@no...> - 2012-10-17 16:27:33
|
On 10/16/12 12:29 PM, Jeff Whitaker wrote: > On 10/16/12 11:20 AM, Rich Signell wrote: >> Jeff, >> Yep, that worked! So here is a working example of OWSlib with >> Basemap: http://nbviewer.ipython.org/3900648/ >> >> I switched the Basemap projection to 'cyl' because we need to ensure >> that Basemap and WMS are using the same projection, right? (and since >> I had requested EPSG:4326 from WMS, that's the 'cyl' in Basemap). >> >> Thanks! >> Rich > Rich: I took your code and made it into a new example. > > https://github.com/matplotlib/basemap/pull/84 > > I think it may be better not to try to create a wmsimage method, since > OWSlib.wms.WebMapService is quite a complicated beast to wrap. > > -Jeff Rich: I went ahead and added a wmsimage method to Basemap (similar to Klo's implementation) and modified your example to use it. The extra **kwargs are just passed on to OWSLib.wms.WebMapService.getmap. Please add comments to pull request https://github.com/matplotlib/basemap/pull/84 -Jeff >> On Tue, Oct 16, 2012 at 11:38 AM, Jeff Whitaker <js...@fa...> wrote: >>> On 10/16/12 8:48 AM, Rich Signell wrote: >>>> Klo & Jeff, >>>> >>>> I tried making a concrete example of using OWSlib with Basemap, but >>>> althought the WMS image looks good, the warpimage does not. >>>> >>>> http://nbviewer.ipython.org/3899690/ >>>> >>>> Do you see where I went wrong? >>>> >>>> Thanks, >>>> Rich >>> Rich: warpimage assumes the image is of global extent. In your example, I >>> think you can just pass the image to the basemap imshow method with >>> >>> from matplotlib.image import imread >>> import urllib2 >>> m.imshow(imread(urllib2.urlopen(url)),origin='upper') >>> >>> Klo previously mentioned there might be a problem with the png data from the >>> WMS server being 'chunked', s you might have to use klo's imshow_chunked >>> function >>> >>> http://www.mail-archive.com/mat...@li.../msg25618.html >>> >>> >>> -Jeff >>> >>>> On Sat, Oct 13, 2012 at 7:26 PM, klo uo <kl...@gm...> wrote: >>>>> That's also what that snippet I linked does. You can add it to to Basemap >>>>> and it should work. >>>>> >>>>> However Jeff suggested we use this tiny package OWSlib and handle WMS >>>>> that >>>>> way, which is better IMHO, but for some reason we did not got further >>>>> reply. >>>>> >>>>> >>>>> >>>>> On Fri, Oct 12, 2012 at 1:31 PM, Rich Signell <rsi...@us...> wrote: >>>>>> WMS services are required to respond to "GetCapabiltiies" request, >>>>>> reporting what layers, styles, times, elevations, and projections they >>>>>> have available. So for example, using the Unidata WMS example below, >>>>>> if we do: >>>>>> >>>>>> >>>>>> >>>>>> http://motherlode.ucar.edu:8080/thredds/wms/fmrc/NCEP/NAM/CONUS_12km/NCEP-NAM-CONUS_12km-noaaport_best.ncd?service=WMS&request=GetCapabilities >>>>>> >>>>>> we can see from the XML response that the Coordinate Reference Systems >>>>>> supported are: >>>>>> >>>>>> <CRS>EPSG:4326</CRS> >>>>>> <CRS>CRS:84</CRS> >>>>>> <CRS>EPSG:41001</CRS> >>>>>> <CRS>EPSG:3857</CRS> >>>>>> <CRS>EPSG:27700</CRS> >>>>>> <CRS>EPSG:3408</CRS> >>>>>> <CRS>EPSG:3409</CRS> >>>>>> <CRS>EPSG:32661</CRS> >>>>>> <CRS>EPSG:32761</CRS> >>>>>> >>>>>> And for this server, the supported response types are: >>>>>> <Format>image/jpeg</Format> >>>>>> <Format>image/png</Format> >>>>>> <Format>application/vnd.google-earth.kmz</Format> >>>>>> <Format>image/gif</Format> >>>>>> >>>>>> So I guess one way to proceed if you wanted to use WMS in Matplotlib >>>>>> and avoid reprojection in python would be to: >>>>>> 1. do the WMS GetCapabilities request to find the available supported >>>>>> Coordinate Reference Systems (which will vary with WMS server) >>>>>> 2. setup Basemap to use one of these CRS >>>>>> 3. use the bounding box of your current axis (in projection units) as >>>>>> part of a GetMap request to the WMS. >>>>>> >>>>>> -Rich >>>>>> >>>>>> On Thu, Oct 11, 2012 at 12:16 AM, klo uo <kl...@gm...> wrote: >>>>>>> I guess that's it? >>>>>>> >>>>>>> warpimage() as it is now, checks if passed image is url, so we can add >>>>>>> additional check if image is url, with urlparse to deduce image >>>>>>> coordinates >>>>>>> and projection if present, then overlay it over already created Basemap >>>>>>> object. >>>>>>> >>>>>>> >>>>>>> >>>>>>> ------------------------------------------------------------------------------ >>>>>>> Don't let slow site performance ruin your business. Deploy New Relic >>>>>>> APM >>>>>>> Deploy New Relic app performance management and know exactly >>>>>>> what is happening inside your Ruby, Python, PHP, Java, and .NET app >>>>>>> Try New Relic at no cost today and get our sweet Data Nerd shirt too! >>>>>>> http://p.sf.net/sfu/newrelic-dev2dev >>>>>>> _______________________________________________ >>>>>>> Matplotlib-users mailing list >>>>>>> Mat...@li... >>>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>>>>>> >>>>>> -- >>>>>> Dr. Richard P. Signell (508) 457-2229 >>>>>> USGS, 384 Woods Hole Rd. >>>>>> Woods Hole, MA 02543-1598 >> > > ------------------------------------------------------------------------------ > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- 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-113 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |